aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs50
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) {