aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs50
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<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) {