From e3dacb69c022107596e0e1483f2be981c8da0dc7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 15 Oct 2018 14:03:27 +0200 Subject: 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) --- src/main.rs | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) (limited to 'src') 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, 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()); - "" - }.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) { -- cgit v1.2.3