|
|
@ -1415,6 +1415,41 @@ impl<EG: EntityGateway> ItemAction<EG> for TradeMeseta { |
|
|
|
dest_meseta.0 += self.amount as u32;
|
|
|
|
entity_gateway.set_character_meseta(&self.dest_character_id, *dest_meseta).await?;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn increase_kill_counters<EG: EntityGateway>( &mut self,
|
|
|
|
entity_gateway: &mut EG,
|
|
|
|
character: &CharacterEntity,
|
|
|
|
equipped_items: &EquippedEntity)
|
|
|
|
-> Result<(), anyhow::Error> {
|
|
|
|
let inventory = self.character_inventory.get_mut(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?;
|
|
|
|
if let Some(weapon_entity) = equipped_items.weapon {
|
|
|
|
println!("updating weapon kill counter for weapon {:?}", weapon_entity);
|
|
|
|
// weapon_entity = &InventoryItem
|
|
|
|
|
|
|
|
// let weapon_id = weapon_entity.item_id();
|
|
|
|
let weapon_id = inventory.get_item_by_entity_id(weapon_entity).ok_or(ItemManagerError::EntityIdNotInInventory(weapon_entity))?.item_id();
|
|
|
|
let mut weapon_handle = inventory.get_item_handle_by_id(weapon_id).ok_or(ItemManagerError::NoSuchItemId(weapon_id))?;
|
|
|
|
// weapon_handle = InventoryItemHandle
|
|
|
|
let individual_item = weapon_handle.item_mut()
|
|
|
|
.ok_or(ItemManagerError::NoSuchItemId(weapon_id))?
|
|
|
|
.individual_mut()
|
|
|
|
.ok_or(ItemManagerError::WrongItemType(weapon_id))?;
|
|
|
|
let weapon = individual_item
|
|
|
|
.weapon_mut()
|
|
|
|
.ok_or(ItemManagerError::WrongItemType(weapon_id))?;
|
|
|
|
|
|
|
|
weapon.increment_kill_counter();
|
|
|
|
entity_gateway.increment_kill_counter(&weapon_entity).await?;
|
|
|
|
entity_gateway.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;
|
|
|
|
}
|
|
|
|
// for units in equipped_items.unit {
|
|
|
|
// if let Some(unit_id) = units {
|
|
|
|
// println!("UNIMPLEMENTED - updating unit kill counter for unit {:?}", unit_id);
|
|
|
|
// // entity_gateway.increase_kill_counter(&unit_id).await?;
|
|
|
|
// // let unit = inventory.get_item_by_entity_id(&unit_id)
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|