kill_counters #109
@ -210,29 +210,6 @@ pub struct ItemEntity {
|
|||||||
pub item: ItemDetail,
|
pub item: ItemDetail,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ItemEntity {
|
|
||||||
pub fn increase_kill_counter(&mut self) {
|
|
||||||
match &self.item {
|
|
||||||
ItemDetail::Weapon(w) => {
|
|
||||||
if let Some(kills) = w.kills {
|
|
||||||
self.item = ItemDetail::Weapon(weapon::Weapon {
|
|
||||||
kills: Some(kills + 1),
|
|
||||||
..*w
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// ItemDetail::Unit(u) => {
|
|
||||||
// if let Some(kills) = u.kills {
|
|
||||||
// kills += 1;
|
|
||||||
// u.kills = Some(kills);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
_ => {},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub enum InventoryItemEntity {
|
pub enum InventoryItemEntity {
|
||||||
Individual(ItemEntity),
|
Individual(ItemEntity),
|
||||||
|
@ -1383,7 +1383,6 @@ 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 {
|
||||||
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))?;
|
||||||
@ -1396,9 +1395,7 @@ impl<EG: EntityGateway> ItemAction<EG> for TradeMeseta {
|
|||||||
.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?;
|
|
||||||
}
|
}
|
||||||
// limiter
|
|
||||||
for units in equipped_items.unit {
|
for units in equipped_items.unit {
|
||||||
if let Some(unit_entity) = units {
|
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 unit_id = inventory.get_item_by_entity_id(unit_entity).ok_or(ItemManagerError::EntityIdNotInInventory(unit_entity))?.item_id();
|
||||||
@ -1412,7 +1409,6 @@ impl<EG: EntityGateway> ItemAction<EG> for TradeMeseta {
|
|||||||
.ok_or(ItemManagerError::WrongItemType(unit_id))?;
|
.ok_or(ItemManagerError::WrongItemType(unit_id))?;
|
||||||
|
|
||||||
unit.increment_kill_counter();
|
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?;
|
entity_gateway.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user