|
|
@ -212,6 +212,7 @@ async fn test_deposit_individual_item() { |
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
|
|
|
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
|
|
|
|
|
|
|
|
entity_gateway.create_item(
|
|
|
|
item::NewItemEntity {
|
|
|
@ -250,8 +251,11 @@ async fn test_deposit_individual_item() { |
|
|
|
|
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a").await;
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
join_room(&mut ship, ClientId(2), 0).await;
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
@ -270,7 +274,7 @@ async fn test_deposit_individual_item() { |
|
|
|
})))).await.unwrap().collect::<Vec<_>>();
|
|
|
|
|
|
|
|
assert!(packets.len() == 1);
|
|
|
|
assert!(matches!(&packets[0], (_, SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
|
|
|
|
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
|
|
|
|
if player_no_longer_has_item.item_id == 0x10001
|
|
|
|
&& player_no_longer_has_item.amount == 0
|
|
|
|
));
|
|
|
@ -294,6 +298,7 @@ async fn test_deposit_stacked_item() { |
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
|
|
|
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
|
|
|
|
|
|
|
|
for _ in 0..3 {
|
|
|
|
entity_gateway.create_item(
|
|
|
@ -313,8 +318,11 @@ async fn test_deposit_stacked_item() { |
|
|
|
|
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a").await;
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
join_room(&mut ship, ClientId(2), 0).await;
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
@ -333,7 +341,7 @@ async fn test_deposit_stacked_item() { |
|
|
|
})))).await.unwrap().collect::<Vec<_>>();
|
|
|
|
|
|
|
|
assert!(packets.len() == 1);
|
|
|
|
assert!(matches!(&packets[0], (_, SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
|
|
|
|
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
|
|
|
|
if player_no_longer_has_item.item_id == 0x10000
|
|
|
|
&& player_no_longer_has_item.amount == 3
|
|
|
|
));
|
|
|
@ -357,6 +365,7 @@ async fn test_deposit_partial_stacked_item() { |
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
|
|
|
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
|
|
|
|
|
|
|
|
for _ in 0..3 {
|
|
|
|
entity_gateway.create_item(
|
|
|
@ -376,8 +385,11 @@ async fn test_deposit_partial_stacked_item() { |
|
|
|
|
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a").await;
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
join_room(&mut ship, ClientId(2), 0).await;
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
@ -396,7 +408,7 @@ async fn test_deposit_partial_stacked_item() { |
|
|
|
})))).await.unwrap().collect::<Vec<_>>();
|
|
|
|
|
|
|
|
assert!(packets.len() == 1);
|
|
|
|
assert!(matches!(&packets[0], (_, SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
|
|
|
|
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
|
|
|
|
if player_no_longer_has_item.item_id == 0x10000
|
|
|
|
&& player_no_longer_has_item.amount == 2
|
|
|
|
));
|
|
|
@ -433,6 +445,7 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() { |
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
|
|
|
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
|
|
|
|
|
|
|
|
for _ in 0..2 {
|
|
|
|
entity_gateway.create_item(
|
|
|
@ -465,8 +478,11 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() { |
|
|
|
|
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a").await;
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
join_room(&mut ship, ClientId(2), 0).await;
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
@ -485,7 +501,7 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() { |
|
|
|
})))).await.unwrap().collect::<Vec<_>>();
|
|
|
|
|
|
|
|
assert!(packets.len() == 1);
|
|
|
|
assert!(matches!(&packets[0], (_, SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
|
|
|
|
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
|
|
|
|
if player_no_longer_has_item.item_id == 0x10000
|
|
|
|
&& player_no_longer_has_item.amount == 2
|
|
|
|
));
|
|
|
@ -906,7 +922,6 @@ async fn test_deposit_meseta() { |
|
|
|
|
|
|
|
let characters = entity_gateway.get_characters_by_user(&user1).await;
|
|
|
|
let char = characters[0].as_ref().unwrap();
|
|
|
|
println!("meseta {}", char.meseta);
|
|
|
|
assert!(char.meseta == 277);
|
|
|
|
assert!(char.bank_meseta == 23);
|
|
|
|
}
|
|
|
@ -943,7 +958,6 @@ async fn test_deposit_too_much_meseta() { |
|
|
|
|
|
|
|
let characters = entity_gateway.get_characters_by_user(&user1).await;
|
|
|
|
let char = characters[0].as_ref().unwrap();
|
|
|
|
println!("meseta {}", char.meseta);
|
|
|
|
assert!(char.meseta == 300);
|
|
|
|
assert!(char.bank_meseta == 999980);
|
|
|
|
}
|
|
|
|