aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2018-06-10 01:16:30 +0200
committerDaniel Schadt <kingdread@gmx.de>2018-06-10 01:16:30 +0200
commit877549baca100d534c1272000b2af7a8b364cd35 (patch)
tree3f4a2df365b89be33e9ed0c50fd29c28c60c5994 /src
parenta25ac4073d201801030f5a2baf13c54d80cc3467 (diff)
downloadevtclib-877549baca100d534c1272000b2af7a8b364cd35.tar.gz
evtclib-877549baca100d534c1272000b2af7a8b364cd35.tar.bz2
evtclib-877549baca100d534c1272000b2af7a8b364cd35.zip
basic structure for mechanic tracker
Diffstat (limited to 'src')
-rw-r--r--src/main.rs3
-rw-r--r--src/statistics/gamedata.rs52
-rw-r--r--src/statistics/trackers.rs39
3 files changed, 92 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index c6c0c2d..f632db4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,7 @@
extern crate byteorder;
extern crate evtclib;
use byteorder::{ReadBytesExt, BE, LE};
+use std::env;
use std::fs::File;
use std::collections::HashMap;
@@ -12,7 +13,7 @@ use std::io::BufReader;
pub fn main() -> Result<(), evtclib::raw::parser::ParseError> {
println!("Hello World!");
- let mut f = BufReader::new(File::open("material/Samarog.evtc")?);
+ let mut f = BufReader::new(File::open(env::args().skip(1).next().unwrap())?);
let result = evtclib::raw::parse_file(&mut f)?;
/*
diff --git a/src/statistics/gamedata.rs b/src/statistics/gamedata.rs
index 73f2780..ea1be39 100644
--- a/src/statistics/gamedata.rs
+++ b/src/statistics/gamedata.rs
@@ -2,6 +2,12 @@
//! some statistics.
use super::boon::{BoonQueue, BoonType};
+/// Enum containing all bosses with their IDs.
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub enum Boss {
+ ValeGuardian = 15483,
+}
+
/// Contains a boon.
///
/// Fields:
@@ -61,3 +67,49 @@ pub static BOONS: &[Boon] = &[
pub fn get_boon(boon_id: u16) -> Option<&'static Boon> {
BOONS.iter().find(|b| b.0 == boon_id)
}
+
+/// Contains pre-defined triggers for boss mechanics.
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub enum Trigger {
+ /// Triggers when the given boon is applied to the player.
+ BoonPlayer(u16),
+ /// Triggers when the given boon is applied to the boss.
+ BoonBoss(u16),
+ /// Triggers when the given skill is used by a player.
+ SkillByPlayer(u16),
+ /// Triggers when the given skill is used on a player.
+ SkillOnPlayer(u16),
+ /// Triggers when the given boon is stripped from an enemy.
+ BoonStripped(u16),
+ /// Triggers when the given entity spawned.
+ Spawn(u16),
+ /// Triggers when the boss finishes channeling the given skill.
+ ChannelComplete(u16),
+}
+
+/// Struct describing a boss mechanic.
+///
+/// Fields:
+/// * Boss id that this mechanic belongs to.
+/// * How the mechanic is triggered.
+/// * Technical term for the mechanic (for debugging purposes).
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct Mechanic(pub u16, pub Trigger, pub &'static str);
+
+macro_rules! mechanics {
+ ($boss_id:expr => [ $($name:expr => $trigger:expr,)* ]) => {
+ $(Mechanic($boss_id as u16, $trigger, $name)),*
+ }
+}
+
+/// A slice of all mechanics that we know about.
+pub static MECHANICS: &[Mechanic] = &[
+ mechanics! { Boss::ValeGuardian => [
+ "Unstable Magic Spike" => Trigger::SkillOnPlayer(31860),
+ ]},
+];
+
+/// Get all mechanics that belong to the given boss.
+pub fn get_mechanics(boss_id: u16) -> Vec<&'static Mechanic> {
+ MECHANICS.iter().filter(|m| m.0 == boss_id).collect()
+}
diff --git a/src/statistics/trackers.rs b/src/statistics/trackers.rs
index 6e23480..bcf5e90 100644
--- a/src/statistics/trackers.rs
+++ b/src/statistics/trackers.rs
@@ -16,7 +16,7 @@ use std::error::Error;
use super::super::{Event, EventKind, Log};
use super::boon::BoonQueue;
-use super::gamedata;
+use super::gamedata::{self, Mechanic, Trigger};
use super::DamageStats;
// A support macro to introduce a new block.
@@ -377,3 +377,40 @@ impl Tracker for BoonTracker {
Ok(self.boon_areas)
}
}
+
+/// A tracker that tracks boss mechanics for each player.
+pub struct MechanicTracker {
+ mechanics: HashMap<u64, HashMap<&'static Mechanic, u32>>,
+ available_mechanics: Vec<&'static Mechanic>,
+ boss_address: u64,
+}
+
+impl MechanicTracker {
+ /// Create a new mechanic tracker that watches over the given mechanics.
+ pub fn new(boss_address: u64, mechanics: Vec<&'static Mechanic>) -> MechanicTracker {
+ MechanicTracker {
+ mechanics: HashMap::new(),
+ available_mechanics: mechanics,
+ boss_address: boss_address,
+ }
+ }
+}
+
+impl Tracker for MechanicTracker {
+ type Stat = HashMap<u64, HashMap<&'static Mechanic, u32>>;
+ type Error = !;
+
+ fn feed(&mut self, event: &Event) -> Result<(), Self::Error> {
+ for mechanic in &self.available_mechanics {
+ match (&event.kind, &mechanic.1) {
+ (EventKind::SkillUse { .. }, Trigger::SkillOnPlayer { .. }) => (),
+ _ => (),
+ }
+ }
+ Ok(())
+ }
+
+ fn finalize(self) -> Result<Self::Stat, Self::Error> {
+ Ok(self.mechanics)
+ }
+}