aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs75
1 files changed, 12 insertions, 63 deletions
diff --git a/src/main.rs b/src/main.rs
index e8ed255..ff00732 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -17,7 +17,7 @@ use structopt::StructOpt;
use walkdir::{DirEntry, WalkDir};
use evtclib::raw::parser::PartialEvtc;
-use evtclib::{EventKind, Log};
+use evtclib::{Boss, EventKind, Log};
mod fexpr;
mod filters;
@@ -132,10 +132,8 @@ pub struct LogResult {
log_file: PathBuf,
/// The time of the recording.
time: DateTime<Utc>,
- /// The numeric ID of the boss.
- boss_id: u16,
- /// The name of the boss.
- boss_name: String,
+ /// The boss.
+ boss: Option<Boss>,
/// A vector of all participating players.
players: Vec<Player>,
/// The outcome of the fight.
@@ -466,16 +464,14 @@ fn search_log(entry: &DirEntry, filter: &dyn LogFilter) -> Result<Option<LogResu
/// Extract human-readable information from the given log file.
fn extract_info(entry: &DirEntry, log: &Log) -> LogResult {
- let boss_name = get_encounter_name(log)
- .unwrap_or_else(|| {
- debug!(
- "log file has unknown boss: {:?} (id: {:#x})",
- entry.path(),
- log.encounter_id()
- );
- "unknown"
- })
- .into();
+ let boss = log.encounter();
+ if boss.is_none() {
+ debug!(
+ "log file has unknown boss: {:?} (id: {:#x})",
+ entry.path(),
+ log.encounter_id()
+ );
+ }
let guild_ids = get_guild_mapping(log);
@@ -494,8 +490,7 @@ fn extract_info(entry: &DirEntry, log: &Log) -> LogResult {
LogResult {
log_file: entry.path().to_path_buf(),
time: Utc.timestamp(i64::from(log.local_end_timestamp().unwrap_or(0)), 0),
- boss_id: log.encounter_id(),
- boss_name,
+ boss,
players,
outcome: get_fight_outcome(log),
is_cm: log.is_cm(),
@@ -531,49 +526,3 @@ 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::Boss;
- Some(match log.encounter()? {
- 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::CardinalAdina => "Cardinal Adina",
- Boss::CardinalSabir => "Cardinal Sabir",
- Boss::QadimThePeerless => "Qadim The Peerless",
-
- Boss::Skorvald => "Skorvald",
- Boss::Artsariiv => "Artsariiv",
- Boss::Arkk => "Arkk",
-
- Boss::MAMA => "MAMA",
- Boss::Siax => "Siax the Corrupted",
- Boss::Ensolyss => "Ensolyss of the Endless Torment",
-
- Boss::IcebroodConstruct => "Icebrood Construct",
- Boss::VoiceOfTheFallen => "Super Kodan Brothers",
- Boss::FraenirOfJormag => "Fraenir of Jormag",
- Boss::Boneskinner => "Boneskinner",
- Boss::WhisperOfJormag => "Whisper of Jormag",
- })
-}