|
|
@ -2,6 +2,7 @@ use elseware::common::serverstate::{ClientId, ServerState}; |
|
|
|
use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
|
|
|
|
use elseware::entity::item;
|
|
|
|
use elseware::ship::ship::{ShipServerState, RecvShipPacket, SendShipPacket};
|
|
|
|
use elseware::entity::character::{CharacterClass, SectionID};
|
|
|
|
|
|
|
|
use libpso::packet::ship::*;
|
|
|
|
use libpso::packet::messages::*;
|
|
|
@ -72,3 +73,68 @@ async fn test_mag_feed() { |
|
|
|
_ => panic!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
async fn test_mag_change_owner() {
|
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
|
|
|
let (_user2, mut char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
|
|
|
|
char1.char_class = CharacterClass::RAmarl;
|
|
|
|
char1.section_id = SectionID::Redria;
|
|
|
|
entity_gateway.save_character(&char1).await;
|
|
|
|
char2.char_class = CharacterClass::FOmarl;
|
|
|
|
char2.section_id = SectionID::Whitill;
|
|
|
|
entity_gateway.save_character(&char2).await;
|
|
|
|
|
|
|
|
entity_gateway.create_item(
|
|
|
|
item::NewItemEntity {
|
|
|
|
item: item::ItemDetail::Mag(
|
|
|
|
item::mag::Mag::baby_mag(0)
|
|
|
|
),
|
|
|
|
location: item::ItemLocation::Inventory {
|
|
|
|
character_id: char1.id,
|
|
|
|
slot: 0,
|
|
|
|
equipped: true,
|
|
|
|
}
|
|
|
|
}).await;
|
|
|
|
|
|
|
|
let mut ship = ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
|
.build();
|
|
|
|
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::PlayerDropItem(PlayerDropItem {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
unknown1: 0,
|
|
|
|
map_area: 0,
|
|
|
|
item_id: 0x10000,
|
|
|
|
x: 0.0,
|
|
|
|
y: 0.0,
|
|
|
|
z: 0.0,
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0x10000,
|
|
|
|
map_area: 0,
|
|
|
|
unknown: [0; 3]
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
let p2_items = entity_gateway.get_items_by_character(&char2).await;
|
|
|
|
let mag = p2_items.get(0).unwrap();
|
|
|
|
match &mag.item {
|
|
|
|
item::ItemDetail::Mag(mag) => {
|
|
|
|
assert!(mag.class == CharacterClass::FOmarl);
|
|
|
|
assert!(mag.id == SectionID::Whitill);
|
|
|
|
},
|
|
|
|
_ => panic!()
|
|
|
|
}
|
|
|
|
}
|