|
@ -15,7 +15,7 @@ use libpso::packet::login::{Login, Session}; |
|
|
use libpso::{utf8_to_array, utf8_to_utf16_array};
|
|
|
use libpso::{utf8_to_array, utf8_to_utf16_array};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn new_user_character<EG: EntityGateway>(entity_gateway: &mut EG, username: &str, password: &str) -> (UserAccountEntity, CharacterEntity) {
|
|
|
|
|
|
|
|
|
pub async fn new_user_character<EG: EntityGateway>(entity_gateway: &mut EG, username: &str, password: &str) -> (UserAccountEntity, CharacterEntity) {
|
|
|
let new_user = NewUserAccountEntity {
|
|
|
let new_user = NewUserAccountEntity {
|
|
|
username: username.into(),
|
|
|
username: username.into(),
|
|
|
password: bcrypt::hash(password, 5).unwrap(),
|
|
|
password: bcrypt::hash(password, 5).unwrap(),
|
|
@ -27,16 +27,16 @@ pub fn new_user_character<EG: EntityGateway>(entity_gateway: &mut EG, username: |
|
|
flags: 0,
|
|
|
flags: 0,
|
|
|
};
|
|
|
};
|
|
|
|
|
|
|
|
|
let user = entity_gateway.create_user(new_user).unwrap();
|
|
|
|
|
|
|
|
|
let user = entity_gateway.create_user(new_user).await.unwrap();
|
|
|
let new_settings = NewUserSettingsEntity::new(user.id);
|
|
|
let new_settings = NewUserSettingsEntity::new(user.id);
|
|
|
let _settings = entity_gateway.create_user_settings(new_settings).unwrap();
|
|
|
|
|
|
|
|
|
let _settings = entity_gateway.create_user_settings(new_settings).await.unwrap();
|
|
|
let new_character = NewCharacterEntity::new(user.id);
|
|
|
let new_character = NewCharacterEntity::new(user.id);
|
|
|
let character = entity_gateway.create_character(new_character).unwrap();
|
|
|
|
|
|
|
|
|
let character = entity_gateway.create_character(new_character).await.unwrap();
|
|
|
|
|
|
|
|
|
(user, character)
|
|
|
(user, character)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub fn log_in_char<EG: EntityGateway>(ship: &mut ShipServerState<EG>, id: ClientId, username: &str, password: &str) {
|
|
|
|
|
|
|
|
|
pub async fn log_in_char<EG: EntityGateway>(ship: &mut ShipServerState<EG>, id: ClientId, username: &str, password: &str) {
|
|
|
let username = username.to_string();
|
|
|
let username = username.to_string();
|
|
|
let password = password.to_string();
|
|
|
let password = password.to_string();
|
|
|
ship.handle(id, &RecvShipPacket::Login(Login {
|
|
|
ship.handle(id, &RecvShipPacket::Login(Login {
|
|
@ -51,16 +51,16 @@ pub fn log_in_char<EG: EntityGateway>(ship: &mut ShipServerState<EG>, id: Client |
|
|
unknown3: [0; 40],
|
|
|
unknown3: [0; 40],
|
|
|
hwinfo: [0; 8],
|
|
|
hwinfo: [0; 8],
|
|
|
session: Session::new(),
|
|
|
session: Session::new(),
|
|
|
})).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})).await.unwrap().for_each(drop);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub fn join_lobby<EG: EntityGateway>(ship: &mut ShipServerState<EG>, id: ClientId) {
|
|
|
|
|
|
|
|
|
pub async fn join_lobby<EG: EntityGateway>(ship: &mut ShipServerState<EG>, id: ClientId) {
|
|
|
ship.handle(id, &RecvShipPacket::CharData(CharData {
|
|
|
ship.handle(id, &RecvShipPacket::CharData(CharData {
|
|
|
_unknown: [0; 0x828]
|
|
|
_unknown: [0; 0x828]
|
|
|
})).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})).await.unwrap().for_each(drop);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub fn create_room<EG: EntityGateway>(ship: &mut ShipServerState<EG>, id: ClientId, name: &str, password: &str) {
|
|
|
|
|
|
|
|
|
pub async fn create_room<EG: EntityGateway>(ship: &mut ShipServerState<EG>, id: ClientId, name: &str, password: &str) {
|
|
|
ship.handle(id, &RecvShipPacket::CreateRoom(CreateRoom {
|
|
|
ship.handle(id, &RecvShipPacket::CreateRoom(CreateRoom {
|
|
|
unknown: [0; 2],
|
|
|
unknown: [0; 2],
|
|
|
name: utf8_to_utf16_array!(name, 16),
|
|
|
name: utf8_to_utf16_array!(name, 16),
|
|
@ -71,24 +71,24 @@ pub fn create_room<EG: EntityGateway>(ship: &mut ShipServerState<EG>, id: Client |
|
|
episode: 1,
|
|
|
episode: 1,
|
|
|
single_player: 0,
|
|
|
single_player: 0,
|
|
|
padding: [0; 3],
|
|
|
padding: [0; 3],
|
|
|
})).unwrap().for_each(drop);
|
|
|
|
|
|
ship.handle(id, &RecvShipPacket::DoneBursting(DoneBursting {})).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})).await.unwrap().for_each(drop);
|
|
|
|
|
|
ship.handle(id, &RecvShipPacket::DoneBursting(DoneBursting {})).await.unwrap().for_each(drop);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub fn join_room<EG: EntityGateway>(ship: &mut ShipServerState<EG>, id: ClientId, room_id: u32) {
|
|
|
|
|
|
|
|
|
pub async fn join_room<EG: EntityGateway>(ship: &mut ShipServerState<EG>, id: ClientId, room_id: u32) {
|
|
|
ship.handle(id, &RecvShipPacket::MenuSelect(MenuSelect {
|
|
|
ship.handle(id, &RecvShipPacket::MenuSelect(MenuSelect {
|
|
|
menu: ROOM_MENU_ID,
|
|
|
menu: ROOM_MENU_ID,
|
|
|
item: room_id,
|
|
|
item: room_id,
|
|
|
})).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})).await.unwrap().for_each(drop);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_pick_up_item_stack_of_items_already_in_inventory() {
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
|
|
async fn test_pick_up_item_stack_of_items_already_in_inventory() {
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a");
|
|
|
|
|
|
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a");
|
|
|
|
|
|
|
|
|
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(
|
|
|
entity_gateway.create_item(
|
|
|
item::NewItemEntity {
|
|
|
item::NewItemEntity {
|
|
@ -102,7 +102,7 @@ fn test_pick_up_item_stack_of_items_already_in_inventory() { |
|
|
slot: 0,
|
|
|
slot: 0,
|
|
|
equipped: false,
|
|
|
equipped: false,
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}).await;
|
|
|
|
|
|
|
|
|
for (slot, tool) in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter().enumerate() {
|
|
|
for (slot, tool) in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter().enumerate() {
|
|
|
for _ in 0..5 {
|
|
|
for _ in 0..5 {
|
|
@ -118,19 +118,19 @@ fn test_pick_up_item_stack_of_items_already_in_inventory() { |
|
|
slot: slot,
|
|
|
slot: slot,
|
|
|
equipped: false,
|
|
|
equipped: false,
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}).await;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a");
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a");
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2));
|
|
|
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "");
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0);
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0).await;
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -141,7 +141,7 @@ fn test_pick_up_item_stack_of_items_already_in_inventory() { |
|
|
x: 0.0,
|
|
|
x: 0.0,
|
|
|
y: 0.0,
|
|
|
y: 0.0,
|
|
|
z: 0.0,
|
|
|
z: 0.0,
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -149,7 +149,7 @@ fn test_pick_up_item_stack_of_items_already_in_inventory() { |
|
|
item_id: 0x210000,
|
|
|
item_id: 0x210000,
|
|
|
area: 0,
|
|
|
area: 0,
|
|
|
unknown: [0; 3]
|
|
|
unknown: [0; 3]
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
let p1_inventory = ship.item_manager.get_character_inventory(&char1).unwrap();
|
|
|
let p1_inventory = ship.item_manager.get_character_inventory(&char1).unwrap();
|
|
|
assert!(p1_inventory.count() == 1);
|
|
|
assert!(p1_inventory.count() == 1);
|
|
@ -158,12 +158,12 @@ fn test_pick_up_item_stack_of_items_already_in_inventory() { |
|
|
assert!(inventory_item.item == HeldItemType::Stacked(item::tool::Tool {tool: item::tool::ToolType::Monomate}, 6));
|
|
|
assert!(inventory_item.item == HeldItemType::Stacked(item::tool::Tool {tool: item::tool::ToolType::Monomate}, 6));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_pick_up_item_stack_of_items_not_already_held() {
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
|
|
async fn test_pick_up_item_stack_of_items_not_already_held() {
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a");
|
|
|
|
|
|
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a");
|
|
|
|
|
|
|
|
|
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(
|
|
|
entity_gateway.create_item(
|
|
|
item::NewItemEntity {
|
|
|
item::NewItemEntity {
|
|
@ -177,17 +177,17 @@ fn test_pick_up_item_stack_of_items_not_already_held() { |
|
|
slot: 0,
|
|
|
slot: 0,
|
|
|
equipped: false,
|
|
|
equipped: false,
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}).await;
|
|
|
|
|
|
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a");
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a");
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2));
|
|
|
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "");
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0);
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0).await;
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -198,7 +198,7 @@ fn test_pick_up_item_stack_of_items_not_already_held() { |
|
|
x: 0.0,
|
|
|
x: 0.0,
|
|
|
y: 0.0,
|
|
|
y: 0.0,
|
|
|
z: 0.0,
|
|
|
z: 0.0,
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -206,7 +206,7 @@ fn test_pick_up_item_stack_of_items_not_already_held() { |
|
|
item_id: 0x210000,
|
|
|
item_id: 0x210000,
|
|
|
area: 0,
|
|
|
area: 0,
|
|
|
unknown: [0; 3]
|
|
|
unknown: [0; 3]
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
let p1_inventory = ship.item_manager.get_character_inventory(&char1).unwrap();
|
|
|
let p1_inventory = ship.item_manager.get_character_inventory(&char1).unwrap();
|
|
|
assert!(p1_inventory.count() == 1);
|
|
|
assert!(p1_inventory.count() == 1);
|
|
@ -215,12 +215,12 @@ fn test_pick_up_item_stack_of_items_not_already_held() { |
|
|
assert!(inventory_item.item == HeldItemType::Stacked(item::tool::Tool {tool: item::tool::ToolType::Monomate}, 1));
|
|
|
assert!(inventory_item.item == HeldItemType::Stacked(item::tool::Tool {tool: item::tool::ToolType::Monomate}, 1));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_pick_up_meseta_when_inventory_full() {
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
|
|
async fn test_pick_up_meseta_when_inventory_full() {
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a");
|
|
|
|
|
|
let (_user2, mut char2) = new_user_character(&mut entity_gateway, "a2", "a");
|
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
|
|
|
|
|
let (_user2, mut char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
|
|
|
|
|
|
|
|
|
for slot in 0..30 {
|
|
|
for slot in 0..30 {
|
|
|
entity_gateway.create_item(
|
|
|
entity_gateway.create_item(
|
|
@ -239,21 +239,21 @@ fn test_pick_up_meseta_when_inventory_full() { |
|
|
slot: slot,
|
|
|
slot: slot,
|
|
|
equipped: false,
|
|
|
equipped: false,
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}).await;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
char2.meseta = 300;
|
|
|
char2.meseta = 300;
|
|
|
entity_gateway.save_character(&char2);
|
|
|
|
|
|
|
|
|
entity_gateway.save_character(&char2).await;
|
|
|
|
|
|
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a");
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a");
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2));
|
|
|
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "");
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0);
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0).await;
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::DropCoordinates(DropCoordinates {
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::DropCoordinates(DropCoordinates {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -262,14 +262,14 @@ fn test_pick_up_meseta_when_inventory_full() { |
|
|
map_area: 0,
|
|
|
map_area: 0,
|
|
|
x: 0.0,
|
|
|
x: 0.0,
|
|
|
z: 0.0,
|
|
|
z: 0.0,
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerSplitItemStack(PlayerSplitItemStack {
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerSplitItemStack(PlayerSplitItemStack {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
|
target: 0,
|
|
|
target: 0,
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
amount: 23,
|
|
|
amount: 23,
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -277,7 +277,7 @@ fn test_pick_up_meseta_when_inventory_full() { |
|
|
item_id: 0xF0000001,
|
|
|
item_id: 0xF0000001,
|
|
|
area: 0,
|
|
|
area: 0,
|
|
|
unknown: [0; 3]
|
|
|
unknown: [0; 3]
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
let p1_inventory = ship.item_manager.get_character_inventory(&char1).unwrap();
|
|
|
let p1_inventory = ship.item_manager.get_character_inventory(&char1).unwrap();
|
|
|
assert!(p1_inventory.count() == 30);
|
|
|
assert!(p1_inventory.count() == 30);
|
|
@ -288,12 +288,12 @@ fn test_pick_up_meseta_when_inventory_full() { |
|
|
assert!(c2.character.meseta == 277);
|
|
|
assert!(c2.character.meseta == 277);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() {
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
|
|
async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() {
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a");
|
|
|
|
|
|
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a");
|
|
|
|
|
|
|
|
|
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 slot in 0..29 {
|
|
|
for slot in 0..29 {
|
|
|
entity_gateway.create_item(
|
|
|
entity_gateway.create_item(
|
|
@ -312,7 +312,7 @@ fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() { |
|
|
slot: slot,
|
|
|
slot: slot,
|
|
|
equipped: false,
|
|
|
equipped: false,
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}).await;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
entity_gateway.create_item(
|
|
|
entity_gateway.create_item(
|
|
@ -327,7 +327,7 @@ fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() { |
|
|
slot: 29,
|
|
|
slot: 29,
|
|
|
equipped: false,
|
|
|
equipped: false,
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}).await;
|
|
|
entity_gateway.create_item(
|
|
|
entity_gateway.create_item(
|
|
|
item::NewItemEntity {
|
|
|
item::NewItemEntity {
|
|
|
item: item::ItemDetail::Tool(
|
|
|
item: item::ItemDetail::Tool(
|
|
@ -340,17 +340,17 @@ fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() { |
|
|
slot: 0,
|
|
|
slot: 0,
|
|
|
equipped: false,
|
|
|
equipped: false,
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}).await;
|
|
|
|
|
|
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a");
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a");
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2));
|
|
|
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "");
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0);
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0).await;
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -361,7 +361,7 @@ fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() { |
|
|
x: 0.0,
|
|
|
x: 0.0,
|
|
|
y: 0.0,
|
|
|
y: 0.0,
|
|
|
z: 0.0,
|
|
|
z: 0.0,
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -369,22 +369,21 @@ fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() { |
|
|
item_id: 0x210000,
|
|
|
item_id: 0x210000,
|
|
|
area: 0,
|
|
|
area: 0,
|
|
|
unknown: [0; 3]
|
|
|
unknown: [0; 3]
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
let p1_inventory = ship.item_manager.get_character_inventory(&char1).unwrap();
|
|
|
let p1_inventory = ship.item_manager.get_character_inventory(&char1).unwrap();
|
|
|
assert!(p1_inventory.count() == 30);
|
|
|
assert!(p1_inventory.count() == 30);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let monomates = p1_inventory.slot(29).unwrap();
|
|
|
let monomates = p1_inventory.slot(29).unwrap();
|
|
|
assert!(monomates.item == HeldItemType::Stacked(item::tool::Tool {tool: item::tool::ToolType::Monomate}, 2));
|
|
|
assert!(monomates.item == HeldItemType::Stacked(item::tool::Tool {tool: item::tool::ToolType::Monomate}, 2));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_can_not_pick_up_item_when_inventory_full() {
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
|
|
async fn test_can_not_pick_up_item_when_inventory_full() {
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a");
|
|
|
|
|
|
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a");
|
|
|
|
|
|
|
|
|
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 slot in 0..30 {
|
|
|
for slot in 0..30 {
|
|
|
entity_gateway.create_item(
|
|
|
entity_gateway.create_item(
|
|
@ -403,7 +402,7 @@ fn test_can_not_pick_up_item_when_inventory_full() { |
|
|
slot: slot,
|
|
|
slot: slot,
|
|
|
equipped: false,
|
|
|
equipped: false,
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}).await;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
entity_gateway.create_item(
|
|
|
entity_gateway.create_item(
|
|
@ -422,18 +421,17 @@ fn test_can_not_pick_up_item_when_inventory_full() { |
|
|
slot: 0,
|
|
|
slot: 0,
|
|
|
equipped: false,
|
|
|
equipped: false,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
}).await;
|
|
|
|
|
|
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a");
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a");
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2));
|
|
|
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "");
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0);
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0).await;
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -444,7 +442,7 @@ fn test_can_not_pick_up_item_when_inventory_full() { |
|
|
x: 0.0,
|
|
|
x: 0.0,
|
|
|
y: 0.0,
|
|
|
y: 0.0,
|
|
|
z: 0.0,
|
|
|
z: 0.0,
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -452,7 +450,7 @@ fn test_can_not_pick_up_item_when_inventory_full() { |
|
|
item_id: 0x210000,
|
|
|
item_id: 0x210000,
|
|
|
area: 0,
|
|
|
area: 0,
|
|
|
unknown: [0; 3]
|
|
|
unknown: [0; 3]
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
let p1_inventory = ship.item_manager.get_character_inventory(&char1).unwrap();
|
|
|
let p1_inventory = ship.item_manager.get_character_inventory(&char1).unwrap();
|
|
|
assert!(p1_inventory.count() == 30);
|
|
|
assert!(p1_inventory.count() == 30);
|
|
@ -460,21 +458,21 @@ fn test_can_not_pick_up_item_when_inventory_full() { |
|
|
assert!(floor_item.item_id == ClientItemId(0x210000));
|
|
|
assert!(floor_item.item_id == ClientItemId(0x210000));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_can_not_drop_more_meseta_than_is_held() {
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
|
|
async fn test_can_not_drop_more_meseta_than_is_held() {
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
|
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a");
|
|
|
|
|
|
|
|
|
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
|
|
|
|
|
|
|
|
char1.meseta = 300;
|
|
|
char1.meseta = 300;
|
|
|
entity_gateway.save_character(&char1);
|
|
|
|
|
|
|
|
|
entity_gateway.save_character(&char1).await;
|
|
|
|
|
|
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a");
|
|
|
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
|
|
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(1));
|
|
|
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "");
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::DropCoordinates(DropCoordinates {
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::DropCoordinates(DropCoordinates {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -483,14 +481,14 @@ fn test_can_not_drop_more_meseta_than_is_held() { |
|
|
map_area: 0,
|
|
|
map_area: 0,
|
|
|
x: 0.0,
|
|
|
x: 0.0,
|
|
|
z: 0.0,
|
|
|
z: 0.0,
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
let split_attempt = ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerSplitItemStack(PlayerSplitItemStack {
|
|
|
let split_attempt = ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerSplitItemStack(PlayerSplitItemStack {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
|
target: 0,
|
|
|
target: 0,
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
amount: 301,
|
|
|
amount: 301,
|
|
|
}))));
|
|
|
|
|
|
|
|
|
})))).await;
|
|
|
assert!(split_attempt.is_err());
|
|
|
assert!(split_attempt.is_err());
|
|
|
|
|
|
|
|
|
let c1 = ship.clients.get(&ClientId(1)).unwrap();
|
|
|
let c1 = ship.clients.get(&ClientId(1)).unwrap();
|
|
@ -498,12 +496,12 @@ fn test_can_not_drop_more_meseta_than_is_held() { |
|
|
assert!(ship.item_manager.get_floor_item_by_id(&char1, ClientItemId(0xF0000001)).is_err())
|
|
|
assert!(ship.item_manager.get_floor_item_by_id(&char1, ClientItemId(0xF0000001)).is_err())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_pick_up_stack_that_would_exceed_stack_limit() {
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
|
|
async fn test_pick_up_stack_that_would_exceed_stack_limit() {
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a");
|
|
|
|
|
|
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a");
|
|
|
|
|
|
|
|
|
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..6 {
|
|
|
for _ in 0..6 {
|
|
|
entity_gateway.create_item(
|
|
|
entity_gateway.create_item(
|
|
@ -518,7 +516,7 @@ fn test_pick_up_stack_that_would_exceed_stack_limit() { |
|
|
slot: 0,
|
|
|
slot: 0,
|
|
|
equipped: false,
|
|
|
equipped: false,
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}).await;
|
|
|
}
|
|
|
}
|
|
|
for _ in 0..6 {
|
|
|
for _ in 0..6 {
|
|
|
entity_gateway.create_item(
|
|
|
entity_gateway.create_item(
|
|
@ -533,18 +531,18 @@ fn test_pick_up_stack_that_would_exceed_stack_limit() { |
|
|
slot: 0,
|
|
|
slot: 0,
|
|
|
equipped: false,
|
|
|
equipped: false,
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}).await;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a");
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a");
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2));
|
|
|
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "");
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0);
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0).await;
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -555,7 +553,7 @@ fn test_pick_up_stack_that_would_exceed_stack_limit() { |
|
|
x: 0.0,
|
|
|
x: 0.0,
|
|
|
y: 0.0,
|
|
|
y: 0.0,
|
|
|
z: 0.0,
|
|
|
z: 0.0,
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -563,7 +561,7 @@ fn test_pick_up_stack_that_would_exceed_stack_limit() { |
|
|
item_id: 0x210000,
|
|
|
item_id: 0x210000,
|
|
|
area: 0,
|
|
|
area: 0,
|
|
|
unknown: [0; 3]
|
|
|
unknown: [0; 3]
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
let p1_inventory = ship.item_manager.get_character_inventory(&char1).unwrap();
|
|
|
let p1_inventory = ship.item_manager.get_character_inventory(&char1).unwrap();
|
|
|
let monomates = p1_inventory.slot(0).unwrap();
|
|
|
let monomates = p1_inventory.slot(0).unwrap();
|
|
@ -572,27 +570,27 @@ fn test_pick_up_stack_that_would_exceed_stack_limit() { |
|
|
assert!(floor_monomates.item == FloorItemType::Stacked(item::tool::Tool {tool: item::tool::ToolType::Monomate}, 6));
|
|
|
assert!(floor_monomates.item == FloorItemType::Stacked(item::tool::Tool {tool: item::tool::ToolType::Monomate}, 6));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_can_not_pick_up_meseta_when_full() {
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
|
|
async fn test_can_not_pick_up_meseta_when_full() {
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
|
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a");
|
|
|
|
|
|
let (_user2, mut char2) = new_user_character(&mut entity_gateway, "a2", "a");
|
|
|
|
|
|
|
|
|
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.meseta = 999999;
|
|
|
char1.meseta = 999999;
|
|
|
entity_gateway.save_character(&char1);
|
|
|
|
|
|
|
|
|
entity_gateway.save_character(&char1).await;
|
|
|
char2.meseta = 300;
|
|
|
char2.meseta = 300;
|
|
|
entity_gateway.save_character(&char2);
|
|
|
|
|
|
|
|
|
entity_gateway.save_character(&char2).await;
|
|
|
|
|
|
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a");
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a");
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2));
|
|
|
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "");
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0);
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0).await;
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::DropCoordinates(DropCoordinates {
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::DropCoordinates(DropCoordinates {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -601,14 +599,14 @@ fn test_can_not_pick_up_meseta_when_full() { |
|
|
map_area: 0,
|
|
|
map_area: 0,
|
|
|
x: 0.0,
|
|
|
x: 0.0,
|
|
|
z: 0.0,
|
|
|
z: 0.0,
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerSplitItemStack(PlayerSplitItemStack {
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerSplitItemStack(PlayerSplitItemStack {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
|
target: 0,
|
|
|
target: 0,
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
amount: 23,
|
|
|
amount: 23,
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -616,7 +614,7 @@ fn test_can_not_pick_up_meseta_when_full() { |
|
|
item_id: 0xF0000001,
|
|
|
item_id: 0xF0000001,
|
|
|
area: 0,
|
|
|
area: 0,
|
|
|
unknown: [0; 3]
|
|
|
unknown: [0; 3]
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
let c1 = ship.clients.get(&ClientId(1)).unwrap();
|
|
|
let c1 = ship.clients.get(&ClientId(1)).unwrap();
|
|
|
let c2 = ship.clients.get(&ClientId(2)).unwrap();
|
|
|
let c2 = ship.clients.get(&ClientId(2)).unwrap();
|
|
@ -627,27 +625,27 @@ fn test_can_not_pick_up_meseta_when_full() { |
|
|
assert!(floor_meseta.item == FloorItemType::Meseta(item::Meseta(23)));
|
|
|
assert!(floor_meseta.item == FloorItemType::Meseta(item::Meseta(23)));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_meseta_caps_at_999999_when_trying_to_pick_up_more() {
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
|
|
async fn test_meseta_caps_at_999999_when_trying_to_pick_up_more() {
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
|
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a");
|
|
|
|
|
|
let (_user2, mut char2) = new_user_character(&mut entity_gateway, "a2", "a");
|
|
|
|
|
|
|
|
|
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.meseta = 999998;
|
|
|
char1.meseta = 999998;
|
|
|
entity_gateway.save_character(&char1);
|
|
|
|
|
|
|
|
|
entity_gateway.save_character(&char1).await;
|
|
|
char2.meseta = 300;
|
|
|
char2.meseta = 300;
|
|
|
entity_gateway.save_character(&char2);
|
|
|
|
|
|
|
|
|
entity_gateway.save_character(&char2).await;
|
|
|
|
|
|
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
let mut ship = ShipServerState::new(entity_gateway.clone());
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a");
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a");
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2));
|
|
|
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "");
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0);
|
|
|
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
join_room(&mut ship, ClientId(2), 0).await;
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::DropCoordinates(DropCoordinates {
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::DropCoordinates(DropCoordinates {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -656,14 +654,14 @@ fn test_meseta_caps_at_999999_when_trying_to_pick_up_more() { |
|
|
map_area: 0,
|
|
|
map_area: 0,
|
|
|
x: 0.0,
|
|
|
x: 0.0,
|
|
|
z: 0.0,
|
|
|
z: 0.0,
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerSplitItemStack(PlayerSplitItemStack {
|
|
|
ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerSplitItemStack(PlayerSplitItemStack {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
|
target: 0,
|
|
|
target: 0,
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
amount: 23,
|
|
|
amount: 23,
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|
|
client: 0,
|
|
|
client: 0,
|
|
@ -671,7 +669,7 @@ fn test_meseta_caps_at_999999_when_trying_to_pick_up_more() { |
|
|
item_id: 0xF0000001,
|
|
|
item_id: 0xF0000001,
|
|
|
area: 0,
|
|
|
area: 0,
|
|
|
unknown: [0; 3]
|
|
|
unknown: [0; 3]
|
|
|
})))).unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
|
let c1 = ship.clients.get(&ClientId(1)).unwrap();
|
|
|
let c1 = ship.clients.get(&ClientId(1)).unwrap();
|
|
|
let c2 = ship.clients.get(&ClientId(2)).unwrap();
|
|
|
let c2 = ship.clients.get(&ClientId(2)).unwrap();
|
|
|