add another item pickup test
This commit is contained in:
parent
7a5e9c366d
commit
280b8ff6dd
@ -679,3 +679,71 @@ async fn test_meseta_caps_at_999999_when_trying_to_pick_up_more() {
|
|||||||
let floor_meseta = ship.item_manager.get_floor_item_by_id(&char1, ClientItemId(0xF0000001));
|
let floor_meseta = ship.item_manager.get_floor_item_by_id(&char1, ClientItemId(0xF0000001));
|
||||||
assert!(floor_meseta.is_err());
|
assert!(floor_meseta.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_std::test]
|
||||||
|
async fn test_player_drops_partial_stack_and_other_player_picks_it_up() {
|
||||||
|
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..5 {
|
||||||
|
entity_gateway.create_item(
|
||||||
|
item::NewItemEntity {
|
||||||
|
item: item::ItemDetail::Tool(
|
||||||
|
item::tool::Tool {
|
||||||
|
tool: item::tool::ToolType::Monomate,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
location: item::ItemLocation::Inventory {
|
||||||
|
character_id: char1.id,
|
||||||
|
slot: 0,
|
||||||
|
equipped: false,
|
||||||
|
}
|
||||||
|
}).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
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::Message(Message::new(GameMessage::DropCoordinates(DropCoordinates {
|
||||||
|
client: 0,
|
||||||
|
target: 0,
|
||||||
|
item_id: 0x10000,
|
||||||
|
map_area: 0,
|
||||||
|
x: 0.0,
|
||||||
|
z: 0.0,
|
||||||
|
})))).await.unwrap().for_each(drop);
|
||||||
|
|
||||||
|
ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerSplitItemStack(PlayerSplitItemStack {
|
||||||
|
client: 0,
|
||||||
|
target: 0,
|
||||||
|
item_id: 0x10000,
|
||||||
|
amount: 2,
|
||||||
|
})))).await.unwrap().for_each(drop);
|
||||||
|
|
||||||
|
ship.handle(ClientId(2), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
||||||
|
client: 0,
|
||||||
|
target: 0,
|
||||||
|
item_id: 0xF0000001,
|
||||||
|
area: 0,
|
||||||
|
unknown: [0; 3]
|
||||||
|
})))).await.unwrap().for_each(drop);
|
||||||
|
|
||||||
|
let p1_inventory = ship.item_manager.get_character_inventory(&char1).unwrap();
|
||||||
|
assert!(p1_inventory.count() == 1);
|
||||||
|
let inventory_item = p1_inventory.slot(0).unwrap();
|
||||||
|
assert!(inventory_item.item == HeldItemType::Stacked(item::tool::Tool {tool: item::tool::ToolType::Monomate}, 3));
|
||||||
|
|
||||||
|
let p2_inventory = ship.item_manager.get_character_inventory(&char2).unwrap();
|
||||||
|
assert!(p2_inventory.count() == 1);
|
||||||
|
let inventory_item = p2_inventory.slot(0).unwrap();
|
||||||
|
assert!(inventory_item.item == HeldItemType::Stacked(item::tool::Tool {tool: item::tool::ToolType::Monomate}, 2));
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user