diff options
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 33 | 
1 files changed, 10 insertions, 23 deletions
| @@ -104,7 +104,8 @@ mod processing;  pub use processing::{process, process_file, process_stream, Compression};  pub mod gamedata; -pub use gamedata::{Boss, EliteSpec, Profession}; +use gamedata::Boss; +pub use gamedata::{EliteSpec, Encounter, Profession};  pub mod analyzers;  pub use analyzers::{Analyzer, Outcome}; @@ -758,20 +759,12 @@ 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 { -            vec![self.boss_id, gamedata::XERA_PHASE2_ID] -        } else if self.boss_id == Boss::LargosTwins as u16 { -            vec![gamedata::NIKARE_ID, gamedata::KENUT_ID] -        } else if self.encounter() == Some(Boss::VoiceOfTheFallen) { -            vec![ -                gamedata::VOICE_OF_THE_FALLEN_ID, -                gamedata::CLAW_OF_THE_FALLEN_ID, -            ] -        } 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()      } @@ -791,16 +784,10 @@ 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<Boss> { -        // 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); -        } -        Boss::from_u16(self.boss_id) +    pub fn encounter(&self) -> Option<Encounter> { +        Boss::from_u16(self.boss_id).map(Boss::encounter)      }      /// Return an analyzer suitable to analyze the given log. | 
