diff --git a/client/src/components/game.construct.jsx b/client/src/components/game.construct.jsx index 7e0d3592..68e53cad 100644 --- a/client/src/components/game.construct.jsx +++ b/client/src/components/game.construct.jsx @@ -40,8 +40,11 @@ class GameConstruct extends preact.Component { shouldComponentUpdate(newProps) { if (newProps.activeSkill !== this.props.activeSkill) return true; if (newProps.animFocus !== this.props.animFocus) return true; - if (newProps.resolution !== this.props.resolution) return true; if (newProps.construct !== this.props.construct) return true; + if (newProps.resolution && newProps.resolution !== this.props.resolution) { + const [type, variant] = newProps.resolution.event; + if (variant.construct === this.props.construct.id && type === 'Ko') return true; + } return false; } @@ -56,15 +59,17 @@ class GameConstruct extends preact.Component { player, } = this.props; - const koEvent = resolution && resolution.text === 'KO!' && resolution.constructId === construct.id; - const ko = construct.green_life.value === 0 && !koEvent ? 'ko' : ''; - - const cssClass = () => { - if (koEvent) return 'ko-transition'; - if (animFocus && !animFocus.includes(construct.id)) return 'unfocus'; + const ko = construct.green_life.value === 0 ? 'ko' : ''; + const koEvent = () => { + if (resolution) { + const [type, variant] = resolution.event; + if (variant.construct === construct.id && type === 'Ko') return 'ko-transition'; + } return ''; }; + const unfocus = animFocus && !animFocus.includes(construct.id) ? 'unfocus' : ''; + const crypSkills = player ?
{range(0, 3).map(j => )}
:
; @@ -74,7 +79,7 @@ class GameConstruct extends preact.Component {
selectSkillTarget(construct.id)} style={ activeSkill ? { cursor: 'pointer' } : {}} - class={`game-construct ${ko} ${cssClass()}`}> + class={`game-construct ${ko} ${koEvent()} ${unfocus}`}>
{crypSkills} diff --git a/client/src/components/game.construct.life.jsx b/client/src/components/game.construct.life.jsx index 58eb2023..a7670603 100644 --- a/client/src/components/game.construct.life.jsx +++ b/client/src/components/game.construct.life.jsx @@ -8,8 +8,8 @@ const addState = connect(({ resolution }) => ({ resolution })); class GameConstructLife extends preact.Component { shouldComponentUpdate(newProps) { if (newProps.resolution && newProps.resolution !== this.props.resolution) { - const [type, info] = newProps.resolution.event; - if (info.construct === this.props.construct.id + const [type, variant] = newProps.resolution.event; + if (variant.construct === this.props.construct.id && (type === 'Damage' || type === 'Healing' || type === 'Recharge')) return true; } if (newProps.construct !== this.props.construct) return true; diff --git a/client/src/utils.jsx b/client/src/utils.jsx index 550c69e6..349679c5 100644 --- a/client/src/utils.jsx +++ b/client/src/utils.jsx @@ -240,7 +240,10 @@ function convertItem(v) { } function effectInfo(i) { - const hybridBlast = 25; + // FIX ME + return 'effect info to be fixed'; + + /*const hybridBlast = 25; const hasteStrike = 30; function multiplier(s) { // Update later to use server info in future if (s === 'CounterAttack') return 120; @@ -295,7 +298,7 @@ function effectInfo(i) { case 'Siphon': return `Construct will take ${multiplier(i.tick.skill)}% of caster's BluePower + GreenPower as blue damage each turn, healing the caster.`; default: return 'Missing Effect Text'; - } + }*/ } module.exports = { diff --git a/core/src/game.rs b/core/src/game.rs index b8186743..0483edb3 100644 --- a/core/src/game.rs +++ b/core/src/game.rs @@ -533,8 +533,8 @@ impl Game { for action in cast.actions() { let events = match action { - Action::Cast { construct } => self.cast(construct, cast), - Action::Hit { construct } => self.hit(construct, cast), + Action::Cast => self.cast(cast), + Action::Hit => self.hit(cast), Action::Damage { construct, values, colour } => { let amount = self.calculate_amount(&values, &resolved); @@ -663,12 +663,12 @@ impl Game { // } } - fn cast(&mut self, construct: Uuid, cast: Cast) -> Vec { - vec![Event::Cast { construct, player: cast.player, direction: self.direction(cast) }] + fn cast(&mut self, cast: Cast) -> Vec { + vec![Event::Cast { construct: cast.source, player: cast.player, direction: self.direction(cast) }] } - fn hit(&mut self, construct: Uuid, cast: Cast) -> Vec { - vec![Event::Hit { construct, player: cast.player, direction: self.direction(cast) }] + fn hit(&mut self, cast: Cast) -> Vec { + vec![Event::Hit { construct: cast.target, player: cast.player, direction: self.direction(cast) }] } fn damage(&mut self, construct: Uuid, amount: usize, colour: Colour) -> Vec { @@ -893,8 +893,8 @@ pub enum Value { #[derive(Debug,Clone,PartialEq,Serialize,Deserialize)] pub enum Action { - Hit { construct: Uuid }, - Cast { construct: Uuid }, + Hit, + Cast, Heal { construct: Uuid, values: Vec, colour: Colour }, Damage { construct: Uuid, values: Vec, colour: Colour }, Effect { construct: Uuid, effect: ConstructEffect }, diff --git a/core/src/skill.rs b/core/src/skill.rs index dc53ed98..e4e12d18 100644 --- a/core/src/skill.rs +++ b/core/src/skill.rs @@ -57,10 +57,10 @@ impl Cast { let mut actions = vec![]; if self.skill.cast_animation() { - actions.push(Action::Cast { construct: self.source }); + actions.push(Action::Cast); } - actions.push(Action::Hit { construct: self.target }); + actions.push(Action::Hit); let mut rest = match self.skill { Skill::Attack => vec![ @@ -1616,12 +1616,12 @@ mod tests { let actions = cast.actions(); match actions[0] { - Action::Cast { construct: _ } => (), + Action::Cast => (), _ => panic!("{:?}", actions), }; match actions[1] { - Action::Hit { construct: _ } => (), + Action::Hit => (), _ => panic!("{:?}", actions), };