diff options
| author | troido <troido@protonmail.com> | 2020-03-03 18:06:02 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-03-03 18:06:02 +0100 |
| commit | 986c82723cf9a4adada02287309999f4ebbf94e3 (patch) | |
| tree | acc26dfd3cb604c959d16f4291db2f6f21d242f9 /src/components/messages.rs | |
| parent | 9954b5cbaab27aaffcafa8723dcd5d1c99fa811f (diff) | |
randomise attack damage
Diffstat (limited to 'src/components/messages.rs')
| -rw-r--r-- | src/components/messages.rs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/components/messages.rs b/src/components/messages.rs index a2ecd2f..ae615f1 100644 --- a/src/components/messages.rs +++ b/src/components/messages.rs @@ -32,21 +32,28 @@ impl <M: Message> Inbox<M> { } } -#[derive(Debug, Clone)] -pub struct AttackMessage { - pub damage: i64, - pub attacker: Option<Entity> + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum AttackType { + Attack(i64), + Heal(i64) } -impl AttackMessage { - pub fn new(damage: i64) -> Self { - Self { - damage, - attacker: None +impl AttackType { + pub fn is_hostile(&self) -> bool { + match self { + Self::Attack(_) => true, + Self::Heal(_) => false } } } +#[derive(Debug, Clone)] +pub struct AttackMessage { + pub attacker: Option<Entity>, + pub typ: AttackType +} + impl Message for AttackMessage {} pub type AttackInbox = Inbox<AttackMessage>; |
