aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs42
1 files changed, 24 insertions, 18 deletions
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)
}