From 14b6a38e61b2e7b6d3d21a350283b3ec60a757ea Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 23 Sep 2020 15:40:52 +0200 Subject: re-introduce Boss This is now the enum that contains the IDs of the single bosses, like Nikare and Kenut. This means we can do away with the NIKARE_ID and such. The enum is not publicly re-exported, as we re-export Encounter (which is more of a replacement of the old Boss). Special casing still remains (mostly in lib.rs), but we should be able to do away with this now with a more general Encounter::bosses and Boss::encounter methods. --- src/analyzers/raids/w6.rs | 6 +- src/gamedata.rs | 151 +++++++++++++++++++++++++++++++--------------- src/lib.rs | 12 ++-- 3 files changed, 112 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/src/analyzers/raids/w6.rs b/src/analyzers/raids/w6.rs index 11fd02e..97a2094 100644 --- a/src/analyzers/raids/w6.rs +++ b/src/analyzers/raids/w6.rs @@ -1,7 +1,7 @@ //! Boss fight analyzers for Wing 6 (Mythwright Gambit) use crate::{ analyzers::{helpers, Analyzer, Outcome}, - gamedata::{KENUT_ID, NIKARE_ID}, + gamedata::Boss, EventKind, Log, }; @@ -100,9 +100,9 @@ impl<'log> Analyzer for TwinLargos<'log> { continue; }; - if agent.id() == NIKARE_ID { + if agent.id() == Boss::Nikare as u16 { nikare_dead = true; - } else if agent.id() == KENUT_ID { + } else if agent.id() == Boss::Kenut as u16 { kenut_dead = true; } } diff --git a/src/gamedata.rs b/src/gamedata.rs index d307802..1f38b0e 100644 --- a/src/gamedata.rs +++ b/src/gamedata.rs @@ -16,59 +16,60 @@ use thiserror::Error; /// inducing a breaking change. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, FromPrimitive)] #[non_exhaustive] +#[repr(u16)] pub enum Encounter { // Wing 1 - ValeGuardian = 0x3C4E, - Gorseval = 0x3C45, - Sabetha = 0x3C0F, + ValeGuardian = Boss::ValeGuardian as u16, + Gorseval = Boss::Gorseval as u16, + Sabetha = Boss::Sabetha as u16, // Wing 2 - Slothasor = 0x3EFB, - Matthias = 0x3EF3, + Slothasor = Boss::Slothasor as u16, + Matthias = Boss::Matthias as u16, // Wing 3 - KeepConstruct = 0x3F6B, - Xera = 0x3F76, + KeepConstruct = Boss::KeepConstruct as u16, + Xera = Boss::Xera as u16, // Wing 4 - Cairn = 0x432A, - MursaatOverseer = 0x4314, - Samarog = 0x4324, - Deimos = 0x4302, + Cairn = Boss::Cairn as u16, + MursaatOverseer = Boss::MursaatOverseer as u16, + Samarog = Boss::Samarog as u16, + Deimos = Boss::Deimos as u16, // Wing 5 - SoullessHorror = 0x4D37, - VoiceInTheVoid = 0x4BFA, + SoullessHorror = Boss::SoullessHorror as u16, + VoiceInTheVoid = Boss::Dhuum as u16, // Wing 6 - ConjuredAmalgamate = 0xABC6, - TwinLargos = 0x5271, - Qadim = 0x51C6, + ConjuredAmalgamate = Boss::ConjuredAmalgamate as u16, + TwinLargos = Boss::Nikare as u16, + Qadim = Boss::Qadim as u16, // Wing 7 - CardinalAdina = 0x55F6, - CardinalSabir = 0x55CC, - QadimThePeerless = 0x55F0, + CardinalAdina = Boss::CardinalAdina as u16, + CardinalSabir = Boss::CardinalSabir as u16, + QadimThePeerless = Boss::QadimThePeerless as u16, // 100 CM (Sunqua Peak) - Ai = 0x5AD6, + Ai = Boss::Ai as u16, // 99 CM (Shattered Observatory) - Skorvald = 0x44E0, - Artsariiv = 0x461D, - Arkk = 0x455F, + Skorvald = Boss::Skorvald as u16, + Artsariiv = Boss::Artsariiv as u16, + Arkk = Boss::Arkk as u16, // 98 CM (Nightmare) - MAMA = 0x427D, - Siax = 0x4284, - Ensolyss = 0x4234, + MAMA = Boss::MAMA as u16, + Siax = Boss::Siax as u16, + Ensolyss = Boss::Ensolyss as u16, // Strike missions - IcebroodConstruct = 0x568A, - SuperKodanBrothers = 0x5747, - FraenirOfJormag = 0x57DC, - Boneskinner = 0x57F9, - WhisperOfJormag = 0x58B7, + IcebroodConstruct = Boss::IcebroodConstruct as u16, + SuperKodanBrothers = Boss::VoiceOfTheFallen as u16, + FraenirOfJormag = Boss::FraenirOfJormag as u16, + Boneskinner = Boss::Boneskinner as u16, + WhisperOfJormag = Boss::WhisperOfJormag as u16, } /// Error for when converting a string to an encounter fails. @@ -168,23 +169,79 @@ impl Display for Encounter { } } -/// ID for Xera in the second phase. +/// Enum containing all boss IDs. +/// +/// For a high-level event categorization, take a look at the [`Encounter`] enum. The IDs listed +/// here are for a more fine-grained control, i.e. if you need to check a specific boss for +/// something. /// -/// The original Xera will despawn, and after the tower phase, a separate spawn -/// will take over. This new Xera will have this ID. Care needs to be taken when -/// calculating boss damage on this encounter, as both Xeras have to be taken -/// into account. -pub const XERA_PHASE2_ID: u16 = 0x3F9E; - -/// The ID of Nikare in the Twin Largos fight. -pub const NIKARE_ID: u16 = Encounter::TwinLargos as u16; -/// The ID of Kenut in the Twin Largos fight. -pub const KENUT_ID: u16 = 21089; - -/// The ID of the Voice of the Fallen. -pub const VOICE_OF_THE_FALLEN_ID: u16 = Encounter::SuperKodanBrothers as u16; -/// The ID of the Claw of the Fallen. -pub const CLAW_OF_THE_FALLEN_ID: u16 = 22481; +/// This enum is non-exhaustive to ensure that future added bosses can be added without +/// inducing a breaking change. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, FromPrimitive)] +#[non_exhaustive] +#[repr(u16)] +pub enum Boss { + // Wing 1 + ValeGuardian = 0x3C4E, + Gorseval = 0x3C45, + Sabetha = 0x3C0F, + + // Wing 2 + Slothasor = 0x3EFB, + Matthias = 0x3EF3, + + // Wing 3 + KeepConstruct = 0x3F6B, + Xera = 0x3F76, + /// ID for Xera in the second phase. + /// + /// The original Xera will despawn, and after the tower phase, a separate spawn will take over. + /// This new Xera will have this ID. Care needs to be taken when calculating boss damage on + /// this encounter, as both Xeras have to be taken into account. + Xera2 = 0x3F9E, + + // Wing 4 + Cairn = 0x432A, + MursaatOverseer = 0x4314, + Samarog = 0x4324, + Deimos = 0x4302, + + // Wing 5 + SoullessHorror = 0x4D37, + Dhuum = 0x4BFA, + + // Wing 6 + ConjuredAmalgamate = 0xABC6, + Nikare = 0x5271, + Kenut = 0x5261, + Qadim = 0x51C6, + + // Wing 7 + CardinalAdina = 0x55F6, + CardinalSabir = 0x55CC, + QadimThePeerless = 0x55F0, + + // 100 CM (Sunqua Peak) + Ai = 0x5AD6, + + // 99 CM (Shattered Observatory) + Skorvald = 0x44E0, + Artsariiv = 0x461D, + Arkk = 0x455F, + + // 98 CM (Nightmare) + MAMA = 0x427D, + Siax = 0x4284, + Ensolyss = 0x4234, + + // Strike missions + IcebroodConstruct = 0x568A, + VoiceOfTheFallen = 0x5747, + ClawOfTheFallen = 0x57D1, + FraenirOfJormag = 0x57DC, + Boneskinner = 0x57F9, + WhisperOfJormag = 0x58B7, +} /// Error for when converting a string to a profession fails. #[derive(Debug, Clone, PartialEq, Eq, Hash, Error)] diff --git a/src/lib.rs b/src/lib.rs index 75bf313..764f8ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,6 +104,7 @@ mod processing; pub use processing::{process, process_file, process_stream, Compression}; pub mod gamedata; +use gamedata::Boss; pub use gamedata::{EliteSpec, Encounter, Profession}; pub mod analyzers; @@ -759,14 +760,11 @@ impl Log { /// agents are needed. pub fn boss_agents(&self) -> Vec<&Agent> { let boss_ids = if self.boss_id == Encounter::Xera as u16 { - vec![self.boss_id, gamedata::XERA_PHASE2_ID] + vec![self.boss_id, Boss::Xera2 as u16] } else if self.boss_id == Encounter::TwinLargos as u16 { - vec![gamedata::NIKARE_ID, gamedata::KENUT_ID] + vec![Boss::Nikare as u16, Boss::Kenut as u16] } else if self.encounter() == Some(Encounter::SuperKodanBrothers) { - vec![ - gamedata::VOICE_OF_THE_FALLEN_ID, - gamedata::CLAW_OF_THE_FALLEN_ID, - ] + vec![Boss::VoiceOfTheFallen as u16, Boss::ClawOfTheFallen as u16] } else { vec![self.boss_id] }; @@ -797,7 +795,7 @@ impl Log { // Sometimes, encounters of the strike mission "Voice of the Fallen and Claw of the Fallen" // are saved with the ID of the Claw and sometimes with the Voice. Therefore, we need to // unify those cases. - if self.boss_id == gamedata::CLAW_OF_THE_FALLEN_ID { + if self.boss_id == Boss::ClawOfTheFallen as u16 { return Some(Encounter::SuperKodanBrothers); } Encounter::from_u16(self.boss_id) -- cgit v1.2.3