Browse Source

entitygateway stuff should take &BankName not BankName

kill_counters
jake 3 years ago
committed by andy
parent
commit
2aa8dae9b2
  1. 7
      src/bin/main.rs
  2. 8
      src/entity/gateway/entitygateway.rs
  3. 12
      src/entity/gateway/inmemory.rs
  4. 32
      src/entity/gateway/postgres/postgres.rs
  5. 2
      src/login/character.rs
  6. 8
      src/ship/items/manager.rs
  7. 2
      src/ship/items/state.rs
  8. 2
      tests/common.rs
  9. 92
      tests/test_bank.rs

7
src/bin/main.rs

@ -69,14 +69,15 @@ fn main() {
character.name = format!("Test Char {}", i*2); character.name = format!("Test Char {}", i*2);
let character = entity_gateway.create_character(character).await.unwrap(); let character = entity_gateway.create_character(character).await.unwrap();
entity_gateway.set_character_meseta(&character.id, item::Meseta(999999)).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);
entity_gateway.set_bank_meseta(&character.id, &item::BankName("".into()), item::Meseta(999999)).await.unwrap();
let mut character = NewCharacterEntity::new(fake_user.id, 1); let mut character = NewCharacterEntity::new(fake_user.id, 1);
character.slot = 2; character.slot = 2;
character.name = "ItemRefactor".into(); character.name = "ItemRefactor".into();
character.exp = 80000000; character.exp = 80000000;
let character = entity_gateway.create_character(character).await.unwrap(); let character = entity_gateway.create_character(character).await.unwrap();
entity_gateway.set_character_meseta(&character.id, item::Meseta(999999)).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();
entity_gateway.set_bank_meseta(&character.id, &item::BankName("".into()), item::Meseta(999999)).await.unwrap();
for _ in 0..3 { for _ in 0..3 {
entity_gateway.create_item( entity_gateway.create_item(
@ -347,7 +348,7 @@ fn main() {
let inventory = item::InventoryEntity::new(vec![InventoryItemEntity::from(item0), item1.into(), item2_w.into(), item3.into(), item4.into(), item5_m.into(), item6.into(), item6_1.into(), item7_a.into(), item8_s.into(), item9_u0.into(), item10_u1.into(), item11_u2.into(), item12_u3.into(), item13.into(), item14.into(), monomates.into()]); let inventory = item::InventoryEntity::new(vec![InventoryItemEntity::from(item0), item1.into(), item2_w.into(), item3.into(), item4.into(), item5_m.into(), item6.into(), item6_1.into(), item7_a.into(), item8_s.into(), item9_u0.into(), item10_u1.into(), item11_u2.into(), item12_u3.into(), item13.into(), item14.into(), monomates.into()]);
entity_gateway.set_character_inventory(&character.id, &inventory).await.unwrap(); entity_gateway.set_character_inventory(&character.id, &inventory).await.unwrap();
entity_gateway.set_character_bank(&character.id, &item::BankEntity::default(), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&character.id, &item::BankEntity::default(), &item::BankName("".into())).await.unwrap();
} }
info!("[patch] starting server"); info!("[patch] starting server");

8
src/entity/gateway/entitygateway.rs

@ -118,7 +118,7 @@ pub trait EntityGateway: Send + Sync {
unimplemented!(); unimplemented!();
} }
async fn get_character_bank(&mut self, _char_id: &CharacterEntityId, _bank_name: BankName) -> Result<BankEntity, GatewayError> {
async fn get_character_bank(&mut self, _char_id: &CharacterEntityId, _bank_name: &BankName) -> Result<BankEntity, GatewayError> {
unimplemented!(); unimplemented!();
} }
@ -126,7 +126,7 @@ pub trait EntityGateway: Send + Sync {
unimplemented!(); unimplemented!();
} }
async fn set_character_bank(&mut self, _char_id: &CharacterEntityId, _inventory: &BankEntity, _bank_name: BankName) -> Result<(), GatewayError> {
async fn set_character_bank(&mut self, _char_id: &CharacterEntityId, _inventory: &BankEntity, _bank_name: &BankName) -> Result<(), GatewayError> {
unimplemented!(); unimplemented!();
} }
@ -146,11 +146,11 @@ pub trait EntityGateway: Send + Sync {
unimplemented!(); unimplemented!();
} }
async fn get_bank_meseta(&mut self, _char_id: &CharacterEntityId, _bank: BankName) -> Result<Meseta, GatewayError> {
async fn get_bank_meseta(&mut self, _char_id: &CharacterEntityId, _bank: &BankName) -> Result<Meseta, GatewayError> {
unimplemented!(); unimplemented!();
} }
async fn set_bank_meseta(&mut self, _char_id: &CharacterEntityId, _bank: BankName, _amount: Meseta) -> Result<(), GatewayError> {
async fn set_bank_meseta(&mut self, _char_id: &CharacterEntityId, _bank: &BankName, _amount: Meseta) -> Result<(), GatewayError> {
unimplemented!(); unimplemented!();
} }
} }

