Browse Source

get_items_by_character takes character id not character entity

pbs
jake 4 years ago
parent
commit
cae89cd2ac
  1. 2
      src/entity/gateway/entitygateway.rs
  2. 6
      src/entity/gateway/inmemory.rs
  3. 4
      src/entity/gateway/postgres/postgres.rs
  4. 2
      src/ship/items/manager.rs
  5. 32
      tests/test_bank.rs
  6. 22
      tests/test_item_pickup.rs
  7. 10
      tests/test_item_use.rs
  8. 6
      tests/test_mags.rs
  9. 16
      tests/test_shops.rs

2
src/entity/gateway/entitygateway.rs

@ -85,7 +85,7 @@ pub trait EntityGateway: Send + Sync + Clone {
unimplemented!(); unimplemented!();
} }
async fn get_items_by_character(&self, _char: &CharacterEntity) -> Result<Vec<ItemEntity>, GatewayError> {
async fn get_items_by_character(&self, _char_id: &CharacterEntityId) -> Result<Vec<ItemEntity>, GatewayError> {
unimplemented!(); unimplemented!();
} }
} }

6
src/entity/gateway/inmemory.rs

@ -205,14 +205,14 @@ impl EntityGateway for InMemoryGateway {
Ok(()) Ok(())
} }
async fn get_items_by_character(&self, character: &CharacterEntity) -> Result<Vec<ItemEntity>, GatewayError> {
async fn get_items_by_character(&self, character_id: &CharacterEntityId) -> Result<Vec<ItemEntity>, GatewayError> {
let items = self.items.lock().unwrap(); let items = self.items.lock().unwrap();
Ok(items Ok(items
.iter() .iter()
.filter(|(_, k)| { .filter(|(_, k)| {
match k.location { match k.location {
ItemLocation::Inventory{character_id, ..} => character_id == character.id,
ItemLocation::Bank{character_id, ..} => character_id == character.id,
ItemLocation::Inventory{character_id, ..} => character_id == character_id,
ItemLocation::Bank{character_id, ..} => character_id == character_id,
_ => false _ => false
} }
}) })

4
src/entity/gateway/postgres/postgres.rs

@ -364,7 +364,7 @@ impl EntityGateway for PostgresGateway {
Ok(()) Ok(())
} }
async fn get_items_by_character(&self, char: &CharacterEntity) -> Result<Vec<ItemEntity>, GatewayError> {
async fn get_items_by_character(&self, char_id: &CharacterEntityId) -> Result<Vec<ItemEntity>, GatewayError> {
let q = r#"select * from ( let q = r#"select * from (
select distinct on (item_location.item) select distinct on (item_location.item)
item.id, item.id,
@ -384,7 +384,7 @@ impl EntityGateway for PostgresGateway {
or cast (location -> 'Bank' ->> 'character_id' as integer) = $1 or cast (location -> 'Bank' ->> 'character_id' as integer) = $1
"#; "#;
let items = sqlx::query_as::<_, PgItemWithLocation>(q) let items = sqlx::query_as::<_, PgItemWithLocation>(q)
.bind(char.id.0)
.bind(char_id.0)
.fetch(&self.pool); .fetch(&self.pool);
Ok(join_all(items Ok(join_all(items
.filter_map(|item: Result<PgItemWithLocation, _>| { .filter_map(|item: Result<PgItemWithLocation, _>| {

2
src/ship/items/manager.rs

@ -116,7 +116,7 @@ impl ItemManager {
// TODO: Result // TODO: Result
pub async fn load_character<EG: EntityGateway>(&mut self, entity_gateway: &mut EG, character: &CharacterEntity) -> Result<(), ItemManagerError> { pub async fn load_character<EG: EntityGateway>(&mut self, entity_gateway: &mut EG, character: &CharacterEntity) -> Result<(), ItemManagerError> {
let items = entity_gateway.get_items_by_character(&character).await?;
let items = entity_gateway.get_items_by_character(&character.id).await?;
let inventory_items = items.clone().into_iter() let inventory_items = items.clone().into_iter()
.filter_map(|item| { .filter_map(|item| {
match item.location { match item.location {

32
tests/test_bank.rs

@ -295,7 +295,7 @@ async fn test_deposit_individual_item() {
&& player_no_longer_has_item.amount == 0 && player_no_longer_has_item.amount == 0
)); ));
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let bank_item_ids = items.iter() let bank_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location { if let item::ItemLocation::Bank {..} = item.location {
@ -364,7 +364,7 @@ async fn test_deposit_stacked_item() {
&& player_no_longer_has_item.amount == 3 && player_no_longer_has_item.amount == 3
)); ));
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let bank_item_ids = items.iter() let bank_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location { if let item::ItemLocation::Bank {..} = item.location {
@ -433,7 +433,7 @@ async fn test_deposit_partial_stacked_item() {
&& player_no_longer_has_item.amount == 2 && player_no_longer_has_item.amount == 2
)); ));
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let bank_item_ids = items.iter() let bank_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location { if let item::ItemLocation::Bank {..} = item.location {
@ -528,7 +528,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 items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let bank_item_ids = items.iter() let bank_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location { if let item::ItemLocation::Bank {..} = item.location {
@ -604,7 +604,7 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() {
assert!(packets.is_err()); assert!(packets.is_err());
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let bank_item_ids = items.iter() let bank_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location { if let item::ItemLocation::Bank {..} = item.location {
@ -700,7 +700,7 @@ async fn test_deposit_individual_item_in_full_bank() {
assert!(packets.is_err()); assert!(packets.is_err());
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let bank_item_ids = items.iter() let bank_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location { if let item::ItemLocation::Bank {..} = item.location {
@ -793,7 +793,7 @@ async fn test_deposit_stacked_item_in_full_bank() {
assert!(packets.is_err()); assert!(packets.is_err());
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let bank_item_ids = items.iter() let bank_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location { if let item::ItemLocation::Bank {..} = item.location {
@ -899,7 +899,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 items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let bank_item_ids = items.iter() let bank_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location { if let item::ItemLocation::Bank {..} = item.location {
@ -1096,7 +1096,7 @@ async fn test_withdraw_individual_item() {
if create_item.item_id == 0x20000 if create_item.item_id == 0x20000
)); ));
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let inventory_item_ids = items.iter() let inventory_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Inventory{..} = item.location { if let item::ItemLocation::Inventory{..} = item.location {
@ -1163,7 +1163,7 @@ async fn test_withdraw_stacked_item() {
if create_item.item_id == 0x10002 if create_item.item_id == 0x10002
)); ));
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let inventory_item_ids = items.iter() let inventory_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Inventory {..} = item.location { if let item::ItemLocation::Inventory {..} = item.location {
@ -1230,7 +1230,7 @@ async fn test_withdraw_partial_stacked_item() {
if create_item.item_id == 0x10002 if create_item.item_id == 0x10002
)); ));
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let bank_item_ids = items.iter() let bank_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location { if let item::ItemLocation::Bank {..} = item.location {
@ -1323,7 +1323,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 items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let inventory_item_ids = items.iter() let inventory_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Inventory {..} = item.location { if let item::ItemLocation::Inventory {..} = item.location {
@ -1399,7 +1399,7 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() {
assert!(packets.is_err()); assert!(packets.is_err());
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let bank_item_ids = items.iter() let bank_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location { if let item::ItemLocation::Bank {..} = item.location {
@ -1495,7 +1495,7 @@ async fn test_withdraw_individual_item_in_full_inventory() {
assert!(packets.is_err()); assert!(packets.is_err());
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let bank_item_ids = items.iter() let bank_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location { if let item::ItemLocation::Bank {..} = item.location {
@ -1588,7 +1588,7 @@ async fn test_withdraw_stacked_item_in_full_inventory() {
assert!(packets.is_err()); assert!(packets.is_err());
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let bank_item_ids = items.iter() let bank_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location { if let item::ItemLocation::Bank {..} = item.location {
@ -1695,7 +1695,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 items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let bank_item_ids = items.iter() let bank_item_ids = items.iter()
.filter_map(|item| { .filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location { if let item::ItemLocation::Bank {..} = item.location {

22
tests/test_item_pickup.rs

@ -80,7 +80,7 @@ async fn test_pick_up_item_stack_of_items_already_in_inventory() {
unknown: [0; 3] unknown: [0; 3]
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(p1_items.len() == 6); assert!(p1_items.len() == 6);
let p1_item_ids = p1_items.iter().map(|item| { let p1_item_ids = p1_items.iter().map(|item| {
@ -149,7 +149,7 @@ async fn test_pick_up_item_stack_of_items_not_already_held() {
unknown: [0; 3] unknown: [0; 3]
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(p1_items.len() == 1); assert!(p1_items.len() == 1);
let first_item = p1_items.get(0).unwrap(); let first_item = p1_items.get(0).unwrap();
@ -227,7 +227,7 @@ async fn test_pick_up_meseta_when_inventory_full() {
unknown: [0; 3] unknown: [0; 3]
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(p1_items.len() == 30); assert!(p1_items.len() == 30);
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap(); let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
@ -324,7 +324,7 @@ async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() {
unknown: [0; 3] unknown: [0; 3]
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(p1_items.len() == 31); assert!(p1_items.len() == 31);
let monomate1 = p1_items.get(29).unwrap(); let monomate1 = p1_items.get(29).unwrap();
@ -415,10 +415,10 @@ async fn test_can_not_pick_up_item_when_inventory_full() {
unknown: [0; 3] unknown: [0; 3]
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(p1_items.len() == 30); assert!(p1_items.len() == 30);
let p2_items = entity_gateway.get_items_by_character(&char2).await.unwrap();
let p2_items = entity_gateway.get_items_by_character(&char2.id).await.unwrap();
assert!(p2_items.len() == 0); assert!(p2_items.len() == 0);
ship.handle(ClientId(2), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem { ship.handle(ClientId(2), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
@ -429,7 +429,7 @@ async fn test_can_not_pick_up_item_when_inventory_full() {
unknown: [0; 3] unknown: [0; 3]
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let p2_items = entity_gateway.get_items_by_character(&char2).await.unwrap();
let p2_items = entity_gateway.get_items_by_character(&char2.id).await.unwrap();
assert!(p2_items.len() == 1); assert!(p2_items.len() == 1);
} }
@ -544,10 +544,10 @@ async fn test_pick_up_stack_that_would_exceed_stack_limit() {
})))).await.unwrap().collect::<Vec<_>>(); })))).await.unwrap().collect::<Vec<_>>();
assert!(packets.len() == 0); assert!(packets.len() == 0);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(p1_items.len() == 6); assert!(p1_items.len() == 6);
let p2_items = entity_gateway.get_items_by_character(&char2).await.unwrap();
let p2_items = entity_gateway.get_items_by_character(&char2.id).await.unwrap();
assert!(p2_items.len() == 0); assert!(p2_items.len() == 0);
} }
@ -726,7 +726,7 @@ async fn test_player_drops_partial_stack_and_other_player_picks_it_up() {
unknown: [0; 3] unknown: [0; 3]
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(p1_items.len() == 3); assert!(p1_items.len() == 3);
let p1_item_ids = p1_items.iter().map(|item| { let p1_item_ids = p1_items.iter().map(|item| {
@ -742,7 +742,7 @@ async fn test_player_drops_partial_stack_and_other_player_picks_it_up() {
}); });
assert!(all_items_are_monomates); assert!(all_items_are_monomates);
let p2_items = entity_gateway.get_items_by_character(&char2).await.unwrap();
let p2_items = entity_gateway.get_items_by_character(&char2.id).await.unwrap();
assert!(p2_items.len() == 2); assert!(p2_items.len() == 2);
let p2_item_ids = p2_items.iter().map(|item| { let p2_item_ids = p2_items.iter().map(|item| {

10
tests/test_item_use.rs

@ -49,7 +49,7 @@ async fn test_use_monomate() {
item_id: 0x10000, item_id: 0x10000,
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(items.iter().filter(|item| { assert!(items.iter().filter(|item| {
if let item::ItemDetail::Tool(t) = item.item { if let item::ItemDetail::Tool(t) = item.item {
t.tool == item::tool::ToolType::Monomate t.tool == item::tool::ToolType::Monomate
@ -110,7 +110,7 @@ async fn test_use_monomate_twice() {
item_id: 0x10000, item_id: 0x10000,
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(items.iter().filter(|item| { assert!(items.iter().filter(|item| {
if let item::ItemDetail::Tool(t) = item.item { if let item::ItemDetail::Tool(t) = item.item {
t.tool == item::tool::ToolType::Monomate t.tool == item::tool::ToolType::Monomate
@ -166,7 +166,7 @@ async fn test_use_last_monomate() {
item_id: 0x10000, item_id: 0x10000,
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(items.iter().filter(|item| { assert!(items.iter().filter(|item| {
if let item::ItemDetail::Tool(t) = item.item { if let item::ItemDetail::Tool(t) = item.item {
t.tool == item::tool::ToolType::Monomate t.tool == item::tool::ToolType::Monomate
@ -218,7 +218,7 @@ async fn test_use_nonstackable_tool() {
item_id: 0x10000, item_id: 0x10000,
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(items.len() == 0); assert!(items.len() == 0);
} }
@ -269,7 +269,7 @@ async fn test_use_materials() {
item_id: 0x10001, item_id: 0x10001,
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(items.iter().filter(|item| { assert!(items.iter().filter(|item| {
if let item::ItemDetail::Tool(t) = item.item { if let item::ItemDetail::Tool(t) = item.item {
t.tool == item::tool::ToolType::PowerMaterial t.tool == item::tool::ToolType::PowerMaterial

6
tests/test_mags.rs

@ -60,7 +60,7 @@ async fn test_mag_feed() {
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
} }
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let mag = p1_items.get(0).unwrap(); let mag = p1_items.get(0).unwrap();
match &mag.item { match &mag.item {
item::ItemDetail::Mag(mag) => { item::ItemDetail::Mag(mag) => {
@ -128,7 +128,7 @@ async fn test_mag_change_owner() {
unknown: [0; 3] unknown: [0; 3]
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let p2_items = entity_gateway.get_items_by_character(&char2).await.unwrap();
let p2_items = entity_gateway.get_items_by_character(&char2.id).await.unwrap();
let mag = p2_items.get(0).unwrap(); let mag = p2_items.get(0).unwrap();
match &mag.item { match &mag.item {
item::ItemDetail::Mag(mag) => { item::ItemDetail::Mag(mag) => {
@ -199,7 +199,7 @@ async fn test_mag_cell() {
item_id: 0x10001, item_id: 0x10001,
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
let mag = p1_items.get(0).unwrap(); let mag = p1_items.get(0).unwrap();
match &mag.item { match &mag.item {
item::ItemDetail::Mag(mag) => { item::ItemDetail::Mag(mag) => {

16
tests/test_shops.rs

@ -135,7 +135,7 @@ async fn test_player_buys_from_weapon_shop() {
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap(); let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap(); let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta < 999999); assert!(c1.meseta < 999999);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert_eq!(p1_items.len(), 1); assert_eq!(p1_items.len(), 1);
} }
@ -173,7 +173,7 @@ async fn test_player_buys_from_tool_shop() {
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap(); let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap(); let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta < 999999); assert!(c1.meseta < 999999);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert_eq!(p1_items.len(), 1); assert_eq!(p1_items.len(), 1);
} }
@ -211,7 +211,7 @@ async fn test_player_buys_multiple_from_tool_shop() {
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap(); let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap(); let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta < 999999); assert!(c1.meseta < 999999);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert_eq!(p1_items.len(), 5); assert_eq!(p1_items.len(), 5);
} }
@ -249,7 +249,7 @@ async fn test_player_buys_from_armor_shop() {
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap(); let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap(); let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta < 999999); assert!(c1.meseta < 999999);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert_eq!(p1_items.len(), 1); assert_eq!(p1_items.len(), 1);
} }
@ -388,7 +388,7 @@ async fn test_buying_item_without_enough_mseseta() {
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap(); let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap(); let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
assert_eq!(c1.meseta, 0); assert_eq!(c1.meseta, 0);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert_eq!(p1_items.len(), 0); assert_eq!(p1_items.len(), 0);
} }
@ -444,7 +444,7 @@ async fn test_player_double_buys_from_tool_shop() {
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap(); let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap(); let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta < 999999); assert!(c1.meseta < 999999);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert_eq!(p1_items.len(), 9); assert_eq!(p1_items.len(), 9);
} }
@ -502,7 +502,7 @@ async fn test_techs_disappear_from_shop_when_bought() {
unknown1: 0, unknown1: 0,
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(p1_items[0].item != p1_items[1].item); assert!(p1_items[0].item != p1_items[1].item);
} }
@ -560,6 +560,6 @@ async fn test_units_disappear_from_shop_when_bought() {
unknown1: 0, unknown1: 0,
})))).await.unwrap().for_each(drop); })))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let p1_items = entity_gateway.get_items_by_character(&char1.id).await.unwrap();
assert!(p1_items[0].item != p1_items[1].item); assert!(p1_items[0].item != p1_items[1].item);
} }
Loading…
Cancel
Save