aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2018-06-14 17:26:23 +0200
committerDaniel Schadt <kingdread@gmx.de>2018-06-14 17:26:23 +0200
commit9f6f3db682ab927fef4f1399d13c4cfc91313f82 (patch)
treebef44f963e1822b837049fe87642609948243578 /src/lib.rs
parentaac51cfaf15659e9447a79032dea5c05e0441709 (diff)
downloadevtclib-9f6f3db682ab927fef4f1399d13c4cfc91313f82.tar.gz
evtclib-9f6f3db682ab927fef4f1399d13c4cfc91313f82.tar.bz2
evtclib-9f6f3db682ab927fef4f1399d13c4cfc91313f82.zip
deal with multiple boss agents
Exemplary done with Xera.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index c81a519..ab32bd1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -35,6 +35,8 @@ pub use event::{Event, EventKind};
pub mod statistics;
+use statistics::gamedata::{self, Boss};
+
/// A macro that returns `true` when the given expression matches the pattern.
///
/// ```rust
@@ -165,12 +167,35 @@ impl Log {
}
/// Return the boss agent.
+ ///
+ /// Be careful with encounters that have multiple boss agents, such as Trio
+ /// and Xera.
pub fn boss(&self) -> &Agent {
self.npcs()
.find(|n| matches!(n.kind, AgentKind::Character(x) if x == self.boss_id))
.expect("Boss has no agent!")
}
+ /// Return all boss agents.
+ ///
+ /// 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 {
+ vec![self.boss_id]
+ };
+ self.npcs()
+ .filter(|a| matches!(a.kind, AgentKind::Character(x) if boss_ids.contains(&x)))
+ .collect()
+ }
+
+ /// Check whether the given address is a boss agent.
+ pub fn is_boss(&self, addr: u64) -> bool {
+ self.boss_agents().into_iter().any(|a| *a.addr() == addr)
+ }
+
/// Return all events present in this log.
pub fn events(&self) -> &[Event] {
&self.events