From 5ae375078d981e9efb3ac6ea68572f941fc883cf Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 4 Oct 2020 11:48:26 +0200 Subject: update to newest evtclib There's a good chance that this will be evtclib 0.5, so we want to adapt our API usage (mainly replacing evtclib::Boss with evtclib::Encounter). The naming is a bit all over the place now, as we sometimes refer to bosses and sometimes to encounters, but I hope to make a sensible decision at *some point* about what we're actually doing here. --- src/fexpr/grammar.lalrpop | 6 +++--- src/filters/log.rs | 10 +++++----- src/main.rs | 12 ++++++------ src/output/formats.rs | 2 +- src/output/sorting.rs | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/fexpr/grammar.lalrpop b/src/fexpr/grammar.lalrpop index 092407e..6333783 100644 --- a/src/fexpr/grammar.lalrpop +++ b/src/fexpr/grammar.lalrpop @@ -9,7 +9,7 @@ use super::{ DurationProducer, CountProducer, }; -use evtclib::Boss; +use evtclib::Encounter; use std::collections::HashSet; use lalrpop_util::ParseError; @@ -61,7 +61,7 @@ LogPredicate: Box = { "-log-before" => filters::log::log_before(<>), "-log-after" => filters::log::log_after(<>), - "-boss" > => filters::log::boss(<>), + "-boss" > => filters::log::encounter(<>), "-cm" => filters::log::challenge_mote(), "-include" => filters::constant(true), @@ -138,7 +138,7 @@ Weekday: Weekday = { }), } -Boss: Boss = { +Encounter: Encounter = { =>? w.parse().map_err(|_| ParseError::User { error: FError { location: l, diff --git a/src/filters/log.rs b/src/filters/log.rs index 10258a0..bd02b21 100644 --- a/src/filters/log.rs +++ b/src/filters/log.rs @@ -9,7 +9,7 @@ use super::{ use std::collections::HashSet; -use evtclib::Boss; +use evtclib::Encounter; use chrono::{DateTime, Datelike, Utc, Weekday}; use num_traits::FromPrimitive as _; @@ -18,22 +18,22 @@ use num_traits::FromPrimitive as _; pub trait LogFilter = Filter; #[derive(Debug, Clone)] -struct BossFilter(HashSet); +struct BossFilter(HashSet); impl Filter for BossFilter { fn filter_early(&self, early_log: &EarlyLogResult) -> Inclusion { - let boss = Boss::from_u16(early_log.evtc.header.combat_id); + let boss = Encounter::from_u16(early_log.evtc.header.combat_id); boss.map(|b| self.0.contains(&b).into()) .unwrap_or(Inclusion::Exclude) } fn filter(&self, log: &LogResult) -> bool { - log.boss.map(|b| self.0.contains(&b)).unwrap_or(false) + log.encounter.map(|b| self.0.contains(&b)).unwrap_or(false) } } /// A `LogFilter` that only accepts logs with one of the given bosses. -pub fn boss(bosses: HashSet) -> Box { +pub fn encounter(bosses: HashSet) -> Box { Box::new(BossFilter(bosses)) } diff --git a/src/main.rs b/src/main.rs index 0ff9e44..9149b17 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, EventKind, Log, Outcome}; +use evtclib::{Encounter, EventKind, Log, Outcome}; mod fexpr; mod filters; @@ -172,8 +172,8 @@ pub struct LogResult { time: DateTime, /// The duration of the fight. duration: Duration, - /// The boss. - boss: Option, + /// The encounter. + encounter: Option, /// A vector of all participating players. players: Vec, /// The outcome of the fight. @@ -552,8 +552,8 @@ fn search_file(path: &Path, is_zip: bool, filter: &dyn LogFilter) -> Result LogResult { - let boss = log.encounter(); - if boss.is_none() { + let encounter = log.encounter(); + if encounter.is_none() { debug!( "log file has unknown boss: {:?} (id: {:#x})", path, @@ -579,7 +579,7 @@ fn extract_info(path: &Path, log: &Log) -> LogResult { log_file: path.to_path_buf(), time: Utc.timestamp(i64::from(log.local_end_timestamp().unwrap_or(0)), 0), duration: get_fight_duration(log), - boss, + encounter, players, outcome: get_fight_outcome(log), is_cm: log.is_cm(), diff --git a/src/output/formats.rs b/src/output/formats.rs index 560963b..7225da2 100644 --- a/src/output/formats.rs +++ b/src/output/formats.rs @@ -42,7 +42,7 @@ impl Format for HumanReadable { .with_timezone(&Local) .format("%Y-%m-%d %H:%M:%S %a"), "Boss".green(), - item.boss + item.encounter .map(|x| x.to_string()) .unwrap_or_else(|| "unknown".into()), if item.is_cm { " CM" } else { "" }, diff --git a/src/output/sorting.rs b/src/output/sorting.rs index 2a0821c..628a1a8 100644 --- a/src/output/sorting.rs +++ b/src/output/sorting.rs @@ -68,7 +68,7 @@ impl Display for Component { } fn boss_id(log: &LogResult) -> u32 { - log.boss.map(|x| x as u32).unwrap_or(0) + log.encounter.map(|x| x as u32).unwrap_or(0) } impl Component { -- cgit v1.2.3