diff options
author | Daniel <kingdread@gmx.de> | 2018-10-15 14:03:27 +0200 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2018-10-15 14:08:04 +0200 |
commit | e3dacb69c022107596e0e1483f2be981c8da0dc7 (patch) | |
tree | f3314494bfa0ba93576760d871c3ffe1198f7635 /src/main.rs | |
parent | 495e2ae7c1275e8cfa9c73686976fb0026dd41f4 (diff) | |
download | raidgrep-e3dacb69c022107596e0e1483f2be981c8da0dc7.tar.gz raidgrep-e3dacb69c022107596e0e1483f2be981c8da0dc7.tar.bz2 raidgrep-e3dacb69c022107596e0e1483f2be981c8da0dc7.zip |
properly use encounter ID to get the name
The previous method was nice because it "just worked" for most of the
bosses, but with the introduction of W6 shenanigans (CA being a gadget,
and Largos Twins being two bosses), the method was a bit unreliable.
Now, the encounter ID that is saved by ArcDPS is used, and a predefined
list of encounter names is consulted, which makes this work better for
most bosses and allows us to change the name when appropriate
(Nightmare Oratuss -> Siax)
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index 76967b8..9e54453 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ extern crate evtclib; extern crate rayon; extern crate regex; extern crate walkdir; +extern crate num_traits; use std::fs::File; use std::io::{self, BufReader}; @@ -17,6 +18,7 @@ use chrono::NaiveDateTime; use regex::Regex; use structopt::StructOpt; use walkdir::{DirEntry, WalkDir}; +use num_traits::cast::FromPrimitive; use evtclib::{AgentKind, AgentName, EventKind, Log}; @@ -263,13 +265,10 @@ fn search_log(entry: &DirEntry, opt: &Opt) -> Result<Option<LogResult>, RuntimeE /// Extract human-readable information from the given log file. fn extract_info(entry: &DirEntry, log: &Log) -> LogResult { - let bosses = log.boss_agents(); - let boss_name = if bosses.len() >= 1 { - unwrap! { AgentName::Single(s) = bosses[0].name() => { s } } - } else { - debug!("log file no boss agents: {:?}", entry.path()); - "<unknown>" - }.into(); + let boss_name = get_encounter_name(log).unwrap_or_else(|| { + debug!("log file has unknown boss: {:?} (id: {:#x})", entry.path(), log.boss_id()); + "unknown" + }).into(); let mut players = log .players() @@ -323,6 +322,43 @@ 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::statistics::gamedata::Boss; + let boss = Boss::from_u16(log.boss_id())?; + Some(match boss { + 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::Skorvald => "Skorvald", + Boss::Artsariiv => "Artsariiv", + Boss::Arkk => "Arkk", + + Boss::MAMA => "MAMA", + Boss::Siax => "Siax the Corrupted", + Boss::Ensolyss => "Ensolyss of the Endless Torment", + }) +} + /// Get the (english) name for the given profession/elite specialization. fn get_profession_name(profession: u32, elite: u32) -> &'static str { match (profession, elite) { |