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) --- Cargo.lock | 1 + Cargo.toml | 1 + src/main.rs | 50 +++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6f5270..fabd3d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -334,6 +334,7 @@ dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "colored 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "evtclib 0.1.0", + "num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 08d01db..0fdb1be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,4 @@ quick-error = "1" colored = "1" chrono = "0.4" rayon = "1" +num-traits = "0.2" 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