diff --git a/src/ship/items/actions.rs b/src/ship/items/actions.rs index 4351d09..f4dcbec 100644 --- a/src/ship/items/actions.rs +++ b/src/ship/items/actions.rs @@ -292,6 +292,7 @@ where let mut inventory = item_state.inventory(&character_id).await?; inventory.add_meseta_no_overflow(amount)?; transaction.gateway().set_character_meseta(&character_id, inventory.meseta).await?; + item_state.set_inventory(inventory).await; Ok(((item_state, transaction), ())) }) diff --git a/tests/test_bank.rs b/tests/test_bank.rs index 2034070..e2c200b 100644 --- a/tests/test_bank.rs +++ b/tests/test_bank.rs @@ -1579,3 +1579,57 @@ async fn test_withdraw_meseta_inventory_is_maxed() { assert!(c1_meseta.0 == 999999); assert!(c1_bank_meseta.0 == 300); } + + + +#[async_std::test] +async fn test_withdraw_meseta_and_buy_a_few_monomates_with_it() { + let mut entity_gateway = InMemoryGateway::default(); + + let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await; + entity_gateway.set_character_meseta(&char1.id, item::Meseta(100)).await.unwrap(); + entity_gateway.set_bank_meseta(&char1.id, &item::BankName("".into()), item::Meseta(300)).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: 0xFFFFFFFF, + action: 1, + item_amount: 0, + meseta_amount: 60, + unknown: 0, + })))).await.unwrap(); + + ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::ShopRequest(ShopRequest { + client: 255, + target: 255, + shop_type: 0, + })))).await.unwrap(); + ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BuyItem(BuyItem { + client: 255, + target: 255, + item_id: 0x10000, + shop_type: 0, + shop_index: 0, + amount: 3, + unknown1: 0, + })))).await.unwrap(); + + //let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap(); + //let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap(); + //assert!(c1_meseta.0 == 23); + //assert!(c1_bank_meseta.0 == 277); +}