aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2020-05-02 14:19:27 +0200
committerDaniel Schadt <kingdread@gmx.de>2020-05-02 14:19:27 +0200
commit8b14355557ca7bf19318d0f8d4b54ce439cdc8c8 (patch)
tree8dcfe07121c6d259cf7f9624eb670a85763502bc /src
parent69f8feb33465de6213963c1aadf955704bb83a08 (diff)
downloadevtclib-8b14355557ca7bf19318d0f8d4b54ce439cdc8c8.tar.gz
evtclib-8b14355557ca7bf19318d0f8d4b54ce439cdc8c8.tar.bz2
evtclib-8b14355557ca7bf19318d0f8d4b54ce439cdc8c8.zip
use getters for Event
Diffstat (limited to 'src')
-rw-r--r--src/event.rs24
-rw-r--r--src/lib.rs10
2 files changed, 21 insertions, 13 deletions
diff --git a/src/event.rs b/src/event.rs
index 6dc6591..072c7d5 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -7,6 +7,7 @@ use std::convert::TryFrom;
use std::io;
use byteorder::{BigEndian, WriteBytesExt};
+use getset::{CopyGetters, Getters};
use num_traits::FromPrimitive;
use thiserror::Error;
@@ -201,29 +202,36 @@ pub enum EventKind {
///
/// Note that if you plan on re-using the raw event afterwards, you should use the implementation
/// that works on a reference instead: `Event::try_from(&raw_event)`.
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, CopyGetters, Getters)]
pub struct Event {
/// The time when the event happened.
///
/// This are the milliseconds since Windows has been started (`timeGetTime()`).
- pub time: u64,
+ #[get_copy = "pub"]
+ time: u64,
/// The kind of the event.
- pub kind: EventKind,
+ #[get = "pub"]
+ kind: EventKind,
/// Whether the agent had more than 90% of its health.
///
/// This is the scholar threshold.
- pub is_ninety: bool,
+ #[get_copy = "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,
+ #[get_copy = "pub"]
+ is_fifty: bool,
/// Whether the source agent was moving.
- pub is_moving: bool,
+ #[get_copy = "pub"]
+ is_moving: bool,
/// Whether the source agent was flanking the target.
- pub is_flanking: bool,
+ #[get_copy = "pub"]
+ is_flanking: bool,
/// Whether some (or all) damage was mitigated by shields.
- pub is_shields: bool,
+ #[get_copy = "pub"]
+ is_shields: bool,
}
impl TryFrom<raw::CbtEvent> for Event {
diff --git a/src/lib.rs b/src/lib.rs
index 8f7d9d1..cc407e8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -773,9 +773,9 @@ impl Log {
self.events().iter().find_map(|e| {
if let EventKind::LogStart {
local_timestamp, ..
- } = e.kind
+ } = e.kind()
{
- Some(local_timestamp)
+ Some(*local_timestamp)
} else {
None
}
@@ -791,9 +791,9 @@ impl Log {
self.events().iter().find_map(|e| {
if let EventKind::LogEnd {
local_timestamp, ..
- } = e.kind
+ } = e.kind()
{
- Some(local_timestamp)
+ Some(*local_timestamp)
} else {
None
}
@@ -806,7 +806,7 @@ impl Log {
/// (`false`).
pub fn was_rewarded(&self) -> bool {
self.events().iter().any(|e| {
- if let EventKind::Reward { .. } = e.kind {
+ if let EventKind::Reward { .. } = e.kind() {
true
} else {
false