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/mechanics.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/mechanics.rs')
-rw-r--r-- | src/statistics/mechanics.rs | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/src/statistics/mechanics.rs b/src/statistics/mechanics.rs deleted file mode 100644 index 0cf6f24..0000000 --- a/src/statistics/mechanics.rs +++ /dev/null @@ -1,62 +0,0 @@ -use super::gamedata::Mechanic; -use super::math::{Monoid, RecordFunc, Semigroup}; - -use std::fmt; - -/// A simple wrapper for integers. -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -struct Counter(u32); - -impl Semigroup for Counter { - #[inline] - fn combine(&self, other: &Counter) -> Counter { - Counter(self.0 + other.0) - } -} - -impl Monoid for Counter { - #[inline] - fn mempty() -> Counter { - Counter(0) - } -} - -/// Provides access to the mechanic log. -#[derive(Clone, Default)] -pub struct MechanicLog { - inner: RecordFunc<u64, (&'static Mechanic, u64), Counter>, -} - -impl MechanicLog { - /// Increase the mechanic counter for the given mechanic and agent by one. - pub fn increase(&mut self, time: u64, mechanic: &'static Mechanic, agent: u64) { - self.inner.insert(time, (mechanic, agent), Counter(1)); - } - - /// Return the count of mechanics. - /// - /// A function can be provided to filter entries by mechanic type and agent. - pub fn count<F: FnMut(&'static Mechanic, u64) -> bool>(&self, mut filter: F) -> u32 { - self.inner.tally_only(|(a, b)| filter(a, *b)).0 - } - - /// Return the count of mechanics between the two given times. - /// - /// A function can be provided to filter entries by mechanic type and agent. - pub fn count_between<F: FnMut(&'static Mechanic, u64) -> bool>( - &self, - start: u64, - stop: u64, - mut filter: F, - ) -> u32 { - self.inner - .between_only(&start, &stop, |(a, b)| filter(a, *b)) - .0 - } -} - -impl fmt::Debug for MechanicLog { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "MechanicLog {{ ... }}") - } -} |