Browse Source

fix more dumb meseta things

pull/128/head
jake 2 years ago
parent
commit
77f69a9d23
  1. 1
      src/ship/items/actions.rs
  2. 54
      tests/test_bank.rs

1
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), ()))
})

54
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);
}
Loading…
Cancel
Save