12
src/entity/gateway/inmemory.rs

@ -416,7 +416,7 @@ impl EntityGateway for InMemoryGateway {
.unwrap_or_default()) .unwrap_or_default())
} }
async fn get_character_bank(&mut self, char_id: &CharacterEntityId, _bank_name: BankName) -> Result<BankEntity, GatewayError> {
async fn get_character_bank(&mut self, char_id: &CharacterEntityId, _bank_name: &BankName) -> Result<BankEntity, GatewayError> {
let banks = self.banks.lock().unwrap(); let banks = self.banks.lock().unwrap();
Ok(banks Ok(banks
.iter() .iter()
@ -432,7 +432,7 @@ impl EntityGateway for InMemoryGateway {
} }
// TOOD: impl bank name // TOOD: impl bank name
async fn set_character_bank(&mut self, char_id: &CharacterEntityId, bank: &BankEntity, _bank_name: BankName) -> Result<(), GatewayError> {
async fn set_character_bank(&mut self, char_id: &CharacterEntityId, bank: &BankEntity, _bank_name: &BankName) -> Result<(), GatewayError> {
let mut banks = self.banks.lock().unwrap(); let mut banks = self.banks.lock().unwrap();
banks.insert(*char_id, bank.clone()); banks.insert(*char_id, bank.clone());
Ok(()) Ok(())
@ -469,15 +469,15 @@ impl EntityGateway for InMemoryGateway {
} }
} }
async fn set_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: BankName, meseta: Meseta) -> Result<(), GatewayError> {
async fn set_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: &BankName, meseta: Meseta) -> Result<(), GatewayError> {
let mut bank_meseta = self.bank_meseta.lock().unwrap(); let mut bank_meseta = self.bank_meseta.lock().unwrap();
bank_meseta.insert((*char_id, bank), meseta);
bank_meseta.insert((*char_id, bank.clone()), meseta);
Ok(()) Ok(())
} }
async fn get_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: BankName) -> Result<Meseta, GatewayError> {
async fn get_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: &BankName) -> Result<Meseta, GatewayError> {
let mut bank_meseta = self.bank_meseta.lock().unwrap(); let mut bank_meseta = self.bank_meseta.lock().unwrap();
if let Some(meseta) = bank_meseta.get_mut(&(*char_id, bank)) {
if let Some(meseta) = bank_meseta.get_mut(&(*char_id, bank.clone())) {
Ok(*meseta) Ok(*meseta)
} }
else { else {

32
src/entity/gateway/postgres/postgres.rs

@ -400,12 +400,12 @@ async fn get_character_inventory(conn: &mut sqlx::PgConnection, char_id: &Charac
Ok(InventoryEntity::new(real_inventory)) Ok(InventoryEntity::new(real_inventory))
} }
async fn get_character_bank(conn: &mut sqlx::PgConnection, char_id: &CharacterEntityId, bank_name: BankName) -> Result<BankEntity, GatewayError>
async fn get_character_bank(conn: &mut sqlx::PgConnection, char_id: &CharacterEntityId, bank_name: &BankName) -> Result<BankEntity, GatewayError>
{ {
let mut t = conn.begin().await?; let mut t = conn.begin().await?;
let bank = sqlx::query_as::<_, PgInventoryEntity>("select * from bank where pchar = $1 and name = $2") let bank = sqlx::query_as::<_, PgInventoryEntity>("select * from bank where pchar = $1 and name = $2")
.bind(char_id.0) .bind(char_id.0)
.bind(bank_name.0)
.bind(bank_name.0.clone())
.fetch_one(&mut t).await?; .fetch_one(&mut t).await?;
// TODO: inefficient // TODO: inefficient
let mut real_bank = Vec::new(); let mut real_bank = Vec::new();
@ -461,7 +461,7 @@ async fn set_character_inventory(conn: &mut sqlx::PgConnection, char_id: &Charac
Ok(()) Ok(())
} }
async fn set_character_bank(conn: &mut sqlx::PgConnection, char_id: &CharacterEntityId, bank: &BankEntity, bank_name: BankName) -> Result<(), GatewayError>
async fn set_character_bank(conn: &mut sqlx::PgConnection, char_id: &CharacterEntityId, bank: &BankEntity, bank_name: &BankName) -> Result<(), GatewayError>
{ {
let bank = bank.items.iter() let bank = bank.items.iter()
.map(|item| { .map(|item| {
@ -479,7 +479,7 @@ async fn set_character_bank(conn: &mut sqlx::PgConnection, char_id: &CharacterEn
sqlx::query("insert into bank (pchar, items, name) values ($1, $2, $3) on conflict (pchar, name) do update set items = $2") sqlx::query("insert into bank (pchar, items, name) values ($1, $2, $3) on conflict (pchar, name) do update set items = $2")
.bind(char_id.0) .bind(char_id.0)
.bind(sqlx::types::Json(bank)) .bind(sqlx::types::Json(bank))
.bind(bank_name.0)
.bind(bank_name.0.clone())
.execute(conn) .execute(conn)
.await?; .await?;
Ok(()) Ok(())
@ -534,24 +534,24 @@ async fn get_character_meseta(conn: &mut sqlx::PgConnection, char_id: &Character
Ok(Meseta(meseta.0 as u32)) Ok(Meseta(meseta.0 as u32))
} }
async fn set_bank_meseta(conn: &mut sqlx::PgConnection, char_id: &CharacterEntityId, bank: BankName, meseta: Meseta) -> Result<(), GatewayError>
async fn set_bank_meseta(conn: &mut sqlx::PgConnection, char_id: &CharacterEntityId, bank: &BankName, meseta: Meseta) -> Result<(), GatewayError>
{ {
sqlx::query("insert into bank_meseta values ($1, $2, $3) on conflict (pchar, bank) do update set items = $2") sqlx::query("insert into bank_meseta values ($1, $2, $3) on conflict (pchar, bank) do update set items = $2")
.bind(char_id.0) .bind(char_id.0)
.bind(meseta.0 as i32) .bind(meseta.0 as i32)
.bind(bank.0)
.bind(bank.0.clone())
.execute(conn) .execute(conn)
.await?; .await?;
Ok(()) Ok(())
} }
async fn get_bank_meseta(conn: &mut sqlx::PgConnection, char_id: &CharacterEntityId, bank: BankName) -> Result<Meseta, GatewayError>
async fn get_bank_meseta(conn: &mut sqlx::PgConnection, char_id: &CharacterEntityId, bank: &BankName) -> Result<Meseta, GatewayError>
{ {
#[derive(sqlx::FromRow)] #[derive(sqlx::FromRow)]
struct PgMeseta(i32); struct PgMeseta(i32);
let meseta = sqlx::query_as::<_, PgMeseta>(r#"select meseta from character_meseta where id = $1 and bank = $2"#) let meseta = sqlx::query_as::<_, PgMeseta>(r#"select meseta from character_meseta where id = $1 and bank = $2"#)
.bind(char_id.0) .bind(char_id.0)
.bind(bank.0)
.bind(bank.0.clone())
.fetch_one(conn) .fetch_one(conn)
.await?; .await?;
Ok(Meseta(meseta.0 as u32)) Ok(Meseta(meseta.0 as u32))
@ -657,7 +657,7 @@ impl EntityGateway for PostgresGateway {
get_character_inventory(&mut *self.pool.acquire().await?, char_id).await get_character_inventory(&mut *self.pool.acquire().await?, char_id).await
} }
async fn get_character_bank(&mut self, char_id: &CharacterEntityId, bank_name: BankName) -> Result<BankEntity, GatewayError> {
async fn get_character_bank(&mut self, char_id: &CharacterEntityId, bank_name: &BankName) -> Result<BankEntity, GatewayError> {
get_character_bank(&mut *self.pool.acquire().await?, char_id, bank_name).await get_character_bank(&mut *self.pool.acquire().await?, char_id, bank_name).await
} }
@ -665,7 +665,7 @@ impl EntityGateway for PostgresGateway {
set_character_inventory(&mut *self.pool.acquire().await?, char_id, inventory).await set_character_inventory(&mut *self.pool.acquire().await?, char_id, inventory).await
} }
async fn set_character_bank(&mut self, char_id: &CharacterEntityId, bank: &BankEntity, bank_name: BankName) -> Result<(), GatewayError> {
async fn set_character_bank(&mut self, char_id: &CharacterEntityId, bank: &BankEntity, bank_name: &BankName) -> Result<(), GatewayError> {
set_character_bank(&mut *self.pool.acquire().await?, char_id, bank, bank_name).await set_character_bank(&mut *self.pool.acquire().await?, char_id, bank, bank_name).await
} }
@ -685,11 +685,11 @@ impl EntityGateway for PostgresGateway {
get_character_meseta(&mut *self.pool.acquire().await?, char_id).await get_character_meseta(&mut *self.pool.acquire().await?, char_id).await
} }
async fn set_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: BankName, meseta: Meseta) -> Result<(), GatewayError> {
async fn set_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: &BankName, meseta: Meseta) -> Result<(), GatewayError> {
set_bank_meseta(&mut *self.pool.acquire().await?, char_id, bank, meseta).await set_bank_meseta(&mut *self.pool.acquire().await?, char_id, bank, meseta).await
} }
async fn get_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: BankName) -> Result<Meseta, GatewayError> {
async fn get_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: &BankName) -> Result<Meseta, GatewayError> {
get_bank_meseta(&mut *self.pool.acquire().await?, char_id, bank).await get_bank_meseta(&mut *self.pool.acquire().await?, char_id, bank).await
} }
} }
@ -773,7 +773,7 @@ impl<'c> EntityGateway for PostgresTransaction<'c> {
get_character_inventory(&mut *self.pgtransaction, char_id).await get_character_inventory(&mut *self.pgtransaction, char_id).await
} }
async fn get_character_bank(&mut self, char_id: &CharacterEntityId, bank_name: BankName) -> Result<BankEntity, GatewayError> {
async fn get_character_bank(&mut self, char_id: &CharacterEntityId, bank_name: &BankName) -> Result<BankEntity, GatewayError> {
get_character_bank(&mut *self.pgtransaction, char_id, bank_name).await get_character_bank(&mut *self.pgtransaction, char_id, bank_name).await
} }
@ -781,7 +781,7 @@ impl<'c> EntityGateway for PostgresTransaction<'c> {
set_character_inventory(&mut *self.pgtransaction, char_id, inventory).await set_character_inventory(&mut *self.pgtransaction, char_id, inventory).await
} }
async fn set_character_bank(&mut self, char_id: &CharacterEntityId, bank: &BankEntity, bank_name: BankName) -> Result<(), GatewayError> {
async fn set_character_bank(&mut self, char_id: &CharacterEntityId, bank: &BankEntity, bank_name: &BankName) -> Result<(), GatewayError> {
set_character_bank(&mut *self.pgtransaction, char_id, bank, bank_name).await set_character_bank(&mut *self.pgtransaction, char_id, bank, bank_name).await
} }
@ -801,11 +801,11 @@ impl<'c> EntityGateway for PostgresTransaction<'c> {
get_character_meseta(&mut *self.pgtransaction, char_id).await get_character_meseta(&mut *self.pgtransaction, char_id).await
} }
async fn set_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: BankName, meseta: Meseta) -> Result<(), GatewayError> {
async fn set_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: &BankName, meseta: Meseta) -> Result<(), GatewayError> {
set_bank_meseta(&mut *self.pgtransaction, char_id, bank, meseta).await set_bank_meseta(&mut *self.pgtransaction, char_id, bank, meseta).await
} }
async fn get_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: BankName) -> Result<Meseta, GatewayError> {
async fn get_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: &BankName) -> Result<Meseta, GatewayError> {
get_bank_meseta(&mut *self.pgtransaction, char_id, bank).await get_bank_meseta(&mut *self.pgtransaction, char_id, bank).await
} }
} }

