aboutsummaryrefslogtreecommitdiff
path: root/src/analyzers/mod.rs
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2020-07-23 02:47:52 +0200
committerDaniel Schadt <kingdread@gmx.de>2020-07-23 02:47:52 +0200
commit962e2b9f8e17a50c7d7d37a424591b0df62f265c (patch)
tree61efe53eae3768aca9d5ce1eb89c91f5adaceeba /src/analyzers/mod.rs
parent0978345648cf9cdad6222f583dd21497b409d07e (diff)
downloadevtclib-962e2b9f8e17a50c7d7d37a424591b0df62f265c.tar.gz
evtclib-962e2b9f8e17a50c7d7d37a424591b0df62f265c.tar.bz2
evtclib-962e2b9f8e17a50c7d7d37a424591b0df62f265c.zip
implement proper outcome for w1-w4
It turns out that `was_rewarded` is a pretty bad heuristic if you ever kill a boss a second time per week (basically, was_rewarded=false does not imply that the boss was unsuccessful). Therefore, we need a proper detection of when a fight failed and when a fight succeeded. This is the first batch that implements this as part of the Analyzer trait for bosses of wings 1 to 4.
Diffstat (limited to 'src/analyzers/mod.rs')
-rw-r--r--src/analyzers/mod.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/analyzers/mod.rs b/src/analyzers/mod.rs
index 5ad88ec..c440136 100644
--- a/src/analyzers/mod.rs
+++ b/src/analyzers/mod.rs
@@ -23,6 +23,33 @@ pub mod fractals;
pub mod helpers;
pub mod raids;
+/// The outcome of a fight.
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Outcome {
+ /// The fight succeeded.
+ Success,
+ /// The fight failed, i.e. the group wiped.
+ Failure,
+}
+
+impl Outcome {
+ /// A function that turns a boolean into an [`Outcome`][Outcome].
+ ///
+ /// This is a convenience function that can help implementing
+ /// [`Analyzer::outcome`][Analyzer::outcome], which is also why this function returns an Option
+ /// instead of the outcome directly.
+ ///
+ /// This turns `true` into [`Outcome::Success`][Outcome::Success] and `false` into
+ /// [`Outcome::Failure`][Outcome::Failure].
+ pub fn from_bool(b: bool) -> Option<Outcome> {
+ if b {
+ Some(Outcome::Success)
+ } else {
+ Some(Outcome::Failure)
+ }
+ }
+}
+
/// An [`Analyzer`][Analyzer] is something that implements fight-dependent analyzing of the log.
pub trait Analyzer {
/// Returns a reference to the log being analyzed.
@@ -30,6 +57,14 @@ pub trait Analyzer {
/// Checks whether the fight was done with the challenge mote activated.
fn is_cm(&self) -> bool;
+
+ /// Returns the outcome of the fight.
+ ///
+ /// Note that not all logs need to have an outcome, e.g. WvW or Golem logs may return `None`
+ /// here.
+ fn outcome(&self) -> Option<Outcome> {
+ None
+ }
}
/// Returns the correct [`Analyzer`][Analyzer] for the given log file.
@@ -39,6 +74,15 @@ pub fn for_log<'l>(log: &'l Log) -> Option<Box<dyn Analyzer + 'l>> {
let boss = log.encounter()?;
match boss {
+ Boss::ValeGuardian | Boss::Gorseval | Boss::Sabetha => {
+ Some(Box::new(raids::GenericRaid::new(log)))
+ }
+
+ Boss::Slothasor | Boss::Matthias => Some(Box::new(raids::GenericRaid::new(log))),
+
+ Boss::KeepConstruct => Some(Box::new(raids::GenericRaid::new(log))),
+ Boss::Xera => Some(Box::new(raids::Xera::new(log))),
+
Boss::Cairn => Some(Box::new(raids::Cairn::new(log))),
Boss::MursaatOverseer => Some(Box::new(raids::MursaatOverseer::new(log))),
Boss::Samarog => Some(Box::new(raids::Samarog::new(log))),