From 85d9fc9ce3f1137222ea4616e327a732412d08d2 Mon Sep 17 00:00:00 2001 From: jake Date: Tue, 31 Jan 2023 20:00:18 -0700 Subject: [PATCH] a test for bank item_id stuff --- tests/test_item_id.rs | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/tests/test_item_id.rs b/tests/test_item_id.rs index dfe8b7b..f8f165f 100644 --- a/tests/test_item_id.rs +++ b/tests/test_item_id.rs @@ -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(); +}