fix warnings from rebase
This commit is contained in:
parent
117a2daa31
commit
e3991f5d41
@ -317,6 +317,7 @@ fn main() {
|
|||||||
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}),
|
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}),
|
||||||
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Native, value: 100}),],
|
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Native, value: 100}),],
|
||||||
tekked: true,
|
tekked: true,
|
||||||
|
kills: None,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
}).await.unwrap();
|
}).await.unwrap();
|
||||||
|
@ -352,7 +352,7 @@ impl EntityGateway for InMemoryGateway {
|
|||||||
|
|
||||||
async fn increment_kill_counter(&mut self, item_id: &ItemEntityId) -> Result<(), GatewayError> {
|
async fn increment_kill_counter(&mut self, item_id: &ItemEntityId) -> Result<(), GatewayError> {
|
||||||
if let Some(item_entity) = self.items.lock().unwrap().get_mut(item_id) {
|
if let Some(item_entity) = self.items.lock().unwrap().get_mut(item_id) {
|
||||||
item_entity.increase_kill_counter();
|
item_entity.item.increment_kill_counter();
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -173,28 +173,29 @@ impl ItemDetail {
|
|||||||
pub fn has_kill_counter(self) -> bool {
|
pub fn has_kill_counter(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
ItemDetail::Weapon(w) => w.kills.is_some(),
|
ItemDetail::Weapon(w) => w.kills.is_some(),
|
||||||
ItemDetail::Armor(a) => false,
|
ItemDetail::Armor(_a) => false,
|
||||||
ItemDetail::Shield(s) => false,
|
ItemDetail::Shield(_s) => false,
|
||||||
// ItemDetail::Unit(u) => u.kills.is_some(),
|
// ItemDetail::Unit(u) => u.kills.is_some(),
|
||||||
ItemDetail::Unit(u) => false,
|
ItemDetail::Unit(_u) => false,
|
||||||
ItemDetail::Tool(t) => false,
|
ItemDetail::Tool(_t) => false,
|
||||||
ItemDetail::TechniqueDisk(d) => false,
|
ItemDetail::TechniqueDisk(_d) => false,
|
||||||
ItemDetail::Mag(m) => false,
|
ItemDetail::Mag(_m) => false,
|
||||||
ItemDetail::ESWeapon(e) => false,
|
ItemDetail::ESWeapon(_e) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: delete this
|
// TODO: delete this
|
||||||
pub fn increment_kill_counter(&self) {
|
// jk actually we need this
|
||||||
|
pub fn increment_kill_counter(&mut self) {
|
||||||
match self {
|
match self {
|
||||||
ItemDetail::Weapon(w) => {},
|
ItemDetail::Weapon(w) => {w.increment_kill_counter()},
|
||||||
ItemDetail::Armor(a) => {},
|
ItemDetail::Armor(_a) => {},
|
||||||
ItemDetail::Shield(s) => {},
|
ItemDetail::Shield(_s) => {},
|
||||||
ItemDetail::Unit(u) => {},
|
ItemDetail::Unit(u) => {u.increment_kill_counter()},
|
||||||
ItemDetail::Tool(t) => {},
|
ItemDetail::Tool(_t) => {},
|
||||||
ItemDetail::TechniqueDisk(d) => {},
|
ItemDetail::TechniqueDisk(_d) => {},
|
||||||
ItemDetail::Mag(m) => {},
|
ItemDetail::Mag(_m) => {},
|
||||||
ItemDetail::ESWeapon(e) => {},
|
ItemDetail::ESWeapon(_e) => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1193,6 +1193,38 @@ impl ItemManager {
|
|||||||
.await
|
.await
|
||||||
.map_err(|err| err.into())
|
.map_err(|err| err.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
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 individual_item_w = weapon_handle.item_mut()
|
||||||
|
.ok_or(ItemManagerError::NoSuchItemId(weapon_id))?
|
||||||
|
.individual_mut()
|
||||||
|
.ok_or(ItemManagerError::WrongItemType(weapon_id))?;
|
||||||
|
let weapon = individual_item_w
|
||||||
|
.weapon_mut()
|
||||||
|
.ok_or(ItemManagerError::WrongItemType(weapon_id))?;
|
||||||
|
|
||||||
|
weapon.increment_kill_counter();
|
||||||
|
}
|
||||||
|
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))?
|
||||||
|
.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.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -1375,41 +1407,6 @@ impl<EG: EntityGateway> ItemAction<EG> for TradeMeseta {
|
|||||||
dest_meseta.0 += self.amount as u32;
|
dest_meseta.0 += self.amount as u32;
|
||||||
entity_gateway.set_character_meseta(&self.dest_character_id, *dest_meseta).await?;
|
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 {
|
|
||||||
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 individual_item_w = weapon_handle.item_mut()
|
|
||||||
.ok_or(ItemManagerError::NoSuchItemId(weapon_id))?
|
|
||||||
.individual_mut()
|
|
||||||
.ok_or(ItemManagerError::WrongItemType(weapon_id))?;
|
|
||||||
let weapon = individual_item_w
|
|
||||||
.weapon_mut()
|
|
||||||
.ok_or(ItemManagerError::WrongItemType(weapon_id))?;
|
|
||||||
|
|
||||||
weapon.increment_kill_counter();
|
|
||||||
}
|
|
||||||
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))?
|
|
||||||
.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.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,6 +334,7 @@ impl<R: Rng + SeedableRng> ArmorShop<R> {
|
|||||||
ArmorShopItem::Unit(Unit {
|
ArmorShopItem::Unit(Unit {
|
||||||
unit: unit_detail.item,
|
unit: unit_detail.item,
|
||||||
modifier: None,
|
modifier: None,
|
||||||
|
kills: None,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user