From 89fb27d858d647868a390fb14e7c5230985b44a9 Mon Sep 17 00:00:00 2001 From: Mashy Date: Tue, 10 Dec 2019 18:38:34 +1000 Subject: [PATCH] fix healing event, remove brackets --- client/src/components/game.construct.life.jsx | 2 +- core/src/construct.rs | 21 +++++++++++++++++-- core/src/game.rs | 21 ++++++++----------- core/src/skill.rs | 2 +- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/client/src/components/game.construct.life.jsx b/client/src/components/game.construct.life.jsx index a7670603..6a2cd37b 100644 --- a/client/src/components/game.construct.life.jsx +++ b/client/src/components/game.construct.life.jsx @@ -10,7 +10,7 @@ class GameConstructLife extends preact.Component { if (newProps.resolution && newProps.resolution !== this.props.resolution) { const [type, variant] = newProps.resolution.event; if (variant.construct === this.props.construct.id - && (type === 'Damage' || type === 'Healing' || type === 'Recharge')) return true; + && (type === 'Damage' || type === 'Healing')) return true; } if (newProps.construct !== this.props.construct) return true; return false; diff --git a/core/src/construct.rs b/core/src/construct.rs index f162c8d3..d5cdd827 100644 --- a/core/src/construct.rs +++ b/core/src/construct.rs @@ -607,6 +607,7 @@ impl Construct { construct, amount: green_healing, overhealing: 0, + display: EventConstruct::new(self), colour: Colour::Green } ); @@ -618,6 +619,7 @@ impl Construct { construct, amount: recharge, overhealing, + display: EventConstruct::new(self), colour: Colour::Red } ); @@ -681,6 +683,7 @@ impl Construct { construct, amount: green_healing, overhealing: 0, + display: EventConstruct::new(self), colour: Colour::Green } ); @@ -692,6 +695,7 @@ impl Construct { construct, amount: recharge, overhealing, + display: EventConstruct::new(self), colour: Colour::Blue } ); @@ -731,7 +735,13 @@ impl Construct { let overhealing = modified_amount - healing; if healing != 0 { - events.push(Event::Healing { construct: self.id, amount: healing, overhealing, colour: Colour::Red }); + events.push(Event::Healing { + construct: self.id, + amount: healing, + overhealing, + display: EventConstruct::new(self), + colour: Colour::Red + }); } }, true => { @@ -786,6 +796,7 @@ impl Construct { amount: healing, overhealing, colour: Colour::Green, + display: EventConstruct::new(self), }); }, true => { @@ -832,7 +843,13 @@ impl Construct { let overhealing = modified_amount - healing; if healing != 0 { - events.push(Event::Healing { construct: self.id, amount: healing, overhealing, colour: Colour::Red }); + events.push(Event::Healing { + construct: self.id, + amount: healing, + overhealing, + colour: Colour::Red, + display: EventConstruct::new(self), + }); } }, true => { diff --git a/core/src/game.rs b/core/src/game.rs index 907c069a..ee232af9 100644 --- a/core/src/game.rs +++ b/core/src/game.rs @@ -449,15 +449,12 @@ impl Game { }; // go through the whole most recent round and modify delays of the resolutions - { - let last = self.resolutions.len() - 1; - let mut iter = self.resolutions[last].iter_mut().peekable(); - while let Some(res) = iter.next() { - res.set_delay(iter.peek()); - r_animation_ms += res.delay; - } + let last = self.resolutions.len() - 1; + let mut iter = self.resolutions[last].iter_mut().peekable(); + while let Some(res) = iter.next() { + res.set_delay(iter.peek()); + r_animation_ms += res.delay; } - // info!("{:#?}", self.casts); // handle cooldowns and statuses @@ -898,7 +895,7 @@ pub enum Event { Effect { construct: Uuid, effect: Effect, duration: u8, display: EventConstruct }, Removal { construct: Uuid, effect: Effect, display: EventConstruct }, - Healing { construct: Uuid, amount: usize, overhealing: usize, colour: Colour }, + Healing { construct: Uuid, amount: usize, overhealing: usize, colour: Colour, display: EventConstruct }, Inversion { construct: Uuid }, Reflection { construct: Uuid }, Ko { construct: Uuid }, @@ -1692,13 +1689,13 @@ mod tests { let resolutions = &game.resolutions[last]; assert!(resolutions.iter().any(|r| match r.event { - Event::Healing { construct, colour, amount, overhealing: _ } => + Event::Healing { construct, colour, amount, overhealing: _, display: _, } => construct == target && amount > 0 && colour == Colour::Green, _ => false, })); assert!(resolutions.iter().any(|r| match r.event { - Event::Healing { construct, colour, amount, overhealing: _ } => + Event::Healing { construct, colour, amount, overhealing: _, display: _ } => construct == target && amount > 0 && colour == Colour::Red, _ => false, })); @@ -1723,7 +1720,7 @@ mod tests { })); assert!(resolutions.iter().any(|r| match r.event { - Event::Healing { construct, colour, amount, overhealing: _ } => + Event::Healing { construct, colour, amount, overhealing: _, display: _ } => construct == source && amount > 0 && colour == Colour::Green, _ => false, })); diff --git a/core/src/skill.rs b/core/src/skill.rs index 60e5c8c1..5bfe2ed9 100644 --- a/core/src/skill.rs +++ b/core/src/skill.rs @@ -732,7 +732,7 @@ impl Cast { values: vec![Value::Stat { construct: self.source, stat: Stat::RedPower, mult: self.skill.multiplier() }], }, Action::Heal { - construct: self.target, + construct: self.source, colour: Colour::Green, values: vec![Value::DamageReceived { construct: self.target, colour: Colour::Red, mult: 50 }], },