From 82ef5ba2ea299fa79043bd98c3911cea2569ed93 Mon Sep 17 00:00:00 2001 From: jake Date: Fri, 12 Nov 2021 10:42:33 -0700 Subject: [PATCH] RIP ItemLocation fun while it lasted ItemLocation ceased to be the canonical place to store an item's location. replaced with ItemNote which basically covers the actual use case but without the enforcing of a location. --- src/bin/main.rs | 60 +----------- src/entity/gateway/entitygateway.rs | 2 +- src/entity/gateway/inmemory.rs | 6 +- src/entity/gateway/postgres/models.rs | 115 ++++++++++++---------- src/entity/gateway/postgres/postgres.rs | 63 ++---------- src/entity/item/mod.rs | 36 +++---- src/login/character.rs | 83 +++++++++------- src/ship/items/bank.rs | 24 ++--- src/ship/items/inventory.rs | 8 +- src/ship/items/manager.rs | 121 ++++++++--------------- tests/test_bank.rs | 125 ------------------------ tests/test_item_actions.rs | 27 ----- tests/test_item_pickup.rs | 39 -------- tests/test_item_use.rs | 15 --- tests/test_mags.rs | 19 ---- tests/test_rooms.rs | 6 -- tests/test_shops.rs | 3 - 17 files changed, 182 insertions(+), 570 deletions(-) diff --git a/src/bin/main.rs b/src/bin/main.rs index a9ed329..8d8f549 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -9,7 +9,7 @@ use elseware::entity::account::{NewUserAccountEntity, NewUserSettingsEntity}; #[allow(unused_imports)] use elseware::entity::gateway::{EntityGateway, InMemoryGateway, PostgresGateway}; use elseware::entity::character::NewCharacterEntity; -use elseware::entity::item::{NewItemEntity, ItemDetail, ItemLocation}; +use elseware::entity::item::{NewItemEntity, ItemDetail}; use elseware::common::interserver::AuthToken; use elseware::entity::item; @@ -87,10 +87,6 @@ fn main() { tekked: true, } ), - location: item::ItemLocation::Bank { - character_id: character.id, - name: item::BankName("".to_string()) - } }).await.unwrap(); } @@ -102,10 +98,6 @@ fn main() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Bank { - character_id: character.id, - name: item::BankName("".to_string()) - } }).await.unwrap(); } @@ -122,9 +114,6 @@ fn main() { tekked: false, } ), - location: ItemLocation::Inventory { - character_id: character.id, - } }).await.unwrap(); let item1 = entity_gateway.create_item( NewItemEntity { @@ -139,9 +128,6 @@ fn main() { tekked: true, } ), - location: ItemLocation::Inventory { - character_id: character.id, - } }).await.unwrap(); let item2_w = entity_gateway.create_item( NewItemEntity { @@ -156,9 +142,6 @@ fn main() { tekked: true, } ), - location: ItemLocation::Inventory { - character_id: character.id, - } }).await.unwrap(); let item3 = entity_gateway.create_item( NewItemEntity { @@ -173,9 +156,6 @@ fn main() { tekked: true, } ), - location: ItemLocation::Inventory { - character_id: character.id, - } }).await.unwrap(); let item4 = entity_gateway.create_item( NewItemEntity { @@ -190,17 +170,11 @@ fn main() { tekked: true, } ), - location: ItemLocation::Inventory { - character_id: character.id, - } }).await.unwrap(); let item5_m = entity_gateway.create_item( item::NewItemEntity { item: item::ItemDetail::Mag(item::mag::Mag::baby_mag(0)), - location: item::ItemLocation::Inventory { - character_id: character.id, - } }).await.unwrap(); for _ in 0..10usize { @@ -211,9 +185,6 @@ fn main() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::FedToMag { - mag: item5_m.id, - } }).await.unwrap(); entity_gateway.feed_mag(&item5_m.id, &fed_tool.id).await.unwrap(); } @@ -226,9 +197,6 @@ fn main() { tool: item::tool::ToolType::CellOfMag502, } ), - location: item::ItemLocation::Inventory { - character_id: character.id, - } }).await.unwrap(); let cell = entity_gateway.create_item( item::NewItemEntity { @@ -237,7 +205,6 @@ fn main() { tool: item::tool::ToolType::CellOfMag502, } ), - location: item::ItemLocation::Consumed, }).await.unwrap(); entity_gateway.use_mag_cell(&item5_m.id, &cell.id).await.unwrap(); @@ -254,10 +221,6 @@ fn main() { tekked: false, } ), - location: ItemLocation::Bank { - character_id: character.id, - name: item::BankName("".to_string()), - } }).await.unwrap(); let item7_a = entity_gateway.create_item( NewItemEntity { @@ -269,9 +232,6 @@ fn main() { slots: 4, } ), - location: ItemLocation::Inventory { - character_id: character.id, - } } ).await.unwrap(); let item8_s = entity_gateway.create_item( @@ -283,9 +243,6 @@ fn main() { evp: 0, } ), - location: ItemLocation::Inventory { - character_id: character.id, - } } ).await.unwrap(); let item9_u0 = entity_gateway.create_item( @@ -296,9 +253,6 @@ fn main() { modifier: Some(item::unit::UnitModifier::Minus), } ), - location: ItemLocation::Inventory { - character_id: character.id, - } } ).await.unwrap(); let item10_u1 = entity_gateway.create_item( @@ -309,9 +263,6 @@ fn main() { modifier: Some(item::unit::UnitModifier::Minus), } ), - location: ItemLocation::Inventory { - character_id: character.id, - } } ).await.unwrap(); let item11_u2 = entity_gateway.create_item( @@ -322,9 +273,6 @@ fn main() { modifier: Some(item::unit::UnitModifier::Minus), } ), - location: ItemLocation::Inventory { - character_id: character.id, - } } ).await.unwrap(); let item12_u3 = entity_gateway.create_item( @@ -335,9 +283,6 @@ fn main() { modifier: Some(item::unit::UnitModifier::Minus), } ), - location: ItemLocation::Inventory { - character_id: character.id, - } } ).await.unwrap(); let item13 = entity_gateway.create_item( @@ -345,9 +290,6 @@ fn main() { item: ItemDetail::Mag( item::mag::Mag::baby_mag(5) ), - location: ItemLocation::Inventory { - character_id: character.id, - } } ).await.unwrap(); diff --git a/src/entity/gateway/entitygateway.rs b/src/entity/gateway/entitygateway.rs index 27cc5d5..46e13ed 100644 --- a/src/entity/gateway/entitygateway.rs +++ b/src/entity/gateway/entitygateway.rs @@ -65,7 +65,7 @@ pub trait EntityGateway: Send + Sync + Clone { unimplemented!(); } - async fn change_item_location(&mut self, _item_id: &ItemEntityId, _item_location: ItemLocation) -> Result<(), GatewayError> { + async fn add_item_note(&mut self, _item_id: &ItemEntityId, _item_note: ItemNote) -> Result<(), GatewayError> { unimplemented!(); } diff --git a/src/entity/gateway/inmemory.rs b/src/entity/gateway/inmemory.rs index 4a95b52..24b6500 100644 --- a/src/entity/gateway/inmemory.rs +++ b/src/entity/gateway/inmemory.rs @@ -223,17 +223,13 @@ impl EntityGateway for InMemoryGateway { + 1; let new_item = ItemEntity { id: ItemEntityId(id), - location: item.location, item: item.item, }; items.insert(ItemEntityId(id), new_item.clone()); Ok(new_item) } - async fn change_item_location(&mut self, item_id: &ItemEntityId, item_location: ItemLocation) -> Result<(), GatewayError> { - if let Some(item_entity) = self.items.lock().unwrap().get_mut(item_id) { - item_entity.location = item_location - } + async fn add_item_note(&mut self, item_id: &ItemEntityId, item_note: ItemNote) -> Result<(), GatewayError> { Ok(()) } diff --git a/src/entity/gateway/postgres/models.rs b/src/entity/gateway/postgres/models.rs index 917aca8..f57e39d 100644 --- a/src/entity/gateway/postgres/models.rs +++ b/src/entity/gateway/postgres/models.rs @@ -571,22 +571,21 @@ pub struct PgItem { #[derive(Debug, Serialize, Deserialize)] -pub enum PgItemLocationDetail { - Inventory { +pub enum PgItemNoteDetail { + CharacterCreation { character_id: u32, }, - Bank { - character_id: u32, - name: String, - }, - LocalFloor { + EnemyDrop { character_id: u32, map_area: MapArea, x: f32, y: f32, z: f32, }, - SharedFloor { + Pickup { + character_id: u32, + }, + PlayerDrop { map_area: MapArea, x: f32, y: f32, @@ -596,73 +595,80 @@ pub enum PgItemLocationDetail { FedToMag { mag: u32, }, - Shop, + BoughtAtShop { + character_id: u32, + }, + SoldToShop, Trade { - id: i32, - character_to: i32, - character_from: i32, - } + id: u32, + character_to: u32, + character_from: u32, + }, } -impl From for PgItemLocationDetail { - fn from(other: ItemLocation) -> PgItemLocationDetail { +impl From for PgItemNoteDetail { + fn from(other: ItemNote) -> PgItemNoteDetail { match other { - ItemLocation::Inventory{character_id} => PgItemLocationDetail::Inventory{ - character_id: character_id.0 - }, - ItemLocation::Bank{character_id, name} => PgItemLocationDetail::Bank{ + ItemNote::CharacterCreation{character_id} => PgItemNoteDetail::CharacterCreation { character_id: character_id.0, - name: name.0 }, - ItemLocation::LocalFloor{character_id, map_area, x,y,z} => PgItemLocationDetail::LocalFloor{ + ItemNote::EnemyDrop{character_id, map_area, x, y, z} => PgItemNoteDetail::EnemyDrop { character_id: character_id.0, map_area, - x,y,z + x,y,z, + }, + ItemNote::Pickup{character_id} => PgItemNoteDetail::Pickup { + character_id: character_id.0, }, - ItemLocation::SharedFloor{map_area, x,y,z} => PgItemLocationDetail::SharedFloor{ + ItemNote::PlayerDrop{map_area, x, y, z} => PgItemNoteDetail::PlayerDrop { map_area, - x,y,z + x,y,z, }, - ItemLocation::Consumed => PgItemLocationDetail::Consumed, - ItemLocation::FedToMag{mag} => PgItemLocationDetail::FedToMag{ + ItemNote::Consumed => PgItemNoteDetail::Consumed, + ItemNote::FedToMag{mag} => PgItemNoteDetail::FedToMag{ mag: mag.0 }, - ItemLocation::Shop => PgItemLocationDetail::Shop, - ItemLocation::Trade{id, character_to, character_from} => PgItemLocationDetail::Trade { - id: id.0 as i32, - character_to: character_to.0 as i32, - character_from: character_from.0 as i32, + ItemNote::BoughtAtShop{character_id} => PgItemNoteDetail::BoughtAtShop { + character_id: character_id.0, + }, + ItemNote::SoldToShop => PgItemNoteDetail::SoldToShop, + ItemNote::Trade{id, character_to, character_from} => PgItemNoteDetail::Trade { + id: id.0, + character_to: character_to.0, + character_from: character_from.0, } } } } -impl From for ItemLocation { - fn from(other: PgItemLocationDetail) -> ItemLocation { +impl From for ItemNote { + fn from(other: PgItemNoteDetail) -> ItemNote { match other { - PgItemLocationDetail::Inventory{character_id} => ItemLocation::Inventory{ - character_id: CharacterEntityId(character_id) - }, - PgItemLocationDetail::Bank{character_id, name} => ItemLocation::Bank{ - character_id: CharacterEntityId(character_id), - name: BankName(name) + PgItemNoteDetail::CharacterCreation{character_id} => ItemNote::CharacterCreation { + character_id: CharacterEntityId(character_id as u32), }, - PgItemLocationDetail::LocalFloor{character_id, map_area, x,y,z} => ItemLocation::LocalFloor{ - character_id: CharacterEntityId(character_id), + PgItemNoteDetail::EnemyDrop{character_id, map_area, x, y, z} => ItemNote::EnemyDrop { + character_id: CharacterEntityId(character_id as u32), map_area, - x,y,z + x,y,z, + }, + PgItemNoteDetail::Pickup{character_id} => ItemNote::Pickup { + character_id: CharacterEntityId(character_id as u32), }, - PgItemLocationDetail::SharedFloor{map_area, x,y,z} => ItemLocation::SharedFloor{ + PgItemNoteDetail::PlayerDrop{map_area, x, y, z} => ItemNote::PlayerDrop { map_area, - x,y,z + x,y,z, }, - PgItemLocationDetail::Consumed => ItemLocation::Consumed, - PgItemLocationDetail::FedToMag{mag} => ItemLocation::FedToMag{ + PgItemNoteDetail::Consumed => ItemNote::Consumed, + PgItemNoteDetail::FedToMag{mag} => ItemNote::FedToMag{ mag: ItemEntityId(mag) }, - PgItemLocationDetail::Shop => ItemLocation::Shop, - PgItemLocationDetail::Trade {id, character_to, character_from} => ItemLocation::Trade { - id: TradeId(id as usize), + PgItemNoteDetail::BoughtAtShop{character_id} => ItemNote::BoughtAtShop { + character_id: CharacterEntityId(character_id), + }, + PgItemNoteDetail::SoldToShop => ItemNote::SoldToShop, + PgItemNoteDetail::Trade {id, character_to, character_from} => ItemNote::Trade { + id: TradeId(id as u32), character_to: CharacterEntityId(character_to as u32), character_from: CharacterEntityId(character_from as u32), } @@ -672,9 +678,9 @@ impl From for ItemLocation { #[derive(Debug, sqlx::FromRow)] -pub struct PgItemLocation { +pub struct PgItemNote { //pub id: i32, - pub location: sqlx::types::Json, + pub note: sqlx::types::Json, created_at: chrono::DateTime, } @@ -723,19 +729,20 @@ pub struct PgItemEntity { pub item: sqlx::types::Json, } +/* #[derive(Debug, sqlx::FromRow)] pub struct PgItemWithLocation { pub id: i32, pub item: sqlx::types::Json, pub location: sqlx::types::Json, } +*/ -impl From for ItemEntity { - fn from(other: PgItemWithLocation) -> ItemEntity { +impl From for ItemEntity { + fn from(other: PgItemEntity) -> ItemEntity { ItemEntity { id: ItemEntityId(other.id as u32), item: other.item.0.into(), - location: other.location.0.into(), } } } diff --git a/src/entity/gateway/postgres/postgres.rs b/src/entity/gateway/postgres/postgres.rs index 4f872c4..3c17246 100644 --- a/src/entity/gateway/postgres/postgres.rs +++ b/src/entity/gateway/postgres/postgres.rs @@ -44,7 +44,7 @@ impl PostgresGateway { } async fn apply_item_modifications(&self, item: ItemEntity) -> ItemEntity { - let ItemEntity {id, item, location} = item; + let ItemEntity {id, item} = item; let item = match item { ItemDetail::Weapon(mut weapon) => { @@ -101,7 +101,6 @@ impl PostgresGateway { ItemEntity { id, item, - location } } } @@ -294,64 +293,18 @@ impl EntityGateway for PostgresGateway { let new_item = sqlx::query_as::<_, PgItem>("insert into item (item) values ($1) returning *;") .bind(sqlx::types::Json(PgItemDetail::from(item.item))) .fetch_one(&mut tx).await?; - let location = sqlx::query_as::<_, PgItemLocation>("insert into item_location (item, location) values ($1, $2) returning *") - .bind(new_item.id) - .bind(sqlx::types::Json(PgItemLocationDetail::from(item.location))) - .fetch_one(&mut tx).await?; tx.commit().await?; Ok(ItemEntity { id: ItemEntityId(new_item.id as u32), item: new_item.item.0.into(), - location: location.location.0.into(), }) - - /* - let mut tx = self.pool.begin().await?; - let new_item = sqlx::query_as::<_, PgItem>("insert into item (item) values ($1) returning *;") - .bind(sqlx::types::Json(PgItemDetail::from(item.item))) - .fetch_one(&mut tx).await?; - let location = if let ItemLocation::Inventory{slot, ..} = &item.location { - sqlx::query("insert into item_location (item, location) values ($1, $2)") - .bind(new_item.id) - .bind(sqlx::types::Json(PgItemLocationDetail::from(item.location.clone()))) - .execute(&mut tx).await?; - sqlx::query("insert into inventory_slot (item, slot) values ($1, $2)") - .bind(new_item.id) - .bind(*slot as i32) - .execute(&mut tx).await?; - sqlx::query_as::<_, PgItemLocation>(r#"select - item_location.item, - jsonb_set(item_location.location, '{Inventory,slot}', inventory_slot.slot::text::jsonb) as location, - item_location.created_at - from item_location - join item on item.id = item_location.item - join inventory_slot on inventory_slot.item = item.id - where item.id = $1 - order by item_location.created_at - limit 1"#) - .bind(new_item.id) - .fetch_one(&mut tx).await? - } - else { - sqlx::query_as::<_, PgItemLocation>("insert into item_location (item, location) values ($1, $2) returning *") - .bind(new_item.id) - .bind(sqlx::types::Json(PgItemLocationDetail::from(item.location))) - .fetch_one(&mut tx).await? - }; - tx.commit().await?; - Ok(ItemEntity { - id: ItemEntityId(new_item.id as u32), - item: new_item.item.0.into(), - location: location.location.0.into(), - }) - */ } - async fn change_item_location(&mut self, item_id: &ItemEntityId, item_location: ItemLocation) -> Result<(), GatewayError> { - sqlx::query("insert into item_location (item, location) values ($1, $2)") + async fn add_item_note(&mut self, item_id: &ItemEntityId, item_note: ItemNote) -> Result<(), GatewayError> { + sqlx::query("insert into item_note(item, note) values ($1, $2)") .bind(item_id.0) - .bind(sqlx::types::Json(PgItemLocationDetail::from(item_location))) + .bind(sqlx::types::Json(PgItemNoteDetail::from(item_note))) .execute(&self.pool).await?; Ok(()) @@ -465,7 +418,7 @@ impl EntityGateway for PostgresGateway { for inv_item in inventory.items.0.into_iter() { match inv_item { PgInventoryItemEntity::Individual(item) => { - let entity = sqlx::query_as::<_, PgItemWithLocation>("select item.id, item.item, item_location.location from item join item_location on item.id = item_location.item where id = $1") + let entity = sqlx::query_as::<_, PgItemEntity>("select item.id, item.item from item where id = $1") .bind(item) .fetch_one(&self.pool).await .map(|item| item.into()) @@ -476,7 +429,7 @@ impl EntityGateway for PostgresGateway { PgInventoryItemEntity::Stacked(items) => { let mut stacked_item = Vec::new(); for s_item in items { - stacked_item.push(sqlx::query_as::<_, PgItemWithLocation>("select item.id, item.item, item_location.location from item join item_location on item.id = item_location.item where id = $1") + stacked_item.push(sqlx::query_as::<_, PgItemEntity>("select item.id, item.item from item where id = $1") .bind(s_item) .fetch_one(&self.pool).await .map(|item| item.into()) @@ -501,7 +454,7 @@ impl EntityGateway for PostgresGateway { for bank_item in bank.items.0.into_iter() { match bank_item { PgInventoryItemEntity::Individual(item) => { - let entity = sqlx::query_as::<_, PgItemWithLocation>("select item.id, item.item, item_location.location from item join item_location on item.id = item_location.item where id = $1") + let entity = sqlx::query_as::<_, PgItemEntity>("select item.id, item.item from item where id = $1") .bind(item) .fetch_one(&self.pool).await .map(|item| item.into()) @@ -512,7 +465,7 @@ impl EntityGateway for PostgresGateway { PgInventoryItemEntity::Stacked(items) => { let mut stacked_item = Vec::new(); for s_item in items { - stacked_item.push(sqlx::query_as::<_, PgItemWithLocation>("select item.id, item.item, item_location.location from item join item_location on item.id = item_location.item where id = $1") + stacked_item.push(sqlx::query_as::<_, PgItemEntity>("select item.id, item.item from item where id = $1") .bind(s_item) .fetch_one(&self.pool).await .map(|item| item.into()) diff --git a/src/entity/item/mod.rs b/src/entity/item/mod.rs index b4260a3..5c320b6 100644 --- a/src/entity/item/mod.rs +++ b/src/entity/item/mod.rs @@ -19,24 +19,27 @@ pub struct ItemEntityId(pub u32); pub struct ItemId(u32); #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] pub struct BankName(pub String); +#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] +pub struct TradeId(pub u32); #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -pub enum ItemLocation { - Inventory { - character_id: CharacterEntityId, - }, - Bank { +pub enum ItemNote { + CharacterCreation { character_id: CharacterEntityId, - name: BankName, }, - LocalFloor { + EnemyDrop { character_id: CharacterEntityId, + //monster_type: MonsterType, + //droprate: f32, map_area: MapArea, x: f32, y: f32, z: f32, }, - SharedFloor { + Pickup { + character_id: CharacterEntityId, + }, + PlayerDrop { map_area: MapArea, x: f32, y: f32, @@ -46,20 +49,15 @@ pub enum ItemLocation { FedToMag { mag: ItemEntityId, }, - Shop, + BoughtAtShop { + character_id: CharacterEntityId, + }, + SoldToShop, Trade { - //id: TradeId, + id: TradeId, character_to: CharacterEntityId, character_from: CharacterEntityId, }, - /*Destroyed { - // marks an item that has been consumed in some way - }, - Transformed { - item_id, - change_event - } -*/ } #[derive(Debug, Clone, PartialEq)] @@ -168,14 +166,12 @@ impl ItemDetail { #[derive(Clone, Debug)] pub struct NewItemEntity { - pub location: ItemLocation, pub item: ItemDetail, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct ItemEntity { pub id: ItemEntityId, - pub location: ItemLocation, pub item: ItemDetail, } diff --git a/src/login/character.rs b/src/login/character.rs index 12e874a..b3afa67 100644 --- a/src/login/character.rs +++ b/src/login/character.rs @@ -20,7 +20,7 @@ use libpso::{utf8_to_array, utf8_to_utf16_array}; use crate::entity::gateway::{EntityGateway, GatewayError}; use crate::entity::account::{UserAccountId, UserAccountEntity, NewUserSettingsEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM}; -use crate::entity::item::{NewItemEntity, ItemDetail, ItemLocation, InventoryItemEntity, InventoryEntity, BankEntity, BankName, EquippedEntity}; +use crate::entity::item::{NewItemEntity, ItemDetail, ItemNote, InventoryItemEntity, InventoryEntity, BankEntity, BankName, EquippedEntity}; use crate::entity::item::weapon::Weapon; use crate::entity::item::armor::Armor; use crate::entity::item::tech::Technique; @@ -220,10 +220,11 @@ async fn new_character(entity_gateway: &mut EG, user: &UserAc special: None, attrs: [None; 3], tekked: true, - }), - location: ItemLocation::Inventory { - character_id: character.id, - }}).await?; + })}).await?; + + entity_gateway.add_item_note(&weapon.id, ItemNote::CharacterCreation { + character_id: character.id, + }).await?; let armor = entity_gateway.create_item( NewItemEntity { @@ -233,10 +234,11 @@ async fn new_character(entity_gateway: &mut EG, user: &UserAc dfp: 0, evp: 0, slots: 0, - }), - location: ItemLocation::Inventory { - character_id: character.id, - }}).await?; + })}).await?; + + entity_gateway.add_item_note(&armor.id, ItemNote::CharacterCreation { + character_id: character.id, + }).await?; let mut mag = { if character.char_class.is_android() { @@ -249,35 +251,40 @@ async fn new_character(entity_gateway: &mut EG, user: &UserAc let mag = entity_gateway.create_item( NewItemEntity { item: ItemDetail::Mag(mag), - location: ItemLocation::Inventory { - character_id: character.id, - }}).await?; - - let mut monomates = Vec::new(); - for _ in 0..4usize { - monomates.push(entity_gateway.create_item( - NewItemEntity { - item: ItemDetail::Tool ( - Tool { - tool: item::tool::ToolType::Monomate, - }), - location: ItemLocation::Inventory { - character_id: character.id, - }}).await?) - } - - let mut monofluids = Vec::new(); - for _ in 0..4usize { - monofluids.push(entity_gateway.create_item( - NewItemEntity { - item: ItemDetail::Tool ( - Tool { - tool: item::tool::ToolType::Monofluid, - }), - location: ItemLocation::Inventory { - character_id: character.id, - }}).await?) - } + }).await?; + + entity_gateway.add_item_note(&mag.id, ItemNote::CharacterCreation { + character_id: character.id, + }).await?; + + let (monomates, monofluids) = futures::future::join_all((0..4usize).map(|_| { + let mut eg = entity_gateway.clone(); + let character_id = character.id; + return async move { + let monomate = eg.create_item( + NewItemEntity { + item: ItemDetail::Tool ( + Tool { + tool: item::tool::ToolType::Monomate, + })}).await?; + + eg.add_item_note(&monomate.id, ItemNote::CharacterCreation { + character_id + }).await?; + + let monofluid = eg.create_item( + NewItemEntity { + item: ItemDetail::Tool ( + Tool { + tool: item::tool::ToolType::Monofluid, + })}).await?; + + eg.add_item_note(&monofluid.id, ItemNote::CharacterCreation { + character_id + }).await?; + + Ok((monomate, monofluid)) + }})).await.into_iter().collect::, GatewayError>>()?.into_iter().unzip(); let inventory = InventoryEntity { items: vec![InventoryItemEntity::Individual(weapon.clone()), InventoryItemEntity::Individual(armor.clone()), InventoryItemEntity::Individual(mag.clone()), diff --git a/src/ship/items/bank.rs b/src/ship/items/bank.rs index f3d5d10..b35a758 100644 --- a/src/ship/items/bank.rs +++ b/src/ship/items/bank.rs @@ -1,6 +1,6 @@ use crate::ship::items::ClientItemId; use libpso::character::character;//::InventoryItem; -use crate::entity::item::{ItemEntityId, ItemEntity, ItemDetail, ItemLocation, BankEntity, BankItemEntity, BankName}; +use crate::entity::item::{ItemEntityId, ItemEntity, ItemDetail, BankEntity, BankItemEntity, BankName}; use crate::entity::character::CharacterEntityId; use crate::entity::item::tool::Tool; use crate::ship::items::inventory::{InventoryItemHandle, InventoryItem}; @@ -301,26 +301,18 @@ impl CharacterBank { BankItem::Individual(item) => { BankItemEntity::Individual(ItemEntity { id: item.entity_id, - location: ItemLocation::Bank { - character_id: *character_id, - name: bank_name.clone(), - }, item: item.item.clone(), }) }, BankItem::Stacked(items) => { BankItemEntity::Stacked(items.entity_ids.iter() - .map(|id| { - ItemEntity { - id: *id, - location: ItemLocation::Bank { - character_id: *character_id, - name: bank_name.clone(), - }, - item: ItemDetail::Tool(items.tool) - } - }) - .collect()) + .map(|id| { + ItemEntity { + id: *id, + item: ItemDetail::Tool(items.tool) + } + }) + .collect()) }, } }) diff --git a/src/ship/items/inventory.rs b/src/ship/items/inventory.rs index 314eeab..c949d74 100644 --- a/src/ship/items/inventory.rs +++ b/src/ship/items/inventory.rs @@ -2,7 +2,7 @@ use std::cmp::Ordering; use thiserror::Error; use libpso::character::character;//::InventoryItem; use crate::entity::character::CharacterEntityId; -use crate::entity::item::{ItemEntityId, ItemDetail, ItemEntity, ItemType, ItemLocation, InventoryEntity, InventoryItemEntity, EquippedEntity}; +use crate::entity::item::{ItemEntityId, ItemDetail, ItemEntity, ItemType, InventoryEntity, InventoryItemEntity, EquippedEntity}; use crate::entity::item::tool::Tool; use crate::entity::item::mag::Mag; use crate::entity::item::weapon::Weapon; @@ -815,9 +815,6 @@ impl CharacterInventory { InventoryItem::Individual(item) => { InventoryItemEntity::Individual(ItemEntity { id: item.entity_id, - location: ItemLocation::Inventory { - character_id: *character_id, - }, item: item.item.clone(), }) }, @@ -826,9 +823,6 @@ impl CharacterInventory { .map(|id| { ItemEntity { id: *id, - location: ItemLocation::Inventory { - character_id: *character_id, - }, item: ItemDetail::Tool(items.tool) } }) diff --git a/src/ship/items/manager.rs b/src/ship/items/manager.rs index 773819c..701a4aa 100644 --- a/src/ship/items/manager.rs +++ b/src/ship/items/manager.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use thiserror::Error; use crate::entity::gateway::{EntityGateway, GatewayError}; use crate::entity::character::{CharacterEntity, CharacterEntityId, TechLevel}; -use crate::entity::item::{ItemDetail, ItemLocation, BankName}; +use crate::entity::item::{ItemDetail, ItemNote, BankName}; use crate::entity::item::{Meseta, NewItemEntity, ItemEntity, ItemEntityId, InventoryItemEntity, BankItemEntity}; use crate::entity::item::tool::{Tool, ToolType}; use crate::entity::item::weapon; @@ -366,13 +366,13 @@ impl ItemManager { ItemOrMeseta::Individual(item_detail) => { let entity = entity_gateway.create_item(NewItemEntity { item: item_detail.clone(), - location: ItemLocation::LocalFloor { - character_id: character.id, - map_area: item_drop.map_area, - x: item_drop.x, - y: item_drop.y, - z: item_drop.z, - } + }).await?; + entity_gateway.add_item_note(&entity.id, ItemNote::EnemyDrop { + character_id: character.id, + map_area: item_drop.map_area, + x: item_drop.x, + y: item_drop.y, + z: item_drop.z, }).await?; FloorItem::Individual(IndividualFloorItem { entity_id: entity.id, @@ -387,13 +387,13 @@ impl ItemManager { ItemOrMeseta::Stacked(tool) => { let entity = entity_gateway.create_item(NewItemEntity { item: ItemDetail::Tool(tool), - location: ItemLocation::LocalFloor { - character_id: character.id, - map_area: item_drop.map_area, - x: item_drop.x, - y: item_drop.y, - z: item_drop.z, - } + }).await?; + entity_gateway.add_item_note(&entity.id, ItemNote::EnemyDrop { + character_id: character.id, + map_area: item_drop.map_area, + x: item_drop.x, + y: item_drop.y, + z: item_drop.z, }).await?; FloorItem::Stacked(StackedFloorItem { entity_ids: vec![entity.id], @@ -438,9 +438,9 @@ impl ItemManager { match dropped_inventory_item { InventoryItem::Individual(individual_inventory_item) => { let individual_floor_item = shared_floor.drop_individual_inventory_item(individual_inventory_item, item_drop_location); - entity_gateway.change_item_location( + entity_gateway.add_item_note( &individual_floor_item.entity_id, - ItemLocation::SharedFloor { + ItemNote::PlayerDrop { map_area: item_drop_location.0, x: item_drop_location.1, y: item_drop_location.2, @@ -451,9 +451,9 @@ impl ItemManager { InventoryItem::Stacked(stacked_inventory_item) => { let stacked_floor_item = shared_floor.drop_stacked_inventory_item(stacked_inventory_item, item_drop_location); for entity_id in &stacked_floor_item.entity_ids { - entity_gateway.change_item_location( + entity_gateway.add_item_note( entity_id, - ItemLocation::SharedFloor { + ItemNote::PlayerDrop { map_area: item_drop_location.0, x: item_drop_location.1, y: item_drop_location.2, @@ -515,9 +515,9 @@ impl ItemManager { .ok_or(ItemManagerError::CouldNotSplitItem(item_id))?; for entity_id in &stacked_floor_item.entity_ids { - entity_gateway.change_item_location( + entity_gateway.add_item_note( entity_id, - ItemLocation::SharedFloor { + ItemNote::PlayerDrop { map_area: drop_location.map_area, x: drop_location.x, y: 0.0, @@ -547,8 +547,8 @@ impl ItemManager { }; for entity_id in consumed_item.entity_ids() { - entity_gateway.change_item_location(&entity_id, - ItemLocation::Consumed).await?; + entity_gateway.add_item_note(&entity_id, + ItemNote::Consumed).await?; } entity_gateway.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?; @@ -569,25 +569,6 @@ impl ItemManager { let item_to_deposit = inventory.get_item_handle_by_id(item_id).ok_or(ItemManagerError::NoSuchItemId(item_id))?; let bank_item = bank.deposit_item(item_to_deposit, amount).ok_or(ItemManagerError::Idunnoman)?; - match bank_item { - BankItem::Individual(individual_bank_item) => { - entity_gateway.change_item_location(&individual_bank_item.entity_id, - ItemLocation::Bank { - character_id: character.id, - name: BankName("".to_string()) - }).await?; - }, - BankItem::Stacked(stacked_bank_item) => { - for entity_id in &stacked_bank_item.entity_ids { - entity_gateway.change_item_location(entity_id, - ItemLocation::Bank { - character_id: character.id, - name: BankName("".to_string()) - }).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?; Ok(()) @@ -608,23 +589,6 @@ impl ItemManager { let item_to_withdraw = bank.get_item_handle_by_id(item_id).ok_or(ItemManagerError::NoSuchItemId(item_id))?; let inventory_item_slot = { let inventory_item = inventory.withdraw_item(item_to_withdraw, amount).ok_or(ItemManagerError::Idunnoman)?; - - match inventory_item { - (InventoryItem::Individual(individual_inventory_item), _slot) => { - entity_gateway.change_item_location(&individual_inventory_item.entity_id, - ItemLocation::Inventory { - character_id: character.id, - }).await?; - }, - (InventoryItem::Stacked(stacked_inventory_item), _slot) => { - for entity_id in &stacked_inventory_item.entity_ids { - entity_gateway.change_item_location(entity_id, - ItemLocation::Inventory { - character_id: character.id, - }).await?; - } - } - } inventory_item.1 }; @@ -662,7 +626,7 @@ impl ItemManager { for entity_id in consumed_tool.entity_ids() { entity_gateway.feed_mag(&individual_item.entity_id, &entity_id).await?; - entity_gateway.change_item_location(&entity_id, ItemLocation::FedToMag { + entity_gateway.add_item_note(&entity_id, ItemNote::FedToMag { mag: individual_item.entity_id, }).await?; } @@ -800,10 +764,13 @@ impl ItemManager { if tool.is_stackable() { let mut item_entities = Vec::new(); for _ in 0..amount { - item_entities.push(entity_gateway.create_item(NewItemEntity { - location: ItemLocation::Shop, + let item_entity = entity_gateway.create_item(NewItemEntity { item: ItemDetail::Tool(tool), - }).await?); + }).await?; + entity_gateway.add_item_note(&item_entity.id, ItemNote::BoughtAtShop { + character_id: character.id, + }).await?; + item_entities.push(item_entity); } let floor_item = StackedFloorItem { entity_ids: item_entities.into_iter().map(|i| i.id).collect(), @@ -817,21 +784,18 @@ impl ItemManager { }; let item_id = { let (picked_up_item, _slot) = inventory.pick_up_stacked_floor_item(&floor_item).ok_or(ItemManagerError::CouldNotAddBoughtItemToInventory)?; - for entity_id in &picked_up_item.entity_ids { - entity_gateway.change_item_location(entity_id, - ItemLocation::Inventory { - character_id: character.id, - }).await?; - } picked_up_item.item_id }; inventory.get_item_by_id(item_id).ok_or(ItemManagerError::ItemIdNotInInventory(item_id))? } else { let item_entity = entity_gateway.create_item(NewItemEntity { - location: ItemLocation::Shop, item: ItemDetail::Tool(tool), }).await?; + entity_gateway.add_item_note(&item_entity.id, ItemNote::BoughtAtShop { + character_id: character.id, + }).await?; + let floor_item = IndividualFloorItem { entity_id: item_entity.id, item_id, @@ -844,10 +808,6 @@ impl ItemManager { }; let item_id = { let (picked_up_item, _slot) = inventory.pick_up_individual_floor_item(&floor_item).ok_or(ItemManagerError::CouldNotAddBoughtItemToInventory)?; - entity_gateway.change_item_location(&picked_up_item.entity_id, - ItemLocation::Inventory { - character_id: character.id, - }).await?; picked_up_item.item_id }; inventory.get_item_by_id(item_id).ok_or(ItemManagerError::ItemIdNotInInventory(item_id))? @@ -855,9 +815,11 @@ impl ItemManager { }, item_detail => { let item_entity = entity_gateway.create_item(NewItemEntity { - location: ItemLocation::Shop, item: item_detail.clone(), }).await?; + entity_gateway.add_item_note(&item_entity.id, ItemNote::BoughtAtShop { + character_id: character.id, + }).await?; let floor_item = IndividualFloorItem { entity_id: item_entity.id, item_id, @@ -870,10 +832,6 @@ impl ItemManager { }; let item_id = { let (picked_up_item, _slot) = inventory.pick_up_individual_floor_item(&floor_item).ok_or(ItemManagerError::CouldNotAddBoughtItemToInventory)?; - entity_gateway.change_item_location(&picked_up_item.entity_id, - ItemLocation::Inventory { - character_id: character.id, - }).await?; picked_up_item.item_id }; inventory.get_item_by_id(item_id).ok_or(ItemManagerError::ItemIdNotInInventory(item_id))? @@ -1121,9 +1079,10 @@ impl ItemAction for AddIndividualFloorItemToInventory { let inventory = item_manager.character_inventory.get_mut(&self.character.id).ok_or(ItemManagerError::NoCharacter(self.character.id))?; let inv_item = inventory.add_individual_floor_item(&self.item); - entity_gateway.change_item_location( + + entity_gateway.add_item_note( &self.item.entity_id, - ItemLocation::Inventory { + ItemNote::Pickup { character_id: self.character.id, } ).await?; diff --git a/tests/test_bank.rs b/tests/test_bank.rs index c0a1d64..e55d153 100644 --- a/tests/test_bank.rs +++ b/tests/test_bank.rs @@ -29,10 +29,6 @@ async fn test_bank_items_sent_in_character_login() { tekked: true, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap(); entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![item]), item::BankName("".into())).await.unwrap(); @@ -70,10 +66,6 @@ async fn test_request_bank_items() { tekked: true, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap()); } @@ -118,10 +110,6 @@ async fn test_request_stacked_bank_items() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap()); } @@ -167,10 +155,6 @@ async fn test_request_bank_items_sorted() { tekked: true, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap(); let monomate = entity_gateway.create_item( item::NewItemEntity { @@ -179,10 +163,6 @@ async fn test_request_bank_items_sorted() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap(); let item2 = entity_gateway.create_item( item::NewItemEntity { @@ -195,10 +175,6 @@ async fn test_request_bank_items_sorted() { tekked: true, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap(); let bank = vec![item::BankItemEntity::Individual(item1), vec![monomate].into(), item2.into()]; @@ -245,9 +221,6 @@ async fn test_deposit_individual_item() { tekked: true, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap(); let item1 = entity_gateway.create_item( item::NewItemEntity { @@ -260,9 +233,6 @@ async fn test_deposit_individual_item() { tekked: true, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap(); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![item0, item1])).await.unwrap(); @@ -322,9 +292,6 @@ async fn test_deposit_stacked_item() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } @@ -386,9 +353,6 @@ async fn test_deposit_partial_stacked_item() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } @@ -460,9 +424,6 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); bank_monomates.push(entity_gateway.create_item( @@ -472,10 +433,6 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".into()), - } }).await.unwrap()); } @@ -537,9 +494,6 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } @@ -552,10 +506,6 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".into()), - } }).await.unwrap()); } @@ -619,9 +569,6 @@ async fn test_deposit_individual_item_in_full_bank() { tekked: true, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); let mut bank = Vec::new(); @@ -637,10 +584,6 @@ async fn test_deposit_individual_item_in_full_bank() { tekked: true, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap()); } @@ -697,9 +640,6 @@ async fn test_deposit_stacked_item_in_full_bank() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } @@ -716,10 +656,6 @@ async fn test_deposit_stacked_item_in_full_bank() { tekked: true, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap()); } @@ -777,9 +713,6 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } @@ -792,10 +725,6 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap()); } @@ -812,10 +741,6 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() { tekked: true, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap().into()); } almost_full_bank.push(bank_monomates.into()); @@ -990,10 +915,6 @@ async fn test_withdraw_individual_item() { tekked: true, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap()); entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), item::BankName("".into())).await.unwrap(); @@ -1053,10 +974,6 @@ async fn test_withdraw_stacked_item() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap()); } @@ -1117,10 +1034,6 @@ async fn test_withdraw_partial_stacked_item() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".into()) - } }).await.unwrap()); } entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), item::BankName("".into())).await.unwrap(); @@ -1188,9 +1101,6 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); bank_monomates.push(entity_gateway.create_item( @@ -1200,10 +1110,6 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".into()), - } }).await.unwrap()); } @@ -1267,10 +1173,6 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".into()), - } }).await.unwrap()); } @@ -1283,9 +1185,6 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } @@ -1349,10 +1248,6 @@ async fn test_withdraw_individual_item_in_full_inventory() { tekked: true, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap()); let mut inventory = Vec::new(); @@ -1368,9 +1263,6 @@ async fn test_withdraw_individual_item_in_full_inventory() { tekked: true, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } @@ -1423,10 +1315,6 @@ async fn test_withdraw_stacked_item_in_full_inventory() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap()); } @@ -1443,9 +1331,6 @@ async fn test_withdraw_stacked_item_in_full_inventory() { tekked: true, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } @@ -1504,10 +1389,6 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Bank { - character_id: char1.id, - name: item::BankName("".to_string()) - } }).await.unwrap()); } entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_item]), item::BankName("".into())).await.unwrap(); @@ -1525,9 +1406,6 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() { tekked: true, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap().into()); } @@ -1540,9 +1418,6 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } items.push(item::InventoryItemEntity::Stacked(item29)); diff --git a/tests/test_item_actions.rs b/tests/test_item_actions.rs index fa27041..456a505 100644 --- a/tests/test_item_actions.rs +++ b/tests/test_item_actions.rs @@ -26,9 +26,6 @@ async fn test_equip_unit_from_equip_menu() { evp: 0, slots: 4, }), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); p1_inv.push(entity_gateway.create_item( @@ -38,9 +35,6 @@ async fn test_equip_unit_from_equip_menu() { unit: item::unit::UnitType::KnightPower, modifier: None, }), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); p1_inv.push(entity_gateway.create_item( @@ -50,9 +44,6 @@ async fn test_equip_unit_from_equip_menu() { unit: item::unit::UnitType::KnightPower, modifier: Some(item::unit::UnitModifier::Plus), }), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); let equipped = item::EquippedEntity { @@ -112,9 +103,6 @@ async fn test_unequip_armor_with_units() { evp: 0, slots: 4, }), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); p1_inv.push(entity_gateway.create_item( @@ -124,9 +112,6 @@ async fn test_unequip_armor_with_units() { unit: item::unit::UnitType::KnightPower, modifier: None, }), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); p1_inv.push(entity_gateway.create_item( @@ -136,9 +121,6 @@ async fn test_unequip_armor_with_units() { unit: item::unit::UnitType::KnightPower, modifier: Some(item::unit::UnitModifier::Plus), }), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); let equipped = item::EquippedEntity { @@ -189,9 +171,6 @@ async fn test_sort_items() { evp: 0, slots: 4, }), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); p1_inv.push(entity_gateway.create_item( @@ -201,9 +180,6 @@ async fn test_sort_items() { unit: item::unit::UnitType::KnightPower, modifier: None, }), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); p1_inv.push(entity_gateway.create_item( @@ -213,9 +189,6 @@ async fn test_sort_items() { unit: item::unit::UnitType::KnightPower, modifier: Some(item::unit::UnitModifier::Plus), }), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(p1_inv)).await.unwrap(); diff --git a/tests/test_item_pickup.rs b/tests/test_item_pickup.rs index e1600d8..d5287d0 100644 --- a/tests/test_item_pickup.rs +++ b/tests/test_item_pickup.rs @@ -29,9 +29,6 @@ async fn test_pick_up_individual_item() { tekked: true, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(p1_inv)).await.unwrap(); @@ -99,9 +96,6 @@ async fn test_pick_up_item_stack_of_items_already_in_inventory() { tool: item::tool::ToolType::Monomate } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); let mut p2_items = Vec::new(); @@ -115,9 +109,6 @@ async fn test_pick_up_item_stack_of_items_already_in_inventory() { tool: tool } ), - location: item::ItemLocation::Inventory { - character_id: char2.id, - } }).await.unwrap()); } p2_items.push(item); @@ -181,9 +172,6 @@ async fn test_pick_up_item_stack_of_items_not_already_held() { tool: item::tool::ToolType::Monomate } ), - location: item::ItemLocation::Inventory { - character_id: char2.id, - } }).await.unwrap()); entity_gateway.set_character_inventory(&char2.id, &item::InventoryEntity::new(vec![p2_monomate])).await.unwrap(); @@ -248,9 +236,6 @@ async fn test_pick_up_meseta_when_inventory_full() { tekked: true, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } @@ -327,9 +312,6 @@ async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() { tekked: true, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap().into()); } @@ -340,9 +322,6 @@ async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()])); let mut p2_monomates = Vec::new(); @@ -353,9 +332,6 @@ async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char2.id, - } }).await.unwrap()); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(p1_inv)).await.unwrap(); @@ -419,9 +395,6 @@ async fn test_can_not_pick_up_item_when_inventory_full() { tekked: true, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } @@ -437,9 +410,6 @@ async fn test_can_not_pick_up_item_when_inventory_full() { tekked: true, } ), - location: item::ItemLocation::Inventory { - character_id: char2.id, - } }).await.unwrap()); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(p1_inv)).await.unwrap(); @@ -552,9 +522,6 @@ async fn test_pick_up_stack_that_would_exceed_stack_limit() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } @@ -567,9 +534,6 @@ async fn test_pick_up_stack_that_would_exceed_stack_limit() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char2.id, - } }).await.unwrap()); } entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![p1_monomates])).await.unwrap(); @@ -747,9 +711,6 @@ async fn test_player_drops_partial_stack_and_other_player_picks_it_up() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } diff --git a/tests/test_item_use.rs b/tests/test_item_use.rs index ba28e19..45c9f3e 100644 --- a/tests/test_item_use.rs +++ b/tests/test_item_use.rs @@ -29,9 +29,6 @@ async fn test_use_monomate() { tool: tool } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } p1_items.push(item::InventoryItemEntity::Stacked(item)); @@ -79,9 +76,6 @@ async fn test_use_monomate_twice() { tool: tool } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } p1_items.push(item::InventoryItemEntity::Stacked(item)); @@ -132,9 +126,6 @@ async fn test_use_last_monomate() { tool: tool } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()])); } @@ -176,9 +167,6 @@ async fn test_use_nonstackable_tool() { tool: item::tool::ToolType::MagicStoneIritista, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(p1_items)).await.unwrap(); @@ -217,9 +205,6 @@ async fn test_use_materials() { tool: tool } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } p1_inv.push(item::InventoryItemEntity::Stacked(item)); diff --git a/tests/test_mags.rs b/tests/test_mags.rs index 268833d..9886215 100644 --- a/tests/test_mags.rs +++ b/tests/test_mags.rs @@ -22,10 +22,6 @@ async fn test_mag_feed() { item: item::ItemDetail::Mag( item::mag::Mag::baby_mag(0) ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - //equipped: true, - } }).await.unwrap(); let mut monomates = Vec::new(); @@ -37,9 +33,6 @@ async fn test_mag_feed() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } @@ -108,9 +101,6 @@ async fn test_mag_change_owner() { item: item::ItemDetail::Mag( item::mag::Mag::baby_mag(0) ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap(); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![mag])).await.unwrap(); @@ -169,9 +159,6 @@ async fn test_mag_cell() { item: item::ItemDetail::Mag( item::mag::Mag::baby_mag(0) ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap(); for _ in 0..1000usize { @@ -182,9 +169,6 @@ async fn test_mag_cell() { tool: item::tool::ToolType::Monomate, } ), - location: item::ItemLocation::FedToMag { - mag: mag.id, - } }).await.unwrap(); entity_gateway.feed_mag(&mag.id, &fed_tool.id).await.unwrap(); } @@ -195,9 +179,6 @@ async fn test_mag_cell() { tool: item::tool::ToolType::CellOfMag502, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap(); let equipped = item::EquippedEntity { diff --git a/tests/test_rooms.rs b/tests/test_rooms.rs index 45f8ace..91e8963 100644 --- a/tests/test_rooms.rs +++ b/tests/test_rooms.rs @@ -31,9 +31,6 @@ async fn test_item_ids_reset_when_rejoining_rooms() { tekked: true, } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap()); } @@ -50,9 +47,6 @@ async fn test_item_ids_reset_when_rejoining_rooms() { tekked: true, } ), - location: item::ItemLocation::Inventory { - character_id: char2.id, - } }).await.unwrap()); } diff --git a/tests/test_shops.rs b/tests/test_shops.rs index ade8ccf..78e2e38 100644 --- a/tests/test_shops.rs +++ b/tests/test_shops.rs @@ -321,9 +321,6 @@ async fn test_other_clients_see_stacked_purchase() { tool: item::tool::ToolType::Monomate } ), - location: item::ItemLocation::Inventory { - character_id: char1.id, - } }).await.unwrap(); let mut ship = Box::new(ShipServerState::builder()