2
src/login/character.rs

@ -295,7 +295,7 @@ async fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAc
InventoryItemEntity::Stacked(monomates), InventoryItemEntity::Stacked(monofluids)], InventoryItemEntity::Stacked(monomates), InventoryItemEntity::Stacked(monofluids)],
}; };
entity_gateway.set_character_inventory(&character.id, &inventory).await?; entity_gateway.set_character_inventory(&character.id, &inventory).await?;
entity_gateway.set_character_bank(&character.id, &BankEntity::default(), BankName("".into())).await?;
entity_gateway.set_character_bank(&character.id, &BankEntity::default(), &BankName("".into())).await?;
let equipped = EquippedEntity { let equipped = EquippedEntity {
weapon: Some(weapon.id), weapon: Some(weapon.id),
armor: Some(armor.id), armor: Some(armor.id),

8
src/ship/items/manager.rs

@ -152,7 +152,7 @@ impl ItemManager {
pub async fn load_character<EG: EntityGateway>(&mut self, entity_gateway: &mut EG, character: &CharacterEntity) -> Result<(), anyhow::Error> { pub async fn load_character<EG: EntityGateway>(&mut self, entity_gateway: &mut EG, character: &CharacterEntity) -> Result<(), anyhow::Error> {
let inventory = entity_gateway.get_character_inventory(&character.id).await?; let inventory = entity_gateway.get_character_inventory(&character.id).await?;
let bank = entity_gateway.get_character_bank(&character.id, BankName("".into())).await?;
let bank = entity_gateway.get_character_bank(&character.id, &BankName("".into())).await?;
let equipped = entity_gateway.get_character_equips(&character.id).await?; let equipped = entity_gateway.get_character_equips(&character.id).await?;
let inventory_items = inventory.items.into_iter() let inventory_items = inventory.items.into_iter()
@ -210,7 +210,7 @@ impl ItemManager {
let character_bank = CharacterBank::new(bank_items); let character_bank = CharacterBank::new(bank_items);
let character_meseta = entity_gateway.get_character_meseta(&character.id).await?; let character_meseta = entity_gateway.get_character_meseta(&character.id).await?;
let bank_meseta = entity_gateway.get_bank_meseta(&character.id, BankName("".into())).await?;
let bank_meseta = entity_gateway.get_bank_meseta(&character.id, &BankName("".into())).await?;
self.character_inventory.insert(character.id, character_inventory); self.character_inventory.insert(character.id, character_inventory);
self.character_bank.insert(character.id, character_bank); self.character_bank.insert(character.id, character_bank);
@ -630,7 +630,7 @@ impl ItemManager {
let _bank_item = bank.deposit_item(item_to_deposit, amount).ok_or(ItemManagerError::Idunnoman)?; let _bank_item = bank.deposit_item(item_to_deposit, amount).ok_or(ItemManagerError::Idunnoman)?;
entity_gateway.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?; entity_gateway.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;
entity_gateway.set_character_bank(&character.id, &bank.as_bank_entity(&character.id, &BankName("".into())), BankName("".into())).await?;
entity_gateway.set_character_bank(&character.id, &bank.as_bank_entity(&character.id, &BankName("".into())), &BankName("".into())).await?;
Ok(()) Ok(())
} }
@ -653,7 +653,7 @@ impl ItemManager {
}; };
entity_gateway.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?; entity_gateway.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;
entity_gateway.set_character_bank(&character.id, &bank.as_bank_entity(&character.id, &BankName("".into())), BankName("".into())).await?;
entity_gateway.set_character_bank(&character.id, &bank.as_bank_entity(&character.id, &BankName("".into())), &BankName("".into())).await?;
inventory.slot(inventory_item_slot).ok_or_else(|| ItemManagerError::Idunnoman.into()) inventory.slot(inventory_item_slot).ok_or_else(|| ItemManagerError::Idunnoman.into())
} }

2
src/ship/items/state.rs

@ -723,7 +723,7 @@ impl ItemState {
pub async fn load_character<EG: EntityGateway>(&mut self, entity_gateway: &mut EG, character: &CharacterEntity) -> Result<(), ItemStateError> { pub async fn load_character<EG: EntityGateway>(&mut self, entity_gateway: &mut EG, character: &CharacterEntity) -> Result<(), ItemStateError> {
let inventory = entity_gateway.get_character_inventory(&character.id).await?; let inventory = entity_gateway.get_character_inventory(&character.id).await?;
let bank = entity_gateway.get_character_bank(&character.id, BankName("".into())).await?;
let bank = entity_gateway.get_character_bank(&character.id, &BankName("".into())).await?;
let equipped = entity_gateway.get_character_equips(&character.id).await?; let equipped = entity_gateway.get_character_equips(&character.id).await?;
let inventory_items = inventory.items.into_iter() let inventory_items = inventory.items.into_iter()

2
tests/common.rs

@ -29,7 +29,7 @@ pub async fn new_user_character<EG: EntityGateway>(entity_gateway: &mut EG, user
let new_character = NewCharacterEntity::new(user.id, kb_conf_preset); let new_character = NewCharacterEntity::new(user.id, kb_conf_preset);
let character = entity_gateway.create_character(new_character).await.unwrap(); let character = entity_gateway.create_character(new_character).await.unwrap();
entity_gateway.set_character_meseta(&character.id, Meseta(0)).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();
entity_gateway.set_bank_meseta(&character.id, &BankName("".into()), Meseta(0)).await.unwrap();
(user, character) (user, character)
} }

92
tests/test_bank.rs

@ -32,7 +32,7 @@ async fn test_bank_items_sent_in_character_login() {
), ),
}).await.unwrap(); }).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![item]), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![item]), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -71,7 +71,7 @@ async fn test_request_bank_items() {
}).await.unwrap()); }).await.unwrap());
} }
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -115,7 +115,7 @@ async fn test_request_stacked_bank_items() {
}).await.unwrap()); }).await.unwrap());
} }
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -182,7 +182,7 @@ async fn test_request_bank_items_sorted() {
}).await.unwrap(); }).await.unwrap();
let bank = vec![item::BankItemEntity::Individual(item1), vec![monomate].into(), item2.into()]; let bank = vec![item::BankItemEntity::Individual(item1), vec![monomate].into(), item2.into()];
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -275,7 +275,13 @@ async fn test_deposit_individual_item() {
&& player_no_longer_has_item.amount == 0 && player_no_longer_has_item.amount == 0
)); ));
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
assert_eq!(inventory_items.items.len(), 1);
inventory_items.items[0].with_individual(|item| {
assert_eq!(item.id, item::ItemEntityId(1));
}).unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert_eq!(bank_items.items.len(), 1); assert_eq!(bank_items.items.len(), 1);
bank_items.items[0].with_individual(|item| { bank_items.items[0].with_individual(|item| {
assert_eq!(item.id, item::ItemEntityId(2)); assert_eq!(item.id, item::ItemEntityId(2));
@ -335,7 +341,7 @@ async fn test_deposit_stacked_item() {
&& player_no_longer_has_item.amount == 3 && player_no_longer_has_item.amount == 3
)); ));
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert_eq!(bank_items.items.len(), 1); assert_eq!(bank_items.items.len(), 1);
bank_items.items[0].with_stacked(|items| { bank_items.items[0].with_stacked(|items| {
assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(), assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(),
@ -397,7 +403,7 @@ async fn test_deposit_partial_stacked_item() {
)); ));
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert_eq!(bank_items.items.len(), 1); assert_eq!(bank_items.items.len(), 1);
bank_items.items[0].with_stacked(|items| { bank_items.items[0].with_stacked(|items| {
assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(), assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(),
@ -443,7 +449,7 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() {
} }
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![inventory_monomates])).await.unwrap(); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![inventory_monomates])).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -477,7 +483,7 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() {
&& player_no_longer_has_item.amount == 2 && player_no_longer_has_item.amount == 2
)); ));
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert_eq!(bank_items.items.len(), 1); assert_eq!(bank_items.items.len(), 1);
bank_items.items[0].with_stacked(|items| { bank_items.items[0].with_stacked(|items| {
assert_eq!(items.iter().map(|i| i.id).collect::<BTreeSet<_>>(), assert_eq!(items.iter().map(|i| i.id).collect::<BTreeSet<_>>(),
@ -516,7 +522,7 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() {
} }
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![inventory_monomates])).await.unwrap(); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![inventory_monomates])).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -543,7 +549,7 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() {
assert!(packets.is_err()); assert!(packets.is_err());
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert_eq!(bank_items.items.len(), 1); assert_eq!(bank_items.items.len(), 1);
bank_items.items[0].with_stacked(|items| { bank_items.items[0].with_stacked(|items| {
assert_eq!(items.len(), 10); assert_eq!(items.len(), 10);
@ -596,7 +602,7 @@ async fn test_deposit_individual_item_in_full_bank() {
} }
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(inventory)).await.unwrap(); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(inventory)).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -623,7 +629,7 @@ async fn test_deposit_individual_item_in_full_bank() {
assert!(packets.is_err()); assert!(packets.is_err());
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert_eq!(bank_items.items.len(), 200); assert_eq!(bank_items.items.len(), 200);
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap(); let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
@ -669,7 +675,7 @@ async fn test_deposit_stacked_item_in_full_bank() {
} }
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![monomates])).await.unwrap(); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![monomates])).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(full_bank), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(full_bank), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -696,7 +702,7 @@ async fn test_deposit_stacked_item_in_full_bank() {
assert!(packets.is_err()); assert!(packets.is_err());
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert_eq!(bank_items.items.len(), 200); assert_eq!(bank_items.items.len(), 200);
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap(); let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
@ -756,7 +762,7 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() {
almost_full_bank.push(bank_monomates.into()); almost_full_bank.push(bank_monomates.into());
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![monomates])).await.unwrap(); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![monomates])).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(almost_full_bank), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(almost_full_bank), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -781,7 +787,7 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() {
unknown: 0, unknown: 0,
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert_eq!(bank_items.items.len(), 200); assert_eq!(bank_items.items.len(), 200);
bank_items.items[199].with_stacked(|items| { bank_items.items[199].with_stacked(|items| {
assert_eq!(items.len(), 4); assert_eq!(items.len(), 4);
@ -822,7 +828,7 @@ async fn test_deposit_meseta() {
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap(); let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, item::BankName("".into())).await.unwrap();
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap();
assert!(c1_meseta.0 == 277); assert!(c1_meseta.0 == 277);
assert!(c1_bank_meseta.0 == 23); assert!(c1_bank_meseta.0 == 23);
} }
@ -833,7 +839,7 @@ async fn test_deposit_too_much_meseta() {
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).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_character_meseta(&char1.id, item::Meseta(300)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(999980)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, &item::BankName("".into()), item::Meseta(999980)).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -859,7 +865,7 @@ async fn test_deposit_too_much_meseta() {
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap(); let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, item::BankName("".into())).await.unwrap();
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap();
assert!(c1_meseta.0 == 300); assert!(c1_meseta.0 == 300);
assert!(c1_bank_meseta.0 == 999980); assert!(c1_bank_meseta.0 == 999980);
} }
@ -870,7 +876,7 @@ async fn test_deposit_meseta_when_bank_is_maxed() {
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).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_character_meseta(&char1.id, item::Meseta(300)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(999999)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, &item::BankName("".into()), item::Meseta(999999)).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -896,7 +902,7 @@ async fn test_deposit_meseta_when_bank_is_maxed() {
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap(); let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, item::BankName("".into())).await.unwrap();
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap();
assert!(c1_meseta.0 == 300); assert!(c1_meseta.0 == 300);
assert!(c1_bank_meseta.0 == 999999); assert!(c1_bank_meseta.0 == 999999);
} }
@ -924,7 +930,7 @@ async fn test_withdraw_individual_item() {
), ),
}).await.unwrap()); }).await.unwrap());
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -984,7 +990,7 @@ async fn test_withdraw_stacked_item() {
}).await.unwrap()); }).await.unwrap());
} }
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -1043,7 +1049,7 @@ async fn test_withdraw_partial_stacked_item() {
), ),
}).await.unwrap()); }).await.unwrap());
} }
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -1073,10 +1079,10 @@ async fn test_withdraw_partial_stacked_item() {
assert!(packets.len() == 2); assert!(packets.len() == 2);
assert!(matches!(&packets[1], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::CreateItem(create_item)})) assert!(matches!(&packets[1], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::CreateItem(create_item)}))
if create_item.item_id == 0x10002
if create_item.item_id == 0x20002
)); ));
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert_eq!(bank_items.items.len(), 1); assert_eq!(bank_items.items.len(), 1);
bank_items.items[0].with_stacked(|items| { bank_items.items[0].with_stacked(|items| {
assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(), assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(),
@ -1121,7 +1127,7 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() {
} }
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![inventory_monomates])).await.unwrap(); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![inventory_monomates])).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -1154,7 +1160,7 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() {
if create_item.item_id == 0x10000 if create_item.item_id == 0x10000
)); ));
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert_eq!(bank_items.items.len(), 0); assert_eq!(bank_items.items.len(), 0);
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap(); let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
@ -1196,7 +1202,7 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() {
} }
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![inventory_monomates])).await.unwrap(); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![inventory_monomates])).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -1223,7 +1229,7 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() {
assert!(packets.is_err()); assert!(packets.is_err());
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert_eq!(bank_items.items.len(), 1); assert_eq!(bank_items.items.len(), 1);
bank_items.items[0].with_stacked(|items| { bank_items.items[0].with_stacked(|items| {
assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(), assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(),
@ -1276,7 +1282,7 @@ async fn test_withdraw_individual_item_in_full_inventory() {
} }
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(inventory)).await.unwrap(); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(inventory)).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -1302,7 +1308,7 @@ async fn test_withdraw_individual_item_in_full_inventory() {
})))).await; })))).await;
assert!(packets.is_err()); assert!(packets.is_err());
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert_eq!(bank_items.items.len(), 1); assert_eq!(bank_items.items.len(), 1);
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap(); let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
@ -1345,7 +1351,7 @@ async fn test_withdraw_stacked_item_in_full_inventory() {
} }
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(inventory)).await.unwrap(); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(inventory)).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), &item::BankName("".into())).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -1373,7 +1379,7 @@ async fn test_withdraw_stacked_item_in_full_inventory() {
assert!(packets.is_err()); assert!(packets.is_err());
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert_eq!(bank_items.items.len(), 1); assert_eq!(bank_items.items.len(), 1);
bank_items.items[0].with_stacked(|items| { bank_items.items[0].with_stacked(|items| {
assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(), assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(),
@ -1401,7 +1407,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() {
), ),
}).await.unwrap()); }).await.unwrap());
} }
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_item]), item::BankName("".into())).await.unwrap();
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_item]), &item::BankName("".into())).await.unwrap();
let mut items = Vec::new(); let mut items = Vec::new();
for _i in 0..29usize { for _i in 0..29usize {
@ -1458,7 +1464,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() {
unknown: 0, unknown: 0,
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let bank_items = entity_gateway.get_character_bank(&char1.id, item::BankName("".into())).await.unwrap();
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
assert!(bank_items.items.len() == 0); assert!(bank_items.items.len() == 0);
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap(); let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
@ -1476,7 +1482,7 @@ async fn test_withdraw_meseta() {
let mut entity_gateway = InMemoryGateway::default(); let mut entity_gateway = InMemoryGateway::default();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).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();
entity_gateway.set_bank_meseta(&char1.id, &item::BankName("".into()), item::Meseta(300)).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -1502,7 +1508,7 @@ async fn test_withdraw_meseta() {
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap(); let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, item::BankName("".into())).await.unwrap();
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap();
assert!(c1_meseta.0 == 23); assert!(c1_meseta.0 == 23);
assert!(c1_bank_meseta.0 == 277); assert!(c1_bank_meseta.0 == 277);
} }
@ -1513,7 +1519,7 @@ async fn test_withdraw_too_much_meseta() {
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).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_character_meseta(&char1.id, item::Meseta(999980)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(300)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, &item::BankName("".into()), item::Meseta(300)).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -1539,7 +1545,7 @@ async fn test_withdraw_too_much_meseta() {
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap(); let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, item::BankName("".into())).await.unwrap();
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap();
assert!(c1_meseta.0 == 999980); assert!(c1_meseta.0 == 999980);
assert!(c1_bank_meseta.0 == 300); assert!(c1_bank_meseta.0 == 300);
} }
@ -1550,7 +1556,7 @@ async fn test_withdraw_meseta_inventory_is_maxed() {
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).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_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, item::BankName("".into()), item::Meseta(300)).await.unwrap();
entity_gateway.set_bank_meseta(&char1.id, &item::BankName("".into()), item::Meseta(300)).await.unwrap();
let mut ship = Box::new(ShipServerState::builder() let mut ship = Box::new(ShipServerState::builder()
.gateway(entity_gateway.clone()) .gateway(entity_gateway.clone())
@ -1576,7 +1582,7 @@ async fn test_withdraw_meseta_inventory_is_maxed() {
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap(); let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, item::BankName("".into())).await.unwrap();
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap();
assert!(c1_meseta.0 == 999999); assert!(c1_meseta.0 == 999999);
assert!(c1_bank_meseta.0 == 300); assert!(c1_bank_meseta.0 == 300);
} }
Loading…
Cancel
Save