Browse Source

I am dumb

pull/113/head
jake 3 years ago
parent
commit
dffa636247
  1. 3
      src/ship/items/actions.rs
  2. 4
      tests/test_item_actions.rs

3
src/ship/items/actions.rs

@ -494,6 +494,7 @@ fn equip_inventory_item(character_id: CharacterEntityId, item_id: ClientItemId,
let mut inventory = item_state.inventory(&character_id)?; let mut inventory = item_state.inventory(&character_id)?;
inventory.equip(&item_id, equip_slot); inventory.equip(&item_id, equip_slot);
transaction.gateway().set_character_equips(&character_id, &inventory.as_equipped_entity()).await?; transaction.gateway().set_character_equips(&character_id, &inventory.as_equipped_entity()).await?;
item_state.set_inventory(inventory);
Ok(((item_state, transaction), ())) Ok(((item_state, transaction), ()))
}) })
@ -522,7 +523,6 @@ where
} }
fn unequip_inventory_item(character_id: CharacterEntityId, item_id: ClientItemId) fn unequip_inventory_item(character_id: CharacterEntityId, item_id: ClientItemId)
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()) -> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()), ItemStateError>> + Send + 'a>> -> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()), ItemStateError>> + Send + 'a>>
@ -532,6 +532,7 @@ fn unequip_inventory_item(character_id: CharacterEntityId, item_id: ClientItemId
let mut inventory = item_state.inventory(&character_id)?; let mut inventory = item_state.inventory(&character_id)?;
inventory.unequip(&item_id); inventory.unequip(&item_id);
transaction.gateway().set_character_equips(&character_id, &inventory.as_equipped_entity()).await?; transaction.gateway().set_character_equips(&character_id, &inventory.as_equipped_entity()).await?;
item_state.set_inventory(inventory);
Ok(((item_state, transaction), ())) Ok(((item_state, transaction), ()))
}) })

4
tests/test_item_actions.rs

@ -47,8 +47,8 @@ async fn test_equip_unit_from_equip_menu() {
}).await.unwrap()); }).await.unwrap());
let equipped = item::EquippedEntity { let equipped = item::EquippedEntity {
weapon: Some(p1_inv[0].id),
armor: None,
weapon: None,
armor: Some(p1_inv[0].id),
shield: None, shield: None,
unit: [None; 4], unit: [None; 4],
mag: None, mag: None,

Loading…
Cancel
Save