|
@ -1423,33 +1423,39 @@ impl<EG: EntityGateway> ItemAction<EG> for TradeMeseta { |
|
|
equipped_items: &EquippedEntity)
|
|
|
equipped_items: &EquippedEntity)
|
|
|
-> Result<(), anyhow::Error> {
|
|
|
-> Result<(), anyhow::Error> {
|
|
|
let inventory = self.character_inventory.get_mut(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?;
|
|
|
let inventory = self.character_inventory.get_mut(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?;
|
|
|
|
|
|
// weapon
|
|
|
if let Some(weapon_entity) = equipped_items.weapon {
|
|
|
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 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))?;
|
|
|
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()
|
|
|
|
|
|
|
|
|
let individual_item_w = weapon_handle.item_mut()
|
|
|
.ok_or(ItemManagerError::NoSuchItemId(weapon_id))?
|
|
|
.ok_or(ItemManagerError::NoSuchItemId(weapon_id))?
|
|
|
.individual_mut()
|
|
|
.individual_mut()
|
|
|
.ok_or(ItemManagerError::WrongItemType(weapon_id))?;
|
|
|
.ok_or(ItemManagerError::WrongItemType(weapon_id))?;
|
|
|
let weapon = individual_item
|
|
|
|
|
|
|
|
|
let weapon = individual_item_w
|
|
|
.weapon_mut()
|
|
|
.weapon_mut()
|
|
|
.ok_or(ItemManagerError::WrongItemType(weapon_id))?;
|
|
|
.ok_or(ItemManagerError::WrongItemType(weapon_id))?;
|
|
|
|
|
|
|
|
|
weapon.increment_kill_counter();
|
|
|
weapon.increment_kill_counter();
|
|
|
entity_gateway.increment_kill_counter(&weapon_entity).await?;
|
|
|
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)
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
// limiter
|
|
|
|
|
|
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();
|
|
|
|
|
|
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))?
|
|
|
|
|
|
.individual_mut()
|
|
|
|
|
|
.ok_or(ItemManagerError::WrongItemType(unit_id))?;
|
|
|
|
|
|
let unit = individual_item_u
|
|
|
|
|
|
.unit_mut()
|
|
|
|
|
|
.ok_or(ItemManagerError::WrongItemType(unit_id))?;
|
|
|
|
|
|
|
|
|
|
|
|
unit.increment_kill_counter();
|
|
|
|
|
|
entity_gateway.increment_kill_counter(&unit_entity).await?;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
entity_gateway.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;
|
|
|
Ok(())
|
|
|
Ok(())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|