Compare commits

...

3 Commits

Author SHA1 Message Date
6399cbbb0e fix mag pbs maybe I dunno
Some checks failed
continuous-integration/drone/push Build is failing
2023-02-01 19:21:30 -07:00
85d9fc9ce3 a test for bank item_id stuff 2023-01-31 20:00:18 -07:00
0d3161e1b4 more error context 2023-01-31 20:00:03 -07:00
3 changed files with 87 additions and 10 deletions

View File

@ -11,7 +11,7 @@ photon_blast = "Pilla"
[Surya]
feed_table = 3
photon_blast = "Leilla"
photon_blast = "Golla"
[Vayu]
feed_table = 4
@ -19,7 +19,7 @@ photon_blast = "MyllaYoulla"
[Varaha]
feed_table = 4
photon_blast = "Leilla"
photon_blast = "Golla"
[Kama]
feed_table = 4
@ -27,7 +27,7 @@ photon_blast = "Pilla"
[Ushasu]
feed_table = 4
photon_blast = "Leilla"
photon_blast = "Golla"
[Apsaras]
feed_table = 4
@ -35,7 +35,7 @@ photon_blast = "Estlla"
[Kumara]
feed_table = 4
photon_blast = "Leilla"
photon_blast = "Golla"
[Kaitabha]
feed_table = 4
@ -55,7 +55,7 @@ photon_blast = "Estlla"
[Rudra]
feed_table = 2
photon_blast = "Leilla"
photon_blast = "Golla"
[Marutah]
feed_table = 2
@ -63,7 +63,7 @@ photon_blast = "Pilla"
[Yaksa]
feed_table = 5
photon_blast = "Leilla"
photon_blast = "Golla"
[Sita]
feed_table = 5
@ -99,7 +99,7 @@ photon_blast = "Estlla"
[Vritra]
feed_table = 1
photon_blast = "Golla"
photon_blast = "Leilla"
[Namuci]
feed_table = 2
@ -107,7 +107,7 @@ photon_blast = "MyllaYoulla"
[Sumba]
feed_table = 2
photon_blast = "Leilla"
photon_blast = "Golla"
[Naga]
feed_table = 6
@ -144,7 +144,7 @@ photon_blast = "Estlla"
[Naraka]
feed_table = 6
photon_blast = "Leilla"
photon_blast = "Golla"
[Madhu]
feed_table = 6

View File

@ -5,6 +5,7 @@ use async_std::sync::Arc;
use std::future::Future;
use std::pin::Pin;
use std::iter::IntoIterator;
use anyhow::Context;
use libpso::packet::{ship::Message, messages::GameMessage};
use crate::ship::map::MapArea;
@ -112,7 +113,8 @@ where
let mut inventory = item_state.inventory(&character_id).await?;
let item = inventory.remove_item(&item_id, amount)
.await
.ok_or_else(|| ItemStateError::NoInventoryItem(item_id))?;
.ok_or_else(|| ItemStateError::NoInventoryItem(item_id))
.with_context(|| format!("{inventory:#?}"))?;
transaction.gateway().set_character_inventory(&character_id, &inventory.as_inventory_entity(&character_id)).await?;
item_state.set_inventory(inventory).await;

View File

@ -296,3 +296,78 @@ async fn test_using_some_monomates_after_a_convoluted_series_of_leaves_and_joins
}).unwrap();
}
#[async_std::test]
async fn test_depositing_a_full_stack_then_withdrawing_part() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_items = Vec::new();
for tool in vec![item::tool::ToolType::Monofluid, item::tool::ToolType::Difluid, item::tool::ToolType::Trifluid].into_iter() {
let mut item = Vec::new();
for _ in 0..5usize {
item.push(entity_gateway.create_item(
item::NewItemEntity {
item: item::ItemDetail::Tool(
item::tool::Tool {
tool: tool
}
),
}).await.unwrap());
}
p1_items.push(item::InventoryItemEntity::Stacked(item));
}
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(p1_items)).await.unwrap();
let mut monomates = Vec::new();
for _ in 0..3usize {
monomates.push(entity_gateway.create_item(
item::NewItemEntity {
item: item::ItemDetail::Tool(
item::tool::Tool {
tool: item::tool::ToolType::Monomate,
}
),
}).await.unwrap());
}
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone())
.build());
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
join_lobby(&mut ship, ClientId(1)).await;
create_room(&mut ship, ClientId(1), "room", "").await;
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
client: 0,
target: 0,
unknown: 0,
})))).await.unwrap();
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
client: 0,
target: 0,
item_id: 0x10001,
action: 0,
item_amount: 5,
meseta_amount: 0,
unknown: 0,
})))).await.unwrap();
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
client: 0,
target: 0,
item_id: 0x10001,
action: 1,
item_amount: 3,
meseta_amount: 0,
unknown: 0,
})))).await.unwrap();
ship.handle(ClientId(1), RecvShipPacket::Message(Message::new(GameMessage::PlayerUseItem(PlayerUseItem {
client: 0,
target: 0,
item_id: 0x20001,
})))).await.unwrap();
}