diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/filters/log.rs | 3 | ||||
-rw-r--r-- | src/main.rs | 75 | ||||
-rw-r--r-- | src/output/formats.rs | 2 | ||||
-rw-r--r-- | src/playerclass.rs | 41 |
4 files changed, 18 insertions, 103 deletions
diff --git a/src/filters/log.rs b/src/filters/log.rs index 79513d5..8cfdcb4 100644 --- a/src/filters/log.rs +++ b/src/filters/log.rs @@ -33,8 +33,7 @@ impl Filter<EarlyLogResult, LogResult> for BossFilter { } fn filter(&self, log: &LogResult) -> bool { - let boss = Boss::from_u16(log.boss_id); - boss.map(|b| self.0.contains(&b)).unwrap_or(false) + log.boss.map(|b| self.0.contains(&b)).unwrap_or(false) } } diff --git a/src/main.rs b/src/main.rs index e8ed255..ff00732 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::{EventKind, Log}; +use evtclib::{Boss, EventKind, Log}; mod fexpr; mod filters; @@ -132,10 +132,8 @@ pub struct LogResult { log_file: PathBuf, /// The time of the recording. time: DateTime<Utc>, - /// The numeric ID of the boss. - boss_id: u16, - /// The name of the boss. - boss_name: String, + /// The boss. + boss: Option<Boss>, /// A vector of all participating players. players: Vec<Player>, /// The outcome of the fight. @@ -466,16 +464,14 @@ fn search_log(entry: &DirEntry, filter: &dyn LogFilter) -> Result<Option<LogResu /// Extract human-readable information from the given log file. fn extract_info(entry: &DirEntry, log: &Log) -> LogResult { - let boss_name = get_encounter_name(log) - .unwrap_or_else(|| { - debug!( - "log file has unknown boss: {:?} (id: {:#x})", - entry.path(), - log.encounter_id() - ); - "unknown" - }) - .into(); + let boss = log.encounter(); + if boss.is_none() { + debug!( + "log file has unknown boss: {:?} (id: {:#x})", + entry.path(), + log.encounter_id() + ); + } let guild_ids = get_guild_mapping(log); @@ -494,8 +490,7 @@ fn extract_info(entry: &DirEntry, log: &Log) -> LogResult { LogResult { log_file: entry.path().to_path_buf(), time: Utc.timestamp(i64::from(log.local_end_timestamp().unwrap_or(0)), 0), - boss_id: log.encounter_id(), - boss_name, + boss, players, outcome: get_fight_outcome(log), is_cm: log.is_cm(), @@ -531,49 +526,3 @@ fn get_fight_outcome(log: &Log) -> FightOutcome { FightOutcome::Wipe } } - -/// Get the (english) name for the given encounter -fn get_encounter_name(log: &Log) -> Option<&'static str> { - use evtclib::Boss; - Some(match log.encounter()? { - Boss::ValeGuardian => "Vale Guardian", - Boss::Gorseval => "Gorseval", - Boss::Sabetha => "Sabetha", - - Boss::Slothasor => "Slothasor", - Boss::Matthias => "Matthias", - - Boss::KeepConstruct => "Keep Construct", - Boss::Xera => "Xera", - - Boss::Cairn => "Cairn", - Boss::MursaatOverseer => "Mursaat Overseer", - Boss::Samarog => "Samarog", - Boss::Deimos => "Deimos", - - Boss::SoullessHorror => "Desmina", - Boss::Dhuum => "Dhuum", - - Boss::ConjuredAmalgamate => "Conjured Amalgamate", - Boss::LargosTwins => "Largos Twins", - Boss::Qadim => "Qadim", - - Boss::CardinalAdina => "Cardinal Adina", - Boss::CardinalSabir => "Cardinal Sabir", - Boss::QadimThePeerless => "Qadim The Peerless", - - Boss::Skorvald => "Skorvald", - Boss::Artsariiv => "Artsariiv", - Boss::Arkk => "Arkk", - - Boss::MAMA => "MAMA", - Boss::Siax => "Siax the Corrupted", - Boss::Ensolyss => "Ensolyss of the Endless Torment", - - Boss::IcebroodConstruct => "Icebrood Construct", - Boss::VoiceOfTheFallen => "Super Kodan Brothers", - Boss::FraenirOfJormag => "Fraenir of Jormag", - Boss::Boneskinner => "Boneskinner", - Boss::WhisperOfJormag => "Whisper of Jormag", - }) -} diff --git a/src/output/formats.rs b/src/output/formats.rs index 203502a..e7008ee 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_name, + item.boss.map(|x| x.to_string()).unwrap_or_else(|| "unknown".into()), if item.is_cm { " CM" } else { "" }, outcome, ) diff --git a/src/playerclass.rs b/src/playerclass.rs index 247e8b1..31a49aa 100644 --- a/src/playerclass.rs +++ b/src/playerclass.rs @@ -67,43 +67,10 @@ impl From<&evtclib::Player> for PlayerClass { impl fmt::Display for PlayerClass { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use EliteSpec::*; - use Profession::*; - - let name = match *self { - PlayerClass::EliteSpec(elite) => match elite { - Dragonhunter => "Dragonhunter", - Firebrand => "Firebrand", - Berserker => "Berserker", - Spellbreaker => "Spellbreaker", - Herald => "Herald", - Renegade => "Renegade", - Scrapper => "Scrapper", - Holosmith => "Holosmith", - Druid => "Druid", - Soulbeast => "Soulbeast", - Daredevil => "Daredevil", - Deadeye => "Deadeye", - Tempest => "Tempest", - Weaver => "Weaver", - Chronomancer => "Chronomancer", - Mirage => "Mirage", - Reaper => "Reaper", - Scourge => "Scourge", - }, - PlayerClass::Profession(prof) => match prof { - Guardian => "Guardian", - Warrior => "Warrior", - Revenant => "Revenant", - Engineer => "Engineer", - Ranger => "Ranger", - Thief => "Thief", - Elementalist => "Elementalist", - Mesmer => "Mesmer", - Necromancer => "Necromancer", - }, - }; - write!(f, "{}", name) + match *self { + PlayerClass::EliteSpec(elite) => elite.fmt(f), + PlayerClass::Profession(prof) => prof.fmt(f), + } } } |