From dcf1b948b953fb17db16eafcdd30f0a25301171f Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Thu, 23 Jul 2020 17:18:56 +0200 Subject: implement Analyzer::outcome for wing 6 --- src/analyzers/raids/w6.rs | 54 +++++++++++++++++++++++++++++++++++++++++++++-- src/gamedata.rs | 9 ++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/analyzers/raids/w6.rs b/src/analyzers/raids/w6.rs index c4e5b1a..cc39403 100644 --- a/src/analyzers/raids/w6.rs +++ b/src/analyzers/raids/w6.rs @@ -1,10 +1,12 @@ //! Boss fight analyzers for Wing 6 (Mythwright Gambit) use crate::{ - analyzers::{helpers, Analyzer}, - Log, + analyzers::{helpers, Analyzer, Outcome}, + gamedata::{KENUT_ID, NIKARE_ID}, + EventKind, Log, }; pub const CA_CM_BUFF: u32 = 53_075; +pub const ZOMMOROS_ID: u16 = 21_118; /// Analyzer for the first fight of Wing 6, Conjured Amalgamate. /// @@ -28,6 +30,23 @@ impl<'log> Analyzer for ConjuredAmalgamate<'log> { fn is_cm(&self) -> bool { helpers::buff_present(self.log, CA_CM_BUFF) } + + fn outcome(&self) -> Option { + for event in self.log.events() { + if let EventKind::Spawn { agent_addr } = event.kind() { + if self + .log + .agent_by_addr(*agent_addr) + .and_then(|a| a.as_character()) + .map(|a| a.id() == ZOMMOROS_ID) + .unwrap_or(false) + { + return Some(Outcome::Success); + } + } + } + Some(Outcome::Failure) + } } pub const LARGOS_CM_HEALTH: u64 = 19_200_000; @@ -56,6 +75,33 @@ impl<'log> Analyzer for LargosTwins<'log> { .map(|h| h >= LARGOS_CM_HEALTH) .unwrap_or(false) } + + fn outcome(&self) -> Option { + let mut nikare_dead = false; + let mut kenut_dead = false; + + for event in self.log.events() { + if let EventKind::ChangeDead { agent_addr } = event.kind() { + let agent = if let Some(agent) = self + .log + .agent_by_addr(*agent_addr) + .and_then(|a| a.as_character()) + { + agent + } else { + continue; + }; + + if agent.id() == NIKARE_ID { + nikare_dead = true; + } else if agent.id() == KENUT_ID { + kenut_dead = true; + } + } + } + + Outcome::from_bool(kenut_dead && nikare_dead) + } } pub const QADIM_CM_HEALTH: u64 = 21_100_000; @@ -84,4 +130,8 @@ impl<'log> Analyzer for Qadim<'log> { .map(|h| h >= QADIM_CM_HEALTH) .unwrap_or(false) } + + fn outcome(&self) -> Option { + Outcome::from_bool(helpers::players_exit_after_boss(self.log)) + } } diff --git a/src/gamedata.rs b/src/gamedata.rs index dd11e94..5e83167 100644 --- a/src/gamedata.rs +++ b/src/gamedata.rs @@ -39,6 +39,10 @@ pub enum Boss { // Wing 6 ConjuredAmalgamate = 0xABC6, + /// This is the ID of Nikare, as that is what the Twin Largos logs are identified by. + /// + /// If you want Nikare specifically, consider using [`NIKARE_ID`][NIKARE_ID], and similarly, if + /// you need Kenut, you can use [`KENUT_ID`][KENUT_ID]. LargosTwins = 0x5271, Qadim = 0x51C6, @@ -167,6 +171,11 @@ impl Display for Boss { /// into account. pub const XERA_PHASE2_ID: u16 = 0x3F9E; +/// The ID of Nikare in the Twin Largos fight. +pub const NIKARE_ID: u16 = Boss::LargosTwins as u16; +/// The ID of Kenut in the Twin Largos fight. +pub const KENUT_ID: u16 = 21089; + /// Error for when converting a string to a profession fails. #[derive(Debug, Clone, PartialEq, Eq, Hash, Error)] #[error("Invalid profession identifier: {0}")] -- cgit v1.2.3