diff options
author | Daniel Schadt <kingdread@gmx.de> | 2018-04-23 17:00:14 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2018-04-23 17:00:14 +0200 |
commit | c6cd5dfef5ca037862c79f7abe460e1b88c8dab4 (patch) | |
tree | 5ed70f85bb238184b9f32a9b33b4e721d7dcb1ed | |
parent | 6165bf6e4cfde199c3bc8bd0b862eb7de309aec3 (diff) | |
download | evtclib-c6cd5dfef5ca037862c79f7abe460e1b88c8dab4.tar.gz evtclib-c6cd5dfef5ca037862c79f7abe460e1b88c8dab4.tar.bz2 evtclib-c6cd5dfef5ca037862c79f7abe460e1b88c8dab4.zip |
more documentation
-rw-r--r-- | src/event.rs | 24 | ||||
-rw-r--r-- | src/lib.rs | 14 |
2 files changed, 32 insertions, 6 deletions
diff --git a/src/event.rs b/src/event.rs index f9489e6..0b28147 100644 --- a/src/event.rs +++ b/src/event.rs @@ -104,18 +104,39 @@ pub enum EventKind { }, } +/// A higher-level representation of a combat event. #[derive(Clone, Debug, PartialEq, Eq)] pub struct Event { + /// The time when the event happened. + /// + /// This are the milliseconds since Windows has been started (`timeGetTime()`). pub time: u64, + /// The kind of the event. pub kind: EventKind, + /// Whether the agent had more than 90% of its health. + /// + /// This is the scholar threshold. pub is_ninety: bool, + /// Whether the target health was below 50%. + /// + /// This is the threshold for many runes and trait damage modifiers (e.g. + /// *Bolt to the Heart*). pub is_fifty: bool, + /// Whether the source agent was moving. pub is_moving: bool, + /// Whether the source agent was flanking the target. pub is_flanking: bool, + /// Whether some (or all) damage was mitigated by shields. pub is_shields: bool, } impl Event { + /// Transform a raw event to a "high-level" event. + /// + /// If the event is not known, or some other error occured, `None` is + /// returned. + /// + /// * `raw_event` - the raw event to transform. pub fn from_raw(raw_event: &raw::CbtEvent) -> Option<Event> { use raw::CbtStateChange; let kind = match raw_event.is_statechange { @@ -211,6 +232,7 @@ fn check_activation(raw_event: &raw::CbtEvent) -> Option<EventKind> { CbtActivation::CancelFire => Activation::CancelFire(raw_event.value), CbtActivation::CancelCancel => Activation::CancelCancel(raw_event.value), CbtActivation::Reset => Activation::Reset, + // Already checked and handled above CbtActivation::None => unreachable!(), }, }), @@ -290,7 +312,7 @@ pub enum WeaponSet { impl WeaponSet { /// Parse a given integer into the correct enum value. - pub fn from_u64(value: u64) -> WeaponSet { + fn from_u64(value: u64) -> WeaponSet { match value { // magic constants from arcdps README 0 => WeaponSet::Water0, @@ -118,13 +118,17 @@ impl Log { } /// Return an iterator over all agents that represent player characters. - pub fn players(&self) -> impl Iterator<Item=&Agent> { - self.agents.iter().filter(|a| matches!(a.kind, AgentKind::Player { .. })) + pub fn players(&self) -> impl Iterator<Item = &Agent> { + self.agents + .iter() + .filter(|a| matches!(a.kind, AgentKind::Player { .. })) } /// Return an iterator over all agents that are NPCs. - pub fn npcs(&self) -> impl Iterator<Item=&Agent> { - self.agents.iter().filter(|a| matches!(a.kind, AgentKind::Character(_))) + pub fn npcs(&self) -> impl Iterator<Item = &Agent> { + self.agents + .iter() + .filter(|a| matches!(a.kind, AgentKind::Character(_))) } /// Return all events present in this log. @@ -135,7 +139,7 @@ impl Log { pub fn process(data: &raw::Evtc) -> Result<Log, EvtcError> { // Prepare "augmented" agents - let mut agents = setup_agents(data)?; + let mut agents = setup_agents(data)?; // Do the first aware/last aware field set_agent_awares(data, &mut agents)?; |