From 39972d54be41bfc7b8b7f38b1f5a4d60e2453da5 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 23 Sep 2020 15:22:55 +0200 Subject: rename Boss to Encounter This is the first step in differentiating between Encounters and Bosses. It sounds a bit weird at first, but there are some events without any bosses (like the River of Souls), and some events which have multiple bosses (like Twin Largos or the kodan strike mission). If we want to support this better, without relying on extra IDs, special casing and constants (like NIKARE_ID), we should differentiate between Encounters and Bosses. --- src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 0c934ec..75bf313 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,7 +104,7 @@ mod processing; pub use processing::{process, process_file, process_stream, Compression}; pub mod gamedata; -pub use gamedata::{Boss, EliteSpec, Profession}; +pub use gamedata::{EliteSpec, Encounter, Profession}; pub mod analyzers; pub use analyzers::{Analyzer, Outcome}; @@ -758,11 +758,11 @@ impl Log { /// This correctly returns multiple agents on encounters where multiple /// agents are needed. pub fn boss_agents(&self) -> Vec<&Agent> { - let boss_ids = if self.boss_id == Boss::Xera as u16 { + let boss_ids = if self.boss_id == Encounter::Xera as u16 { vec![self.boss_id, gamedata::XERA_PHASE2_ID] - } else if self.boss_id == Boss::LargosTwins as u16 { + } else if self.boss_id == Encounter::TwinLargos as u16 { vec![gamedata::NIKARE_ID, gamedata::KENUT_ID] - } else if self.encounter() == Some(Boss::VoiceOfTheFallen) { + } else if self.encounter() == Some(Encounter::SuperKodanBrothers) { vec![ gamedata::VOICE_OF_THE_FALLEN_ID, gamedata::CLAW_OF_THE_FALLEN_ID, @@ -791,16 +791,16 @@ impl Log { /// /// Some logs don't have an encounter set or have an ID that is unknown to us (for example, if /// people set up arcdps with custom IDs). Therefore, this method can only return the encounter - /// if we know about it in [`Boss`][Boss]. + /// if we know about it in [`Encounter`]. #[inline] - pub fn encounter(&self) -> Option { + pub fn encounter(&self) -> Option { // 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 { - return Some(Boss::VoiceOfTheFallen); + return Some(Encounter::SuperKodanBrothers); } - Boss::from_u16(self.boss_id) + Encounter::from_u16(self.boss_id) } /// Return an analyzer suitable to analyze the given log. -- cgit v1.2.3 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/lib.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/lib.rs') 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 From 43be7f946c71d54e6ca4c8c517560590ad1f5b8a Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 23 Sep 2020 16:17:06 +0200 Subject: add Encounter::bosses and Boss::encounter Those functions can be used to simplify the special case handling that was done in lib.rs on encounters that have multiple bosses. --- src/lib.rs | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 764f8ce..2233c93 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -759,17 +759,9 @@ impl Log { /// This correctly returns multiple agents on encounters where multiple /// 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, Boss::Xera2 as u16] - } else if self.boss_id == Encounter::TwinLargos as u16 { - vec![Boss::Nikare as u16, Boss::Kenut as u16] - } else if self.encounter() == Some(Encounter::SuperKodanBrothers) { - vec![Boss::VoiceOfTheFallen as u16, Boss::ClawOfTheFallen as u16] - } else { - vec![self.boss_id] - }; + let bosses = self.encounter().map(Encounter::bosses).unwrap_or(&[] as &[_]); self.npcs() - .filter(|c| boss_ids.contains(&c.character().id)) + .filter(|c| bosses.iter().any(|boss| *boss as u16 == c.character().id)) .map(Agent::erase) .collect() } @@ -792,13 +784,7 @@ impl Log { /// if we know about it in [`Encounter`]. #[inline] pub fn encounter(&self) -> Option { - // 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 == Boss::ClawOfTheFallen as u16 { - return Some(Encounter::SuperKodanBrothers); - } - Encounter::from_u16(self.boss_id) + Boss::from_u16(self.boss_id).map(Boss::encounter) } /// Return an analyzer suitable to analyze the given log. -- cgit v1.2.3 From 4be9a3bac6fda057e5c95f605c320bec2a278e68 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Mon, 28 Sep 2020 13:19:50 +0200 Subject: fix formatting --- src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 2233c93..ecdc876 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -759,7 +759,10 @@ impl Log { /// This correctly returns multiple agents on encounters where multiple /// agents are needed. pub fn boss_agents(&self) -> Vec<&Agent> { - let bosses = self.encounter().map(Encounter::bosses).unwrap_or(&[] as &[_]); + let bosses = self + .encounter() + .map(Encounter::bosses) + .unwrap_or(&[] as &[_]); self.npcs() .filter(|c| bosses.iter().any(|boss| *boss as u16 == c.character().id)) .map(Agent::erase) -- cgit v1.2.3