diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/statistics/gamedata.rs | 38 | ||||
-rw-r--r-- | src/statistics/mod.rs | 1 | ||||
-rw-r--r-- | src/statistics/trackers.rs | 21 |
3 files changed, 57 insertions, 3 deletions
diff --git a/src/statistics/gamedata.rs b/src/statistics/gamedata.rs new file mode 100644 index 0000000..d7f0e0e --- /dev/null +++ b/src/statistics/gamedata.rs @@ -0,0 +1,38 @@ +//! This module contains some game data that is necessary to correctly calculate +//! some statistics. +use super::boon::{BoonQueue, BoonType}; + +/// Contains a boon. +/// +/// Fields: +/// * boon id +/// * name (english) (just for easier debugging) +/// * maximum number of stacks +/// * boon type (intensity or duration) +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Boon(pub u16, pub &'static str, pub u32, pub BoonType); + +impl Boon { + pub fn create_queue(&self) -> BoonQueue { + BoonQueue::new(self.2, self.3) + } +} + +/// A list of all boons (and conditions) +pub static BOONS: &[Boon] = &[ + // Standard boons. + // Queue size for duration based boons are wonky, more or less guess work. + Boon(717, "Protection", 5, BoonType::Duration), + Boon(718, "Regeneration", 5, BoonType::Duration), + Boon(719, "Swiftness", 5, BoonType::Duration), + Boon(725, "Fury", 5, BoonType::Duration), + Boon(726, "Vigor", 5, BoonType::Duration), + Boon(740, "Might", 25, BoonType::Intensity), + Boon(743, "Aegis", 5, BoonType::Duration), + Boon(1187, "Quickness", 5, BoonType::Duration), + Boon(30328, "Alacrity", 9, BoonType::Duration), +]; + +pub fn get_boon(boon_id: u16) -> Option<&'static Boon> { + BOONS.iter().find(|b| b.0 == boon_id) +} diff --git a/src/statistics/mod.rs b/src/statistics/mod.rs index 0a524ea..7f465ae 100644 --- a/src/statistics/mod.rs +++ b/src/statistics/mod.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; use std::error::Error; pub mod boon; +pub mod gamedata; pub mod trackers; use self::trackers::{RunnableTracker, Tracker}; diff --git a/src/statistics/trackers.rs b/src/statistics/trackers.rs index 9b8d633..751b639 100644 --- a/src/statistics/trackers.rs +++ b/src/statistics/trackers.rs @@ -16,6 +16,7 @@ use std::error::Error; use super::super::{Event, EventKind, Log}; use super::boon::{BoonQueue, BoonType}; +use super::gamedata; use super::DamageStats; // A support macro to introduce a new block. @@ -237,8 +238,6 @@ pub struct BoonTracker { } impl BoonTracker { - const MAX_STACKS: u32 = 25; - /// Creates a new boon tracker. pub fn new() -> BoonTracker { Default::default() @@ -304,7 +303,13 @@ impl BoonTracker { .entry(agent) .or_insert_with(Default::default) .entry(buff_id) - .or_insert_with(|| BoonQueue::new(Self::MAX_STACKS, BoonType::Intensity)) + .or_insert_with(|| { + gamedata::get_boon(buff_id) + .map(gamedata::Boon::create_queue) + // For unknown boons, default to a duration-based counter + // with 5 stacks. + .unwrap_or_else(|| BoonQueue::new(5, BoonType::Duration)) + }) } } @@ -333,6 +338,16 @@ impl Tracker for BoonTracker { self.update_next_update(); } + // XXX: Properly handle SINGLE and MANUAL removal types + EventKind::BuffRemove { + destination_agent_addr, + buff_id, + .. + } => { + self.get_queue(destination_agent_addr, buff_id).clear(); + self.update_next_update(); + } + _ => (), } |