aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2018-06-13 13:17:28 +0200
committerDaniel Schadt <kingdread@gmx.de>2018-06-13 13:17:28 +0200
commit2fe671951369b8f049e8acf02e9e9750c96b4dcd (patch)
tree49e9c0cc4bcbf6d76183555ac95bc3d9504c7a05
parentfe16699205b6b40aed8cafbe95820835a7052908 (diff)
downloadevtclib-2fe671951369b8f049e8acf02e9e9750c96b4dcd.tar.gz
evtclib-2fe671951369b8f049e8acf02e9e9750c96b4dcd.tar.bz2
evtclib-2fe671951369b8f049e8acf02e9e9750c96b4dcd.zip
clean up a bit
-rw-r--r--src/event.rs67
-rw-r--r--src/statistics/damage.rs2
-rw-r--r--src/statistics/math.rs7
-rw-r--r--src/statistics/trackers.rs17
4 files changed, 7 insertions, 86 deletions
diff --git a/src/event.rs b/src/event.rs
index f87688e..02f4686 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -104,73 +104,6 @@ pub enum EventKind {
},
}
-impl EventKind {
- /// Returns the source agent address for this event, if one exists.
- pub fn source_agent_addr(&self) -> Option<u64> {
- use EventKind::*;
- match *self {
- EnterCombat { agent_addr, .. } => return Some(agent_addr),
- ExitCombat { agent_addr } => return Some(agent_addr),
- ChangeUp { agent_addr } => return Some(agent_addr),
- ChangeDown { agent_addr } => return Some(agent_addr),
- ChangeDead { agent_addr } => return Some(agent_addr),
- Spawn { agent_addr } => return Some(agent_addr),
- Despawn { agent_addr } => return Some(agent_addr),
- HealthUpdate { agent_addr, .. } => return Some(agent_addr),
- WeaponSwap { agent_addr, .. } => return Some(agent_addr),
- MaxHealthUpdate { agent_addr, .. } => return Some(agent_addr),
- PointOfView { agent_addr } => return Some(agent_addr),
- SkillUse {
- source_agent_addr, ..
- } => return Some(source_agent_addr),
- ConditionTick {
- source_agent_addr, ..
- } => return Some(source_agent_addr),
- InvulnTick {
- source_agent_addr, ..
- } => return Some(source_agent_addr),
- Physical {
- source_agent_addr, ..
- } => return Some(source_agent_addr),
- BuffApplication {
- source_agent_addr, ..
- } => return Some(source_agent_addr),
- BuffRemove {
- source_agent_addr, ..
- } => return Some(source_agent_addr),
- _ => return None,
- }
- }
-
- /// Returns the destination agent address for this event, if one exists.
- pub fn destination_agent_addr(&self) -> Option<u64> {
- use EventKind::*;
- match *self {
- ConditionTick {
- destination_agent_addr,
- ..
- } => return Some(destination_agent_addr),
- InvulnTick {
- destination_agent_addr,
- ..
- } => return Some(destination_agent_addr),
- Physical {
- destination_agent_addr,
- ..
- } => return Some(destination_agent_addr),
- BuffApplication {
- destination_agent_addr,
- ..
- } => return Some(destination_agent_addr),
- BuffRemove {
- destination_agent_addr,
- ..
- } => return Some(destination_agent_addr),
- _ => return None,
- }
- }
-}
-
/// A higher-level representation of a combat event.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Event {
diff --git a/src/statistics/damage.rs b/src/statistics/damage.rs
index fdf723f..0fcbf9b 100644
--- a/src/statistics/damage.rs
+++ b/src/statistics/damage.rs
@@ -36,7 +36,7 @@ impl Monoid for Damage {
}
/// Provides access to the damage log.
-#[derive(Clone)]
+#[derive(Clone, Default)]
pub struct DamageLog {
inner: RecordFunc<u64, Meta, Damage>,
}
diff --git a/src/statistics/math.rs b/src/statistics/math.rs
index 3760ca3..6e7e666 100644
--- a/src/statistics/math.rs
+++ b/src/statistics/math.rs
@@ -45,7 +45,7 @@ struct Record<X, T, D> {
/// * `T` tag for each data point. Can be arbitrary.
/// * `D` actual data. Must be [`Monoid`](trait.Monoid.html), so that it can be
/// summed up.
-#[derive(Clone)]
+#[derive(Clone, Default)]
pub struct RecordFunc<X, T, D> {
data: Vec<Record<X, T, D>>,
}
@@ -84,6 +84,11 @@ where
self.data.len()
}
+ /// Check whether there are no records.
+ pub fn is_emtpy(&self) -> bool {
+ self.data.is_empty()
+ }
+
/// Get the absolute value at the specific point.
#[inline]
pub fn get(&self, x: &X) -> D {
diff --git a/src/statistics/trackers.rs b/src/statistics/trackers.rs
index ce87f3d..11e51f2 100644
--- a/src/statistics/trackers.rs
+++ b/src/statistics/trackers.rs
@@ -18,26 +18,12 @@
//! trackers on the same log.
use std::collections::HashMap;
use std::error::Error;
-use std::hash::Hash;
use super::super::{Event, EventKind, Log};
use super::boon::BoonQueue;
use super::damage::{DamageLog, DamageType};
use super::gamedata::{self, Mechanic, Trigger};
-// A support macro to introduce a new block.
-//
-// Doesn't really require a macro, but it's nicer to look at
-// with! { foo = bar }
-// rather than
-// { let foo = bar; ... }
-macro_rules! with {
- ($name:ident = $expr:expr => $bl:block) => {{
- let $name = $expr;
- $bl
- }};
-}
-
/// A tracker.
///
/// A tracker should be responsible for tracking a single statistic. Each
@@ -322,9 +308,6 @@ impl Tracker for BoonTracker {
type Error = !;
fn feed(&mut self, event: &Event) -> Result<(), Self::Error> {
- if event.kind.destination_agent_addr() != Some(self.agent_addr) {
- return Ok(());
- }
let delta_t = event.time - self.last_time;
if self.next_update != 0 && delta_t > self.next_update {