diff options
author | Daniel Schadt <kingdread@gmx.de> | 2020-04-27 14:39:36 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2020-04-27 14:39:36 +0200 |
commit | 08465ea1b8c1b9f90057bcc10fb8887ee57cac8c (patch) | |
tree | 7786e81336db4f814a323ed1cdacdced801f9abe /src/statistics/damage.rs | |
parent | 2a9aef0a371ffb860bfc48b691b9aaf0393e3df7 (diff) | |
download | evtclib-08465ea1b8c1b9f90057bcc10fb8887ee57cac8c.tar.gz evtclib-08465ea1b8c1b9f90057bcc10fb8887ee57cac8c.tar.bz2 evtclib-08465ea1b8c1b9f90057bcc10fb8887ee57cac8c.zip |
remove statistics submodule
The way the trackers worked was rather... "adventurous", and while there
were some good ideas and it mostly worked, the implementation and
interface could do better.
Additionally, it was incomplete, for example there were a lot of
mechanics just missing.
While I'm not against having this functionality provided by evtclib, I
think it would be more worthwile with a better designed implementation &
API, so this "proof of concept" implementation is gone until there is a
better way of doing things.
gamedata is being kept, as the boss identifiers are useful and
applications shouldn't have to deal with keeping this low-level list
themselves.
Diffstat (limited to 'src/statistics/damage.rs')
-rw-r--r-- | src/statistics/damage.rs | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/src/statistics/damage.rs b/src/statistics/damage.rs deleted file mode 100644 index 0c26a9b..0000000 --- a/src/statistics/damage.rs +++ /dev/null @@ -1,95 +0,0 @@ -use super::math::{Monoid, RecordFunc, Semigroup}; -use std::fmt; - -/// Type of the damage. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum DamageType { - Physical, - Condition, -} - -/// Meta information about a damage log entry. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub struct Meta { - pub source: u64, - pub target: u64, - pub kind: DamageType, - pub skill: u32, -} - -/// A small wrapper that wraps a damage number. -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] -pub struct Damage(pub u64); - -impl Semigroup for Damage { - #[inline] - fn combine(&self, other: &Self) -> Self { - Damage(self.0 + other.0) - } -} - -impl Monoid for Damage { - #[inline] - fn mempty() -> Self { - Damage(0) - } -} - -/// Provides access to the damage log. -#[derive(Clone, Default)] -pub struct DamageLog { - inner: RecordFunc<u64, Meta, Damage>, -} - -impl DamageLog { - pub fn new() -> Self { - DamageLog { - inner: RecordFunc::new(), - } - } - - pub fn log( - &mut self, - time: u64, - source: u64, - target: u64, - kind: DamageType, - skill: u32, - value: u64, - ) { - self.inner.insert( - time, - Meta { - source, - target, - kind, - skill, - }, - Damage(value), - ) - } - - pub fn damage_between<F: FnMut(&Meta) -> bool>( - &self, - start: u64, - stop: u64, - filter: F, - ) -> Damage { - self.inner.between_only(&start, &stop, filter) - } - - pub fn damage<F: FnMut(&Meta) -> bool>(&self, filter: F) -> Damage { - self.inner.tally_only(filter) - } -} - -impl fmt::Debug for DamageLog { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!( - f, - "DamageLog {{ {} events logged, {:?} total damage }}", - self.inner.len(), - self.inner.tally() - ) - } -} |