Browse Source

andy vs. clippy round 5

kill_counters
andy 3 years ago
parent
commit
ca44dcf689
  1. 2
      src/ship/items/inventory.rs
  2. 6
      src/ship/items/manager.rs

2
src/ship/items/inventory.rs

@ -1002,7 +1002,7 @@ impl CharacterInventory {
pub fn get_item_by_entity_id(&self, item_id: ItemEntityId) -> Option<&InventoryItem> {
for item in &self.items {
if let Some(_) = item.entity_ids().iter().find(|&&item| item == item_id) {
if item.entity_ids().iter().any(|&item| item == item_id) {
return Some(item)
}
}

6
src/ship/items/manager.rs

@ -1396,9 +1396,8 @@ impl<EG: EntityGateway> ItemAction<EG> for TradeMeseta {
weapon.increment_kill_counter();
}
for units in equipped_items.unit {
if let Some(unit_entity) = units {
let unit_id = inventory.get_item_by_entity_id(unit_entity).ok_or(ItemManagerError::EntityIdNotInInventory(unit_entity))?.item_id();
for units in equipped_items.unit.iter().flatten() {
let unit_id = inventory.get_item_by_entity_id(*units).ok_or(ItemManagerError::EntityIdNotInInventory(*units))?.item_id();
let mut unit_handle = inventory.get_item_handle_by_id(unit_id).ok_or(ItemManagerError::NoSuchItemId(unit_id))?;
let individual_item_u = unit_handle.item_mut()
.ok_or(ItemManagerError::NoSuchItemId(unit_id))?
@ -1409,7 +1408,6 @@ impl<EG: EntityGateway> ItemAction<EG> for TradeMeseta {
.ok_or(ItemManagerError::WrongItemType(unit_id))?;
unit.increment_kill_counter();
}
}
entity_gateway.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;
Ok(())

Loading…
Cancel
Save