Browse Source

actually add and use AddKill modifier and remove dead code

kill_counters
andy 2 years ago
parent
commit
7ac68d13bb
  1. 11
      src/entity/gateway/entitygateway.rs
  2. 2
      src/entity/gateway/inmemory.rs
  3. 6
      src/entity/item/weapon.rs
  4. 2
      src/ship/packet/handler/message.rs
  5. 3
      tests/test_unseal_items.rs

11
src/entity/gateway/entitygateway.rs

@ -157,17 +157,6 @@ pub trait EntityGateway: Send + Sync {
async fn create_trade(&mut self, _char_id1: &CharacterEntityId, _char_id2: &CharacterEntityId) -> Result<TradeEntity, GatewayError> {
unimplemented!();
}
async fn increment_kill_counter(&mut self, _item_entity_id: &ItemEntityId) -> Result<(), GatewayError> {
unimplemented!();
}
async fn get_kill_counter() {
unimplemented!();
}
async fn set_kill_counter() {
unimplemented!();
}
}

2
src/entity/gateway/inmemory.rs

@ -78,6 +78,7 @@ pub struct InMemoryGateway {
weapon_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<weapon::WeaponModifier>>>>,
unit_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<unit::UnitModifier>>>>,
trades: Arc<Mutex<Vec<TradeEntity>>>,
unit_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<unit::UnitModifier>>>>,
}
impl Default for InMemoryGateway {
@ -96,6 +97,7 @@ impl Default for InMemoryGateway {
weapon_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
unit_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
trades: Arc::new(Mutex::new(Vec::new())),
unit_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
}
}
}

6
src/entity/item/weapon.rs

@ -1684,10 +1684,4 @@ impl Weapon {
| WeaponType::Scepter
)
}
pub fn increment_kill_counter(&mut self) {
if let Some(kills) = self.kills {
self.kills = Some(kills + 1);
}
}
}

2
src/ship/packet/handler/message.rs

@ -411,7 +411,7 @@ where
}
pub async fn player_killed_monster<EG>( id: ClientId,
_pkt: &KillMonster, // use this later for turbo logging?
pkt: &KillMonster,
entity_gateway: &mut EG,
client_location: &ClientLocation,
clients: &Clients,

3
tests/test_unseal_items.rs

@ -1,7 +1,4 @@
/* TODO:
1. test to check if sjs/lame/limiter drop with Some() kill counter enabled
2. test to make sure other items drop with None kill counter
3. test kill counters get incremented per kill
4. test unsealing item:
- client item id does not change
- unsealed item no longer has kill counter

Loading…
Cancel
Save