diff options
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | src/main.rs | 42 | 
2 files changed, 27 insertions, 18 deletions
| diff --git a/CHANGELOG.md b/CHANGELOG.md index 9822318..7c09a27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ All notable changes to this project will be documented in this file.  - The exit code will now be dependent on whether logs matching the filter were    found or not. +### Fixed +- Fight outcomes for some logs (2nd/3rd/... kill in a week) have been fixed. +  ## 1.2.0 - 2020-05-16  ### Added  - An indicator for whether a fight was done with Challenge Mote activated. diff --git a/src/main.rs b/src/main.rs index 674d128..0915f42 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ use structopt::StructOpt;  use walkdir::{DirEntry, WalkDir};  use evtclib::raw::parser::PartialEvtc; -use evtclib::{Boss, Event, EventKind, Log}; +use evtclib::{Boss, EventKind, Log, Outcome};  mod fexpr;  mod filters; @@ -212,15 +212,13 @@ pub enum FightOutcome {      Wipe,  } -/// A stripped version of [`LogResult`][LogResult] that is available early in the parsing process. -/// -/// This can be used by filters to filter out logs early, before they will be fully parsed. -#[derive(Debug, Clone)] -pub struct EarlyLogResult { -    /// The path to the log file. -    log_file: PathBuf, -    /// The partially parsed evtc. -    evtc: PartialEvtc, +impl From<Outcome> for FightOutcome { +    fn from(outcome: Outcome) -> Self { +        match outcome { +            Outcome::Success => FightOutcome::Success, +            Outcome::Failure => FightOutcome::Wipe, +        } +    }  }  impl FromStr for FightOutcome { @@ -235,6 +233,17 @@ impl FromStr for FightOutcome {      }  } +/// A stripped version of [`LogResult`][LogResult] that is available early in the parsing process. +/// +/// This can be used by filters to filter out logs early, before they will be fully parsed. +#[derive(Debug, Clone)] +pub struct EarlyLogResult { +    /// The path to the log file. +    log_file: PathBuf, +    /// The partially parsed evtc. +    evtc: PartialEvtc, +} +  enum ZipWrapper<R: Read + Seek> {      Raw(Option<R>),      Zipped(zip::ZipArchive<R>), @@ -592,16 +601,13 @@ fn get_guild_mapping(log: &Log) -> HashMap<u64, String> {  /// Get the outcome of the fight.  fn get_fight_outcome(log: &Log) -> FightOutcome { -    if log.was_rewarded() { -        FightOutcome::Success -    } else { -        FightOutcome::Wipe -    } +    log.analyzer() +        .and_then(|a| a.outcome()) +        .map(Into::into) +        .unwrap_or(FightOutcome::Wipe)  }  /// Get the duration of the fight.  fn get_fight_duration(log: &Log) -> Duration { -    let start = log.events().first().map(Event::time).unwrap_or(0) as i64; -    let end = log.events().last().map(Event::time).unwrap_or(0) as i64; -    Duration::milliseconds(end - start) +    Duration::milliseconds(log.span() as i64)  } | 
