Browse Source

Merge pull request 'keyboard-controller-buttons' (#104) from godihatevcs into master

Reviewed-on: #104
set_char_exp
jake 3 years ago
parent
commit
70c89cd9ad
  1. 1118
      Cargo.lock
  2. 4
      src/bin/main.rs
  3. 88
      src/entity/character.rs
  4. 2
      src/entity/gateway/inmemory.rs
  5. 16
      src/entity/gateway/postgres/models.rs
  6. 12
      src/entity/gateway/postgres/postgres.rs
  7. 2
      src/lib.rs
  8. 6
      src/login/character.rs
  9. 21
      src/ship/character.rs
  10. 22
      src/ship/items/transaction.rs
  11. 4
      src/ship/packet/handler/lobby.rs
  12. 24
      src/ship/packet/handler/settings.rs
  13. 14
      src/ship/ship.rs
  14. 4
      tests/common.rs
  15. 78
      tests/test_bank.rs
  16. 73
      tests/test_character.rs
  17. 10
      tests/test_exp_gain.rs
  18. 6
      tests/test_item_actions.rs
  19. 48
      tests/test_item_pickup.rs
  20. 10
      tests/test_item_use.rs
  21. 10
      tests/test_mags.rs
  22. 12
      tests/test_rooms.rs
  23. 58
      tests/test_shops.rs
  24. 158
      tests/test_trade.rs

1118
Cargo.lock
File diff suppressed because it is too large
View File

4
src/bin/main.rs

@ -65,12 +65,12 @@ fn main() {
};
let fake_user = entity_gateway.create_user(fake_user).await.unwrap();
entity_gateway.create_user_settings(NewUserSettingsEntity::new(fake_user.id)).await.unwrap();
let mut character = NewCharacterEntity::new(fake_user.id);
let mut character = NewCharacterEntity::new(fake_user.id, 1);
character.name = format!("Test Char {}", i*2);
let character = entity_gateway.create_character(character).await.unwrap();
entity_gateway.set_character_meseta(&character.id, item::Meseta(999999)).await.unwrap();
entity_gateway.set_bank_meseta(&character.id, item::BankName("".into()), item::Meseta(999999)).await.unwrap();
let mut character = NewCharacterEntity::new(fake_user.id);
let mut character = NewCharacterEntity::new(fake_user.id, 1);
character.slot = 2;
character.name = "ItemRefactor".into();
character.exp = 80000000;

88
src/entity/character.rs

@ -2,8 +2,8 @@ use std::convert::{From, Into};
use std::collections::HashMap;
use serde::{Serialize, Deserialize};
use libpso::packet::ship::{UpdateConfig, WriteInfoboard};
use libpso::character::character::{DEFAULT_PALETTE_CONFIG, DEFAULT_TECH_MENU};
use libpso::packet::ship::{UpdateConfig, WriteInfoboard, KeyboardConfig, GamepadConfig};
use libpso::character::settings::{DEFAULT_PALETTE_CONFIG, DEFAULT_TECH_MENU, DEFAULT_KEYBOARD_CONFIG1, DEFAULT_KEYBOARD_CONFIG2, DEFAULT_KEYBOARD_CONFIG3, DEFAULT_KEYBOARD_CONFIG4, DEFAULT_GAMEPAD_CONFIG};
use crate::entity::item::tech::Technique;
use crate::entity::account::UserAccountId;
@ -264,6 +264,82 @@ pub struct CharacterMaterials {
pub tp: u32,
}
#[derive(Clone, Debug)]
pub struct CharacterKeyboardConfig {
pub keyboard_config: [u8; 0x16C],
}
impl Default for CharacterKeyboardConfig {
fn default() -> CharacterKeyboardConfig {
CharacterKeyboardConfig {
keyboard_config: DEFAULT_KEYBOARD_CONFIG1,
}
}
}
impl CharacterKeyboardConfig {
fn new(preset: usize) -> CharacterKeyboardConfig {
match preset {
1 => {
CharacterKeyboardConfig {
keyboard_config: DEFAULT_KEYBOARD_CONFIG1,
}
},
2 => {
CharacterKeyboardConfig {
keyboard_config: DEFAULT_KEYBOARD_CONFIG2,
}
},
3 => {
CharacterKeyboardConfig {
keyboard_config: DEFAULT_KEYBOARD_CONFIG3,
}
},
4 => {
CharacterKeyboardConfig {
keyboard_config: DEFAULT_KEYBOARD_CONFIG4,
}
},
_ => {
CharacterKeyboardConfig {
keyboard_config: DEFAULT_KEYBOARD_CONFIG1,
}
},
}
}
pub fn update(&mut self, new_config: &KeyboardConfig) {
self.keyboard_config = new_config.keyboard_config;
}
pub fn as_bytes(&self) -> [u8; 0x16C] {
self.keyboard_config
}
}
#[derive(Clone, Debug)]
pub struct CharacterGamepadConfig {
pub gamepad_config: [u8; 0x38],
}
impl Default for CharacterGamepadConfig {
fn default() -> CharacterGamepadConfig {
CharacterGamepadConfig {
gamepad_config: DEFAULT_GAMEPAD_CONFIG,
}
}
}
impl CharacterGamepadConfig {
pub fn update(&mut self, new_config: &GamepadConfig) {
self.gamepad_config = new_config.gamepad_config;
}
pub fn as_bytes(&self) -> [u8; 0x38] {
self.gamepad_config
}
}
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Default, derive_more::Display)]
pub struct CharacterEntityId(pub u32);
@ -287,10 +363,12 @@ pub struct NewCharacterEntity {
pub tech_menu: CharacterTechMenu,
pub option_flags: u32,
pub keyboard_config: CharacterKeyboardConfig,
pub gamepad_config: CharacterGamepadConfig,
}
impl NewCharacterEntity {
pub fn new(user: UserAccountId) -> NewCharacterEntity {
pub fn new(user: UserAccountId, keyboard_config_preset: usize,) -> NewCharacterEntity {
NewCharacterEntity {
user_id: user,
slot: 0,
@ -306,6 +384,8 @@ impl NewCharacterEntity {
materials: CharacterMaterials::default(),
tech_menu: CharacterTechMenu::default(),
option_flags: 0,
keyboard_config: CharacterKeyboardConfig::new(keyboard_config_preset),
gamepad_config: CharacterGamepadConfig::default(),
}
}
}
@ -331,4 +411,6 @@ pub struct CharacterEntity {
pub tech_menu: CharacterTechMenu,
pub option_flags: u32,
pub keyboard_config: CharacterKeyboardConfig,
pub gamepad_config: CharacterGamepadConfig,
}

2
src/entity/gateway/inmemory.rs

@ -202,6 +202,8 @@ impl EntityGateway for InMemoryGateway {
materials: character.materials,
tech_menu: character.tech_menu,
option_flags: character.option_flags,
keyboard_config: character.keyboard_config,
gamepad_config: character.gamepad_config,
};
characters.insert(new_character.id, new_character.clone());
Ok(new_character)

16
src/entity/gateway/postgres/models.rs

@ -49,8 +49,8 @@ pub struct PgUserSettings {
id: i32,
user_account: i32,
blocked_users: Vec<u8>, //[u32; 0x1E],
key_config: Vec<u8>, //[u8; 0x16C],
joystick_config: Vec<u8>, //[u8; 0x38],
keyboard_config: Vec<u8>, //[u8; 0x16C],
gamepad_config: Vec<u8>, //[u8; 0x38],
option_flags: i32,
shortcuts: Vec<u8>, //[u8; 0xA40],
symbol_chats: Vec<u8>, //[u8; 0x4E0],
@ -64,8 +64,8 @@ impl From<PgUserSettings> for UserSettingsEntity {
user_id: UserAccountId(other.user_account as u32),
settings: settings::UserSettings {
blocked_users: vec_to_array(other.blocked_users.chunks(4).map(|b| u32::from_le_bytes([b[0], b[1], b[2], b[3]])).collect()),
key_config: vec_to_array(other.key_config),
joystick_config: vec_to_array(other.joystick_config),
keyboard_config: vec_to_array(other.keyboard_config),
gamepad_config: vec_to_array(other.gamepad_config),
option_flags: other.option_flags as u32,
shortcuts: vec_to_array(other.shortcuts),
symbol_chats: vec_to_array(other.symbol_chats),
@ -217,6 +217,8 @@ pub struct PgCharacter {
tp: i16,
tech_menu: Vec<u8>,
keyboard_config: Vec<u8>,
gamepad_config: Vec<u8>,
}
impl From<PgCharacter> for CharacterEntity {
@ -266,6 +268,12 @@ impl From<PgCharacter> for CharacterEntity {
tech_menu: CharacterTechMenu {
tech_menu: vec_to_array(other.tech_menu)
},
keyboard_config: CharacterKeyboardConfig {
keyboard_config: vec_to_array(other.keyboard_config)
},
gamepad_config: CharacterGamepadConfig {
gamepad_config: vec_to_array(other.gamepad_config)
},
}
}
}

12
src/entity/gateway/postgres/postgres.rs

@ -144,12 +144,12 @@ impl EntityGateway for PostgresGateway {
}
async fn create_user_settings(&mut self, settings: NewUserSettingsEntity) -> Result<UserSettingsEntity, GatewayError> {
let new_settings = sqlx::query_as::<_, PgUserSettings>("insert into user_settings (user_account, blocked_users, key_config, joystick_config, option_flags, shortcuts, symbol_chats, team_name)
let new_settings = sqlx::query_as::<_, PgUserSettings>("insert into user_settings (user_account, blocked_users, keyboard_config, gamepad_config, option_flags, shortcuts, symbol_chats, team_name)
values ($1, $2, $3, $4, $5, $6, $7, $8) returning *;")
.bind(settings.user_id.0)
.bind(settings.settings.blocked_users.iter().copied().flat_map(|i| i.to_le_bytes().to_vec()).collect::<Vec<u8>>())
.bind(settings.settings.key_config.to_vec())
.bind(settings.settings.joystick_config.to_vec())
.bind(settings.settings.keyboard_config.to_vec())
.bind(settings.settings.gamepad_config.to_vec())
.bind(settings.settings.option_flags as i32)
.bind(settings.settings.shortcuts.to_vec())
.bind(settings.settings.symbol_chats.to_vec())
@ -166,10 +166,10 @@ impl EntityGateway for PostgresGateway {
}
async fn save_user_settings(&mut self, settings: &UserSettingsEntity) -> Result<(), GatewayError> {
sqlx::query("update user_settings set blocked_users=$1, key_config=$2, joystick_config=$3, option_flags=$4, shortcuts=$5, symbol_chats=$6, team_name=$7 where id=$8")
sqlx::query("update user_settings set blocked_users=$1, keyboard_config=$2, gamepad_config=$3, option_flags=$4, shortcuts=$5, symbol_chats=$6, team_name=$7 where id=$8")
.bind(settings.settings.blocked_users.iter().copied().flat_map(|i| i.to_le_bytes().to_vec()).collect::<Vec<u8>>())
.bind(&settings.settings.key_config.to_vec())
.bind(&settings.settings.joystick_config.to_vec())
.bind(&settings.settings.keyboard_config.to_vec())
.bind(&settings.settings.gamepad_config.to_vec())
.bind(&settings.settings.option_flags)
.bind(&settings.settings.shortcuts.to_vec())
.bind(&settings.settings.symbol_chats.to_vec())

2
src/lib.rs

@ -1,8 +1,6 @@
#![allow(incomplete_features)]
#![feature(maybe_uninit_extra)]
#![feature(inline_const)]
#![feature(drain_filter)]
#![feature(derive_default_enum)]
#![feature(try_blocks)]

6
src/login/character.rs

@ -385,8 +385,8 @@ impl<EG: EntityGateway> CharacterServerState<EG> {
}
};
let pkt = SendKeyAndTeamSettings::new(settings.settings.key_config,
settings.settings.joystick_config, 0, 0);
let pkt = SendKeyAndTeamSettings::new(settings.settings.keyboard_config,
settings.settings.gamepad_config, 0, 0);
let pkt = SendCharacterPacket::SendKeyAndTeamSettings(Box::new(pkt));
Ok(vec![pkt])
@ -712,7 +712,7 @@ impl<EG: EntityGateway> InterserverActor for CharacterServerState<EG> {
fn new_character_from_preview(user: &UserAccountEntity, preview: &CharacterPreview) -> NewCharacterEntity {
let mut character = NewCharacterEntity::new(user.id);
let mut character = NewCharacterEntity::new(user.id, 1); // it should not be possible for the client to specify the kbm config preset from the char create screen
character.slot = preview.slot;
character.name = String::from_utf16_lossy(&preview.character.name).trim_matches(char::from(0)).into();
character.section_id = preview.character.section_id.into();

21
src/ship/character.rs

@ -82,7 +82,6 @@ impl<'a> CharacterBytesBuilder<'a> {
}
}
#[derive(Default)]
pub struct FullCharacterBytesBuilder<'a> {
character: Option<&'a CharacterEntity>,
@ -91,8 +90,8 @@ pub struct FullCharacterBytesBuilder<'a> {
meseta: Option<Meseta>,
inventory: Option<&'a CharacterInventory>,
bank: Option<&'a CharacterBank>,
key_config: Option<&'a [u8; 0x16C]>,
joystick_config: Option<&'a [u8; 0x38]>,
keyboard_config: Option<&'a [u8; 0x16C]>,
gamepad_config: Option<&'a [u8; 0x38]>,
symbol_chat: Option<&'a [u8; 1248]>,
tech_menu: Option<&'a [u8; 40]>,
option_flags: Option<u32>,
@ -148,17 +147,17 @@ impl<'a> FullCharacterBytesBuilder<'a> {
}
#[must_use]
pub fn key_config(self, key_config: &'a [u8; 0x16C]) -> FullCharacterBytesBuilder<'a> {
pub fn keyboard_config(self, keyboard_config: &'a [u8; 0x16C]) -> FullCharacterBytesBuilder<'a> {
FullCharacterBytesBuilder {
key_config: Some(key_config),
keyboard_config: Some(keyboard_config),
..self
}
}
#[must_use]
pub fn joystick_config(self, joystick_config: &'a [u8; 0x38]) -> FullCharacterBytesBuilder<'a> {
pub fn gamepad_config(self, gamepad_config: &'a [u8; 0x38]) -> FullCharacterBytesBuilder<'a> {
FullCharacterBytesBuilder {
joystick_config: Some(joystick_config),
gamepad_config: Some(gamepad_config),
..self
}
}
@ -194,8 +193,8 @@ impl<'a> FullCharacterBytesBuilder<'a> {
let meseta = self.meseta.unwrap();
let inventory = self.inventory.unwrap();
let bank = self.bank.unwrap();
let key_config = self.key_config.unwrap();
let joystick_config = self.joystick_config.unwrap();
let keyboard_config = self.keyboard_config.unwrap();
let gamepad_config = self.gamepad_config.unwrap();
let symbol_chat = self.symbol_chat.unwrap();
let tech_menu = self.tech_menu.unwrap();
let option_flags = self.option_flags.unwrap();
@ -222,8 +221,8 @@ impl<'a> FullCharacterBytesBuilder<'a> {
..character::Inventory::default()
},
key_team_config: character::KeyTeamConfig {
key_config: *key_config,
joystick_config: *joystick_config,
keyboard_config: *keyboard_config,
gamepad_config: *gamepad_config,
..character::KeyTeamConfig::default()
},
info_board: character.info_board.as_bytes(),

22
src/ship/items/transaction.rs

@ -163,7 +163,7 @@ mod test {
item_manager.id_counter += self.value;
entity_gateway.create_character(NewCharacterEntity {
slot: self.value,
..NewCharacterEntity::new(UserAccountId(0))
..NewCharacterEntity::new(UserAccountId(0), 1) // TODO: handle different keyboard_config_presets
})
.await?;
Ok(())
@ -209,7 +209,7 @@ mod test {
#[derive(Default, Clone)]
struct DummyGateway {
d1_set: String,
_d1_set: String,
d2_inc: u32,
}
@ -224,10 +224,10 @@ mod test {
#[async_trait::async_trait]
impl<EG: EntityGateway> ItemAction<EG> for DummyAction1 {
async fn commit(&self, item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
async fn commit(&self, _item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
entity_gateway.create_character(NewCharacterEntity {
slot: 1,
..NewCharacterEntity::new(UserAccountId(0))
..NewCharacterEntity::new(UserAccountId(0), 1) // TODO: handle different keyboard_config_presets
})
.await?;
Ok(())
@ -236,10 +236,10 @@ mod test {
#[async_trait::async_trait]
impl<EG: EntityGateway> ItemAction<EG> for DummyAction2 {
async fn commit(&self, item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
async fn commit(&self, _item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
entity_gateway.create_character(NewCharacterEntity {
slot: 1,
..NewCharacterEntity::new(UserAccountId(0))
..NewCharacterEntity::new(UserAccountId(0), 1) // TODO: handle different keyboard_config_presets
})
.await?;
Ok(())
@ -279,7 +279,7 @@ mod test {
#[derive(Default, Clone)]
struct DummyGateway {
d1_set: String,
_d1_set: String,
d2_inc: u32,
}
@ -294,10 +294,10 @@ mod test {
#[async_trait::async_trait]
impl<EG: EntityGateway> ItemAction<EG> for DummyAction1 {
async fn commit(&self, item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
async fn commit(&self, _item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
entity_gateway.create_character(NewCharacterEntity {
slot: 1,
..NewCharacterEntity::new(UserAccountId(0))
..NewCharacterEntity::new(UserAccountId(0), 1) // TODO: handle different keyboard_config_presets
})
.await?;
Err(GatewayError::Error.into())
@ -306,10 +306,10 @@ mod test {
#[async_trait::async_trait]
impl<EG: EntityGateway> ItemAction<EG> for DummyAction2 {
async fn commit(&self, item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
async fn commit(&self, _item_manager: &mut ItemManager, entity_gateway: &mut EG) -> Result<(), TransactionCommitError> {
entity_gateway.create_character(NewCharacterEntity {
slot: 1,
..NewCharacterEntity::new(UserAccountId(0))
..NewCharacterEntity::new(UserAccountId(0), 1) // TODO: handle different keyboard_config_presets
})
.await?;
Ok(())

4
src/ship/packet/handler/lobby.rs

@ -32,8 +32,8 @@ pub fn block_selected(id: ClientId,
.meseta(*meseta)
.inventory(inventory)
.bank(bank)
.key_config(&client.settings.settings.key_config)
.joystick_config(&client.settings.settings.joystick_config)
.keyboard_config(&client.character.keyboard_config.as_bytes())
.gamepad_config(&client.character.gamepad_config.as_bytes())
.symbol_chat(&client.settings.settings.symbol_chats)
.tech_menu(&client.character.tech_menu.as_bytes())
.option_flags(client.character.option_flags)

24
src/ship/packet/handler/settings.rs

@ -19,9 +19,31 @@ pub async fn save_options<EG: EntityGateway>(id: ClientId,
clients: &mut Clients,
entity_gateway: &mut EG)
-> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
// // TODO: don't unwrap?
// TODO: don't unwrap?
let client = clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id)).unwrap();
client.character.option_flags = save_options.options;
entity_gateway.save_character(&client.character).await.unwrap();
Box::new(None.into_iter())
}
pub async fn keyboard_config<EG: EntityGateway>(id: ClientId,
keyboard_config: &KeyboardConfig,
clients: &mut Clients,
entity_gateway: &mut EG)
-> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
let client = clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id)).unwrap();
client.character.keyboard_config.update(keyboard_config);
entity_gateway.save_character(&client.character).await.unwrap();
Box::new(None.into_iter())
}
pub async fn gamepad_config<EG: EntityGateway>(id: ClientId,
gamepad_config: &GamepadConfig,
clients: &mut Clients,
entity_gateway: &mut EG)
-> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
let client = clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id)).unwrap();
client.character.gamepad_config.update(gamepad_config);
entity_gateway.save_character(&client.character).await.unwrap();
Box::new(None.into_iter())
}

14
src/ship/ship.rs

@ -92,7 +92,6 @@ pub enum RecvShipPacket {
PlayerChat(PlayerChat),
CreateRoom(CreateRoom),
RoomNameRequest(RoomNameRequest),
UpdateConfig(UpdateConfig),
ViewInfoboardRequest(ViewInfoboardRequest),
WriteInfoboard(WriteInfoboard),
RoomListRequest(RoomListRequest),
@ -114,6 +113,9 @@ pub enum RecvShipPacket {
RequestShipBlockList(RequestShipBlockList),
ItemsToTrade(ItemsToTrade),
TradeConfirmed(TradeConfirmed),
KeyboardConfig(KeyboardConfig),
GamepadConfig(GamepadConfig),
UpdateConfig(UpdateConfig),
}
impl RecvServerPacket for RecvShipPacket {
@ -138,7 +140,6 @@ impl RecvServerPacket for RecvShipPacket {
0x06 => Ok(RecvShipPacket::PlayerChat(PlayerChat::from_bytes(data)?)),
0xC1 => Ok(RecvShipPacket::CreateRoom(CreateRoom::from_bytes(data)?)),
0x8A => Ok(RecvShipPacket::RoomNameRequest(RoomNameRequest::from_bytes(data)?)),
0x7ED => Ok(RecvShipPacket::UpdateConfig(UpdateConfig::from_bytes(data)?)),
0xD8 => Ok(RecvShipPacket::ViewInfoboardRequest(ViewInfoboardRequest::from_bytes(data)?)),
0xD9 => Ok(RecvShipPacket::WriteInfoboard(WriteInfoboard::from_bytes(data)?)),
0x08 => Ok(RecvShipPacket::RoomListRequest(RoomListRequest::from_bytes(data)?)),
@ -155,6 +156,9 @@ impl RecvServerPacket for RecvShipPacket {
0xD2 => Ok(RecvShipPacket::TradeConfirmed(TradeConfirmed::from_bytes(data)?)),
0xE7 => Ok(RecvShipPacket::FullCharacterData(Box::new(FullCharacterData::from_bytes(data)?))),
0x1ED => Ok(RecvShipPacket::SaveOptions(SaveOptions::from_bytes(data)?)),
0x4ED => Ok(RecvShipPacket::KeyboardConfig(KeyboardConfig::from_bytes(data)?)),
0x5ED => Ok(RecvShipPacket::GamepadConfig(GamepadConfig::from_bytes(data)?)),
0x7ED => Ok(RecvShipPacket::UpdateConfig(UpdateConfig::from_bytes(data)?)),
_ => Err(PacketParseError::WrongPacketForServerType(u16::from_le_bytes([data[2], data[3]]), data.to_vec()))
}
}
@ -743,6 +747,12 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> {
let block = self.blocks.with_client(id, &self.clients)?;
handler::trade::trade_confirmed(id, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut self.item_manager, &mut self.trades).await?
},
RecvShipPacket::KeyboardConfig(keyboard_config) => {
handler::settings::keyboard_config(id, keyboard_config, &mut self.clients, &mut self.entity_gateway).await
},
RecvShipPacket::GamepadConfig(gamepad_config) => {
handler::settings::gamepad_config(id, gamepad_config, &mut self.clients, &mut self.entity_gateway).await
},
})
}

4
tests/common.rs

@ -13,7 +13,7 @@ use libpso::packet::login::{Login, Session};
use libpso::{utf8_to_array, utf8_to_utf16_array};
pub async 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, kb_conf_preset: usize) -> (UserAccountEntity, CharacterEntity) {
let new_user = NewUserAccountEntity {
email: format!("{}@pso.com", username),
username: username.into(),
@ -26,7 +26,7 @@ pub async fn new_user_character<EG: EntityGateway>(entity_gateway: &mut EG, user
let user = entity_gateway.create_user(new_user).await.unwrap();
let new_settings = NewUserSettingsEntity::new(user.id);
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, kb_conf_preset);
let character = entity_gateway.create_character(new_character).await.unwrap();
entity_gateway.set_character_meseta(&character.id, Meseta(0)).await.unwrap();
entity_gateway.set_bank_meseta(&character.id, BankName("".into()), Meseta(0)).await.unwrap();

78
tests/test_bank.rs

@ -15,8 +15,8 @@ use common::*;
async fn test_bank_items_sent_in_character_login() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let item = entity_gateway.create_item(
item::NewItemEntity {
@ -50,8 +50,8 @@ async fn test_bank_items_sent_in_character_login() {
async fn test_request_bank_items() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut bank = Vec::new();
for _ in 0..3 {
@ -98,8 +98,8 @@ async fn test_request_bank_items() {
async fn test_request_stacked_bank_items() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut monomates = Vec::new();
for _ in 0..3usize {
@ -141,8 +141,8 @@ async fn test_request_stacked_bank_items() {
async fn test_request_bank_items_sorted() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let item1 = entity_gateway.create_item(
item::NewItemEntity {
@ -207,8 +207,8 @@ async fn test_request_bank_items_sorted() {
async fn test_deposit_individual_item() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let item0 = entity_gateway.create_item(
item::NewItemEntity {
@ -280,8 +280,8 @@ async fn test_deposit_individual_item() {
async fn test_deposit_stacked_item() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut monomates = Vec::new();
for _ in 0..3usize {
@ -341,8 +341,8 @@ async fn test_deposit_stacked_item() {
async fn test_deposit_partial_stacked_item() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut monomates = Vec::new();
for _ in 0..3usize {
@ -411,8 +411,8 @@ async fn test_deposit_partial_stacked_item() {
async fn test_deposit_stacked_item_with_stack_already_in_bank() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut bank_monomates = Vec::new();
let mut inventory_monomates = Vec::new();
@ -483,7 +483,7 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() {
async fn test_deposit_stacked_item_with_full_stack_in_bank() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut inventory_monomates = Vec::new();
for _ in 0..2usize {
@ -555,7 +555,7 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() {
async fn test_deposit_individual_item_in_full_bank() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut inventory = Vec::new();
inventory.push(entity_gateway.create_item(
@ -629,7 +629,7 @@ async fn test_deposit_individual_item_in_full_bank() {
async fn test_deposit_stacked_item_in_full_bank() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut monomates = Vec::new();
for _ in 0..2usize {
@ -702,7 +702,7 @@ async fn test_deposit_stacked_item_in_full_bank() {
async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut monomates = Vec::new();
for _ in 0..2usize {
@ -785,7 +785,7 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() {
async fn test_deposit_meseta() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap();
let mut ship = Box::new(ShipServerState::builder()
@ -821,7 +821,7 @@ async fn test_deposit_meseta() {
async fn test_deposit_too_much_meseta() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(999980)).await.unwrap();
@ -858,7 +858,7 @@ async fn test_deposit_too_much_meseta() {
async fn test_deposit_meseta_when_bank_is_maxed() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(999999)).await.unwrap();
@ -896,8 +896,8 @@ async fn test_deposit_meseta_when_bank_is_maxed() {
async fn test_withdraw_individual_item() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut bank = Vec::new();
bank.push(entity_gateway.create_item(
@ -958,8 +958,8 @@ async fn test_withdraw_individual_item() {
async fn test_withdraw_stacked_item() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut monomates = Vec::new();
for _ in 0..3usize {
@ -1018,8 +1018,8 @@ async fn test_withdraw_stacked_item() {
async fn test_withdraw_partial_stacked_item() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut monomates = Vec::new();
for _ in 0..3usize {
@ -1084,8 +1084,8 @@ async fn test_withdraw_partial_stacked_item() {
async fn test_withdraw_stacked_item_with_stack_already_in_inventory() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut inventory_monomates = Vec::new();
let mut bank_monomates = Vec::new();
@ -1158,7 +1158,7 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() {
async fn test_withdraw_stacked_item_with_full_stack_in_inventory() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut bank_monomates = Vec::new();
for _ in 0..2usize {
@ -1230,7 +1230,7 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() {
async fn test_withdraw_individual_item_in_full_inventory() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut bank = Vec::new();
bank.push(entity_gateway.create_item(
@ -1300,7 +1300,7 @@ async fn test_withdraw_individual_item_in_full_inventory() {
async fn test_withdraw_stacked_item_in_full_inventory() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut monomates = Vec::new();
for _ in 0..2usize {
@ -1374,7 +1374,7 @@ async fn test_withdraw_stacked_item_in_full_inventory() {
async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut bank_item = Vec::new();
for _ in 0..2usize {
@ -1390,7 +1390,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() {
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_item]), item::BankName("".into())).await.unwrap();
let mut items = Vec::new();
for i in 0..29usize {
for _i in 0..29usize {
items.push(entity_gateway.create_item(
item::NewItemEntity {
item: item::ItemDetail::Weapon(
@ -1460,7 +1460,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() {
async fn test_withdraw_meseta() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(300)).await.unwrap();
let mut ship = Box::new(ShipServerState::builder()
@ -1496,7 +1496,7 @@ async fn test_withdraw_meseta() {
async fn test_withdraw_too_much_meseta() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999980)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(300)).await.unwrap();
@ -1533,7 +1533,7 @@ async fn test_withdraw_too_much_meseta() {
async fn test_withdraw_meseta_inventory_is_maxed() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(300)).await.unwrap();

73
tests/test_character.rs

@ -2,6 +2,7 @@ use elseware::common::serverstate::{ClientId, ServerState};
use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
use elseware::ship::ship::{ShipServerState, RecvShipPacket};
use libpso::character::settings::{DEFAULT_KEYBOARD_CONFIG1, DEFAULT_KEYBOARD_CONFIG2, DEFAULT_KEYBOARD_CONFIG3, DEFAULT_KEYBOARD_CONFIG4};
use libpso::packet::ship::*;
#[path = "common.rs"]
@ -12,7 +13,7 @@ use common::*;
async fn test_save_options() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -29,3 +30,73 @@ async fn test_save_options() {
assert!(char.option_flags == 12345);
}
#[async_std::test]
async fn test_default3_keyboard_mappings() {
/*
check if keyboard is set to default3 when specified. this will only occur for things like creating characters from the web page.
normal client behaviour will simply use default1 when creating a character.
gamepad only has 1 default config
*/
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 3).await;
assert!(char1.keyboard_config.as_bytes() == DEFAULT_KEYBOARD_CONFIG3);
}
#[async_std::test]
async fn test_invalid_keyboard_preset_value() {
// check if keyboard_config self-corrects to DEFAULT1 if an invalid value (>4) is given
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 10).await;
assert!(char1.keyboard_config.as_bytes() == DEFAULT_KEYBOARD_CONFIG1);
}
#[async_std::test]
async fn test_change_keyboard_mappings() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 2).await;
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;
assert!(char1.keyboard_config.as_bytes() == DEFAULT_KEYBOARD_CONFIG2);
// update from default2 to default4
// the client simply sends the full 364 bytes...
ship.handle(ClientId(1), &RecvShipPacket::KeyboardConfig(KeyboardConfig{
keyboard_config: [
0, 0, 0, 0, 117, 0, 0, 0, 0, 0, 0, 0, 105, 0, 0, 0,
0, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 115, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 97, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0,
0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 89, 0, 0, 0,
0, 0, 0, 0, 94, 0, 0, 0, 0, 0, 0, 0, 93, 0, 0, 0,
0, 0, 0, 0, 92, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, 0,
0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 93, 0, 0, 0,
0, 0, 0, 0, 92, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, 0,
0, 0, 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, 94, 0, 0, 0,
0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0,
0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0,
0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0,
0, 0, 0, 0, 70, 0, 0, 0, 0, 0, 0, 0, 71, 0, 0, 0,
0, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 73, 0, 0, 0,
0, 0, 0, 0, 74, 0, 0, 0, 0, 0, 0, 0, 75, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0,
0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0,
0, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 46, 0, 0, 0,
0, 0, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0,
0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0,
0, 0, 0, 0, 51, 0, 0, 0, 1, 0, 0, 0
],
})).await.unwrap().for_each(drop);
let characters = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let char = characters[0].as_ref().unwrap();
assert!(char.keyboard_config.as_bytes() == DEFAULT_KEYBOARD_CONFIG4);
}

10
tests/test_exp_gain.rs

@ -15,7 +15,7 @@ use common::*;
async fn test_character_gains_exp() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -52,7 +52,7 @@ async fn test_character_gains_exp() {
async fn test_character_levels_up() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 49;
entity_gateway.save_character(&char1).await.unwrap();
@ -92,7 +92,7 @@ async fn test_character_levels_up() {
async fn test_character_levels_up_multiple_times() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -136,8 +136,8 @@ async fn test_character_levels_up_multiple_times() {
async fn test_one_character_gets_full_exp_and_other_attacker_gets_partial() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone())

6
tests/test_item_actions.rs

@ -14,7 +14,7 @@ use common::*;
async fn test_equip_unit_from_equip_menu() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item(
@ -91,7 +91,7 @@ async fn test_equip_unit_from_equip_menu() {
async fn test_unequip_armor_with_units() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item(
@ -159,7 +159,7 @@ async fn test_unequip_armor_with_units() {
async fn test_sort_items() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item(

48
tests/test_item_pickup.rs

@ -14,8 +14,8 @@ use common::*;
async fn test_pick_up_individual_item() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item(
@ -85,8 +85,8 @@ async fn test_pick_up_individual_item() {
async fn test_pick_up_item_stack_of_items_already_in_inventory() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_monomate = Vec::new();
p1_monomate.push(entity_gateway.create_item(
@ -99,7 +99,7 @@ async fn test_pick_up_item_stack_of_items_already_in_inventory() {
}).await.unwrap());
let mut p2_items = Vec::new();
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() {
let mut item = Vec::new();
for _ in 0..5usize {
item.push(entity_gateway.create_item(
@ -161,8 +161,8 @@ async fn test_pick_up_item_stack_of_items_already_in_inventory() {
async fn test_pick_up_item_stack_of_items_not_already_held() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p2_monomate = Vec::new();
p2_monomate.push(entity_gateway.create_item(
@ -220,8 +220,8 @@ async fn test_pick_up_item_stack_of_items_not_already_held() {
async fn test_pick_up_meseta_when_inventory_full() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_items = Vec::new();
for _ in 0..30usize {
@ -292,11 +292,11 @@ async fn test_pick_up_meseta_when_inventory_full() {
async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new();
for slot in 0..29usize {
for _slot in 0..29usize {
p1_inv.push(entity_gateway.create_item(
item::NewItemEntity {
item: item::ItemDetail::Weapon(
@ -375,11 +375,11 @@ async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() {
async fn test_can_not_pick_up_item_when_inventory_full() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new();
for slot in 0..30usize {
for _slot in 0..30usize {
p1_inv.push(entity_gateway.create_item(
item::NewItemEntity {
item: item::ItemDetail::Weapon(
@ -465,7 +465,7 @@ async fn test_can_not_pick_up_item_when_inventory_full() {
async fn test_can_not_drop_more_meseta_than_is_held() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap();
@ -504,8 +504,8 @@ async fn test_can_not_drop_more_meseta_than_is_held() {
async fn test_pick_up_stack_that_would_exceed_stack_limit() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_monomates = Vec::new();
for _ in 0..6usize {
@ -578,8 +578,8 @@ async fn test_pick_up_stack_that_would_exceed_stack_limit() {
async fn test_can_not_pick_up_meseta_when_full() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
entity_gateway.set_character_meseta(&char2.id, item::Meseta(300)).await.unwrap();
@ -632,8 +632,8 @@ async fn test_can_not_pick_up_meseta_when_full() {
async fn test_meseta_caps_at_999999_when_trying_to_pick_up_more() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999998)).await.unwrap();
entity_gateway.set_character_meseta(&char2.id, item::Meseta(300)).await.unwrap();
@ -685,8 +685,8 @@ async fn test_meseta_caps_at_999999_when_trying_to_pick_up_more() {
async fn test_player_drops_partial_stack_and_other_player_picks_it_up() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut monomates = Vec::new();
for _ in 0..5usize {

10
tests/test_item_use.rs

@ -16,7 +16,7 @@ use common::*;
async fn test_use_monomate() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_items = Vec::new();
for tool in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter() {
@ -63,7 +63,7 @@ async fn test_use_monomate() {
async fn test_use_monomate_twice() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_items = Vec::new();
for tool in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter() {
@ -115,7 +115,7 @@ async fn test_use_monomate_twice() {
async fn test_use_last_monomate() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
for tool in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter() {
@ -157,7 +157,7 @@ async fn test_use_last_monomate() {
async fn test_use_nonstackable_tool() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_items = Vec::new();
p1_items.push(entity_gateway.create_item(
@ -192,7 +192,7 @@ async fn test_use_nonstackable_tool() {
async fn test_use_materials() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
for tool in vec![item::tool::ToolType::PowerMaterial, item::tool::ToolType::LuckMaterial].into_iter() {

10
tests/test_mags.rs

@ -1,7 +1,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::ship::ship::{ShipServerState, RecvShipPacket};
use elseware::entity::character::{CharacterClass, SectionID};
use libpso::packet::ship::*;
@ -15,7 +15,7 @@ use common::*;
async fn test_mag_feed() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mag = entity_gateway.create_item(
item::NewItemEntity {
@ -87,8 +87,8 @@ async fn test_mag_feed() {
async fn test_mag_change_owner() {
let mut entity_gateway = InMemoryGateway::default();
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;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, mut char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
char1.char_class = CharacterClass::RAmarl;
char1.section_id = SectionID::Redria;
entity_gateway.save_character(&char1).await.unwrap();
@ -152,7 +152,7 @@ async fn test_mag_change_owner() {
async fn test_mag_cell() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mag = entity_gateway.create_item(
item::NewItemEntity {

12
tests/test_rooms.rs

@ -4,7 +4,7 @@ use elseware::entity::item;
use elseware::ship::ship::{ShipServerState, RecvShipPacket, SendShipPacket};
use libpso::packet::ship::*;
use libpso::packet::messages::*;
//use libpso::packet::messages::*;
#[path = "common.rs"]
mod common;
@ -15,8 +15,8 @@ use common::*;
async fn test_item_ids_reset_when_rejoining_rooms() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new();
for _ in 0..3usize {
@ -99,7 +99,7 @@ async fn test_item_ids_reset_when_rejoining_rooms() {
#[async_std::test]
async fn test_load_rare_monster_default_appear_rates() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone())
.build());
@ -119,7 +119,7 @@ async fn test_load_rare_monster_default_appear_rates() {
#[async_std::test]
async fn test_set_valid_quest_group() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone())
.build());
@ -139,7 +139,7 @@ async fn test_set_valid_quest_group() {
#[async_std::test]
async fn test_set_invalid_quest_group() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone())
.build());

58
tests/test_shops.rs

@ -16,7 +16,7 @@ use common::*;
async fn test_player_opens_weapon_shop() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap();
@ -46,7 +46,7 @@ async fn test_player_opens_weapon_shop() {
async fn test_player_opens_tool_shop() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap();
@ -76,7 +76,7 @@ async fn test_player_opens_tool_shop() {
async fn test_player_opens_armor_shop() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap();
@ -106,7 +106,7 @@ async fn test_player_opens_armor_shop() {
async fn test_player_buys_from_weapon_shop() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -144,7 +144,7 @@ async fn test_player_buys_from_weapon_shop() {
async fn test_player_buys_from_tool_shop() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -181,7 +181,7 @@ async fn test_player_buys_from_tool_shop() {
async fn test_player_buys_multiple_from_tool_shop() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -222,7 +222,7 @@ async fn test_player_buys_multiple_from_tool_shop() {
async fn test_player_buys_from_armor_shop() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -259,7 +259,7 @@ async fn test_player_buys_from_armor_shop() {
async fn test_player_sells_3_attr_weapon_to_shop() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
@ -303,8 +303,8 @@ async fn test_player_sells_3_attr_weapon_to_shop() {
async fn test_other_clients_see_purchase() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
char1.exp = 80000000;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
entity_gateway.save_character(&char1).await.unwrap();
@ -346,8 +346,8 @@ async fn test_other_clients_see_purchase() {
async fn test_other_clients_see_stacked_purchase() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -397,7 +397,7 @@ async fn test_other_clients_see_stacked_purchase() {
async fn test_buying_item_without_enough_mseseta() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -432,7 +432,7 @@ async fn test_buying_item_without_enough_mseseta() {
async fn test_player_double_buys_from_tool_shop() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -497,7 +497,7 @@ async fn test_player_double_buys_from_tool_shop() {
async fn test_techs_disappear_from_shop_when_bought() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -559,7 +559,7 @@ async fn test_techs_disappear_from_shop_when_bought() {
async fn test_units_disappear_from_shop_when_bought() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
@ -620,7 +620,7 @@ async fn test_units_disappear_from_shop_when_bought() {
async fn test_player_sells_untekked_weapon() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
@ -664,7 +664,7 @@ async fn test_player_sells_untekked_weapon() {
async fn test_player_sells_rare_item() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
@ -708,7 +708,7 @@ async fn test_player_sells_rare_item() {
async fn test_player_sells_partial_photon_drop_stack() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
@ -751,7 +751,7 @@ async fn test_player_sells_partial_photon_drop_stack() {
async fn test_player_sells_basic_frame() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
@ -792,7 +792,7 @@ async fn test_player_sells_basic_frame() {
async fn test_player_sells_max_frame() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
@ -833,7 +833,7 @@ async fn test_player_sells_max_frame() {
async fn test_player_sells_basic_barrier() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
@ -873,7 +873,7 @@ async fn test_player_sells_basic_barrier() {
async fn test_player_sells_max_barrier() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
@ -913,7 +913,7 @@ async fn test_player_sells_max_barrier() {
async fn test_player_sells_1_star_minusminus_unit() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
@ -952,7 +952,7 @@ async fn test_player_sells_1_star_minusminus_unit() {
async fn test_player_sells_5_star_plusplus_unit() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
@ -991,7 +991,7 @@ async fn test_player_sells_5_star_plusplus_unit() {
async fn test_player_sells_rare_frame() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
@ -1032,7 +1032,7 @@ async fn test_player_sells_rare_frame() {
async fn test_player_sells_rare_barrier() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
@ -1072,7 +1072,7 @@ async fn test_player_sells_rare_barrier() {
async fn test_player_sells_rare_unit() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let mut p1_inv = Vec::new();
@ -1111,7 +1111,7 @@ async fn test_player_sells_rare_unit() {
async fn test_player_cant_sell_if_meseta_would_go_over_max() {
let mut entity_gateway = InMemoryGateway::default();
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999995)).await.unwrap();
let mut p1_inv = Vec::new();

158
tests/test_trade.rs

@ -114,8 +114,8 @@ impl TradeItemBuilder {
async fn test_trade_one_individual_item() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item(
@ -215,8 +215,8 @@ async fn test_trade_one_individual_item() {
async fn test_trade_player2_to_player1() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p2_inv = Vec::new();
p2_inv.push(entity_gateway.create_item(
@ -316,8 +316,8 @@ async fn test_trade_player2_to_player1() {
async fn test_reverse_trade_ack_order() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item(
@ -417,8 +417,8 @@ async fn test_reverse_trade_ack_order() {
async fn test_trade_one_stacked_item() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -521,8 +521,8 @@ async fn test_trade_one_stacked_item() {
async fn test_trade_partial_stacked_item() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -628,8 +628,8 @@ async fn test_trade_partial_stacked_item() {
async fn test_trade_individual_both() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = vec![
entity_gateway.create_item(
@ -793,8 +793,8 @@ async fn test_trade_individual_both() {
async fn test_trade_stacked_both() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -963,8 +963,8 @@ async fn test_trade_stacked_both() {
async fn test_trade_partial_stack_both() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -1139,8 +1139,8 @@ async fn test_trade_partial_stack_both() {
async fn test_trade_same_stacked_item_to_eachother() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..3).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -1311,8 +1311,8 @@ async fn test_trade_same_stacked_item_to_eachother() {
async fn test_trade_stacked_when_already_have_partial_stack() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..3).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -1451,8 +1451,8 @@ async fn test_trade_stacked_when_already_have_partial_stack() {
async fn test_trade_individual_for_stacked() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = vec![
entity_gateway.create_item(
@ -1621,8 +1621,8 @@ async fn test_trade_individual_for_stacked() {
async fn test_trade_multiple_individual() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = vec![
entity_gateway.create_item(
@ -1879,8 +1879,8 @@ async fn test_trade_multiple_individual() {
async fn test_trade_multiple_stacked() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack1 = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -2146,8 +2146,8 @@ async fn test_trade_multiple_stacked() {
async fn test_trade_not_enough_inventory_space_individual() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -2268,8 +2268,8 @@ async fn test_trade_not_enough_inventory_space_individual() {
async fn test_trade_not_enough_inventory_space_stacked() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -2385,8 +2385,8 @@ async fn test_trade_not_enough_inventory_space_stacked() {
async fn test_trade_stack_too_big() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..8).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -2501,8 +2501,8 @@ async fn test_trade_stack_too_big() {
async fn test_trade_meseta() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, Meseta(2323)).await.unwrap();
@ -2582,8 +2582,8 @@ async fn test_trade_meseta() {
async fn test_trade_too_much_meseta() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, Meseta(4000)).await.unwrap();
entity_gateway.set_character_meseta(&char2.id, Meseta(999000)).await.unwrap();
@ -2634,8 +2634,8 @@ async fn test_trade_too_much_meseta() {
async fn test_trade_invalid_amount_of_meseta() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, Meseta(4000)).await.unwrap();
entity_gateway.set_character_meseta(&char2.id, Meseta(999000)).await.unwrap();
@ -2686,8 +2686,8 @@ async fn test_trade_invalid_amount_of_meseta() {
async fn test_trade_meseta_request_and_items_dont_match() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, Meseta(4000)).await.unwrap();
entity_gateway.set_character_meseta(&char2.id, Meseta(999000)).await.unwrap();
@ -2738,8 +2738,8 @@ async fn test_trade_meseta_request_and_items_dont_match() {
async fn test_player_declined_trade() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -2769,8 +2769,8 @@ async fn test_player_declined_trade() {
async fn test_back_out_of_trade_last_minute() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item(
@ -2835,8 +2835,8 @@ async fn test_back_out_of_trade_last_minute() {
async fn test_valid_trade_when_both_inventories_are_full() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = futures::future::join_all((0..30).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -2977,8 +2977,8 @@ async fn test_valid_trade_when_both_inventories_are_full() {
async fn test_invalid_trade_when_both_inventories_are_full() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = futures::future::join_all((0..30).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -3128,9 +3128,9 @@ async fn test_invalid_trade_when_both_inventories_are_full() {
async fn test_client_tries_to_start_two_trades() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user2, _char3) = new_user_character(&mut entity_gateway, "a3", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let (_user2, _char3) = new_user_character(&mut entity_gateway, "a3", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -3160,9 +3160,9 @@ async fn test_client_tries_to_start_two_trades() {
async fn test_client_tries_trading_with_client_already_trading() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user2, _char3) = new_user_character(&mut entity_gateway, "a3", "a").await;
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let (_user2, _char3) = new_user_character(&mut entity_gateway, "a3", "a", 1).await;
let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -3199,8 +3199,8 @@ async fn test_client_tries_trading_with_client_already_trading() {
async fn test_add_then_remove_individual_item() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new();
for _ in 0..2 {
@ -3312,8 +3312,8 @@ async fn test_add_then_remove_individual_item() {
async fn test_add_then_remove_stacked_item() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack1 = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -3447,8 +3447,8 @@ async fn test_add_then_remove_stacked_item() {
async fn test_add_then_remove_partial_stack() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack1 = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -3571,8 +3571,8 @@ async fn test_add_then_remove_partial_stack() {
async fn test_add_then_remove_meseta() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, Meseta(2323)).await.unwrap();
@ -3657,8 +3657,8 @@ async fn test_add_then_remove_meseta() {
async fn test_items_to_trade_data_does_not_match() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item(
@ -3740,8 +3740,8 @@ async fn test_items_to_trade_data_does_not_match() {
async fn test_items_to_trade_id_does_not_match() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item(
@ -3811,8 +3811,8 @@ async fn test_items_to_trade_id_does_not_match() {
async fn test_stack_is_same_amount_in_request_and_items_to_trade() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -3885,8 +3885,8 @@ async fn test_stack_is_same_amount_in_request_and_items_to_trade() {
async fn test_stack_is_same_amount_in_request_and_items_to_trade2() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_stack = futures::future::join_all((0..2).map(|_| {
let mut entity_gateway = entity_gateway.clone();
@ -3959,8 +3959,8 @@ async fn test_stack_is_same_amount_in_request_and_items_to_trade2() {
async fn test_items_to_trade_count_less_than() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = vec![
entity_gateway.create_item(
@ -4061,8 +4061,8 @@ async fn test_items_to_trade_count_less_than() {
async fn test_items_to_trade_count_greater_than() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
entity_gateway.set_character_meseta(&char1.id, Meseta(23)).await.unwrap();
@ -4171,8 +4171,8 @@ async fn test_items_to_trade_count_greater_than() {
async fn test_items_to_trade_count_mismatch_with_meseta() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let p1_inv = vec![
entity_gateway.create_item(
@ -4273,8 +4273,8 @@ async fn test_items_to_trade_count_mismatch_with_meseta() {
async fn test_dropping_item_after_trade() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
let (_user2, char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
let mut p1_inv = Vec::new();
p1_inv.push(entity_gateway.create_item(
@ -4364,7 +4364,7 @@ async fn test_dropping_item_after_trade() {
assert!(matches!(ack[3], (ClientId(2), SendShipPacket::TradeSuccessful {..})));
assert!(matches!(ack[4], (ClientId(1), SendShipPacket::TradeSuccessful {..})));
let ack = ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
let _ack = ship.handle(ClientId(2), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDropItem(PlayerDropItem {
client: 0,
target: 0,
unknown1: 0,

Loading…
Cancel
Save