aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2018-06-10 11:55:59 +0200
committerDaniel Schadt <kingdread@gmx.de>2018-06-10 12:04:58 +0200
commit812a3d3d42aea4b1f53bfa47982fd35a070a4612 (patch)
treecfbfb038e24a4040d503c6bdc6c2e071798be203 /src/event.rs
parent877549baca100d534c1272000b2af7a8b364cd35 (diff)
downloadevtclib-812a3d3d42aea4b1f53bfa47982fd35a070a4612.tar.gz
evtclib-812a3d3d42aea4b1f53bfa47982fd35a070a4612.tar.bz2
evtclib-812a3d3d42aea4b1f53bfa47982fd35a070a4612.zip
first iteration of multiplexer
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/event.rs b/src/event.rs
index 02f4686..f87688e 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -104,6 +104,73 @@ pub enum EventKind {
},
}
+impl EventKind {
+ /// Returns the source agent address for this event, if one exists.
+ pub fn source_agent_addr(&self) -> Option<u64> {
+ use EventKind::*;
+ match *self {
+ EnterCombat { agent_addr, .. } => return Some(agent_addr),
+ ExitCombat { agent_addr } => return Some(agent_addr),
+ ChangeUp { agent_addr } => return Some(agent_addr),
+ ChangeDown { agent_addr } => return Some(agent_addr),
+ ChangeDead { agent_addr } => return Some(agent_addr),
+ Spawn { agent_addr } => return Some(agent_addr),
+ Despawn { agent_addr } => return Some(agent_addr),
+ HealthUpdate { agent_addr, .. } => return Some(agent_addr),
+ WeaponSwap { agent_addr, .. } => return Some(agent_addr),
+ MaxHealthUpdate { agent_addr, .. } => return Some(agent_addr),
+ PointOfView { agent_addr } => return Some(agent_addr),
+ SkillUse {
+ source_agent_addr, ..
+ } => return Some(source_agent_addr),
+ ConditionTick {
+ source_agent_addr, ..
+ } => return Some(source_agent_addr),
+ InvulnTick {
+ source_agent_addr, ..
+ } => return Some(source_agent_addr),
+ Physical {
+ source_agent_addr, ..
+ } => return Some(source_agent_addr),
+ BuffApplication {
+ source_agent_addr, ..
+ } => return Some(source_agent_addr),
+ BuffRemove {
+ source_agent_addr, ..
+ } => return Some(source_agent_addr),
+ _ => return None,
+ }
+ }
+
+ /// Returns the destination agent address for this event, if one exists.
+ pub fn destination_agent_addr(&self) -> Option<u64> {
+ use EventKind::*;
+ match *self {
+ ConditionTick {
+ destination_agent_addr,
+ ..
+ } => return Some(destination_agent_addr),
+ InvulnTick {
+ destination_agent_addr,
+ ..
+ } => return Some(destination_agent_addr),
+ Physical {
+ destination_agent_addr,
+ ..
+ } => return Some(destination_agent_addr),
+ BuffApplication {
+ destination_agent_addr,
+ ..
+ } => return Some(destination_agent_addr),
+ BuffRemove {
+ destination_agent_addr,
+ ..
+ } => return Some(destination_agent_addr),
+ _ => return None,
+ }
+ }
+}
+
/// A higher-level representation of a combat event.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Event {