From 64a9d8f51f9ba316be2ac38336a74c5667852f58 Mon Sep 17 00:00:00 2001 From: ntr Date: Sat, 7 Dec 2019 16:17:41 +1000 Subject: [PATCH] anims nearly back --- client/src/animations.utils.jsx | 18 ++++++++++-------- .../components/game.construct.anim.text.jsx | 6 +++--- .../components/game.construct.effect.box.jsx | 4 ++-- client/src/components/game.construct.life.jsx | 4 ++-- client/src/events.jsx | 5 +++-- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/client/src/animations.utils.jsx b/client/src/animations.utils.jsx index 5220f3c7..1ba4bf10 100644 --- a/client/src/animations.utils.jsx +++ b/client/src/animations.utils.jsx @@ -2,17 +2,20 @@ const actions = require('./actions'); const { TIMES } = require('./constants'); function setAnimations(r, store, account) { + const { cast, focus, event, delay } = r; + const { source, target, player, skill } = cast; + store.dispatch(actions.setAnimFocus(r.focus)); - if (r.variant[0] === 'Cast') { + if (r.event[0] === 'Cast') { store.dispatch(actions.setAnimText(null)); - const { player } = r.cast; - const { x, y, target } = r.variant[1]; + debugger + const { construct, direction: [x, y] } = r.event[1]; const animY = y && player === account.id ? -1 : y; const animSource = { animation: 'sourceCast', - constructId: target, + constructId: construct, direction: { x, y: animY }, }; store.dispatch(actions.setAnimSource(animSource)); @@ -20,15 +23,14 @@ function setAnimations(r, store, account) { return setTimeout(() => store.dispatch(actions.setAnimSource(null)), TIMES.SOURCE_DURATION_MS); } - if (r.variant[0].includes('Hit')) { + if (r.event[0].includes('Hit')) { store.dispatch(actions.setAnimText(null)); - const { player, skill } = r.cast; - const { x, y, target } = r.variant[1]; + const { construct, direction: [x, y] } = r.event[1]; const animY = y && player === account.id ? -1 : y; const isPlayer = player === account.id; const animTarget = { - constructId: target, + constructId: construct, player: isPlayer, skill, direction: { x, y: animY }, diff --git a/client/src/components/game.construct.anim.text.jsx b/client/src/components/game.construct.anim.text.jsx index b54d9cd1..2c652e53 100644 --- a/client/src/components/game.construct.anim.text.jsx +++ b/client/src/components/game.construct.anim.text.jsx @@ -17,7 +17,7 @@ class AnimText extends preact.Component { componentDidUpdate(prevProps) { const { animText, construct } = this.props; - if (animText && animText !== prevProps.animText && animText.variant[1].target === construct.id) { + if (animText && animText !== prevProps.animText && animText.event[1].construct === construct.id) { anime({ targets: '.combat-text', top: '40%', @@ -29,7 +29,7 @@ class AnimText extends preact.Component { render() { const { construct, animText, itemInfo } = this.props; - if (animText && animText.variant[1].target === construct.id) { + if (animText && animText.event[1].construct === construct.id) { const itemSourceDescription = () => { const itemSource = itemInfo.combos.filter(c => c.item === removeTier(animText.cast.skill)); const itemSourceInfo = itemSource.length @@ -40,7 +40,7 @@ class AnimText extends preact.Component { }; const generateAnimText = () => { - const [type, event] = animText.variant; + const [type, event] = animText.event; if (type === 'Ko') return

KO!

; if (type === 'Disable') { const { disable } = event; diff --git a/client/src/components/game.construct.effect.box.jsx b/client/src/components/game.construct.effect.box.jsx index 598c2ae8..afb97e7b 100644 --- a/client/src/components/game.construct.effect.box.jsx +++ b/client/src/components/game.construct.effect.box.jsx @@ -22,7 +22,7 @@ const addState = connect( class GameConstructEffects extends preact.Component { shouldComponentUpdate(newProps) { if (newProps.animText && newProps.animText !== this.props.animText) { - const [type, info] = newProps.animText.variant; + const [type, info] = newProps.animText.event; if (info.target === this.props.construct.id && (type === 'Effect' || type === 'Removal')) return true; } @@ -56,7 +56,7 @@ class GameConstructEffects extends preact.Component { ); } - const effects = animText ? animText.variant[1].display.effects : construct.effects; + const effects = animText ? animText.event[1].display.effects : construct.effects; const renderEffects = effects.length ? effects.map(c => diff --git a/client/src/components/game.construct.life.jsx b/client/src/components/game.construct.life.jsx index fe2f76a1..340208ab 100644 --- a/client/src/components/game.construct.life.jsx +++ b/client/src/components/game.construct.life.jsx @@ -8,7 +8,7 @@ const addState = connect(({ animText }) => ({ animText })); class GameConstructLife extends preact.Component { shouldComponentUpdate(newProps) { if (newProps.animText && newProps.animText !== this.props.animText) { - const [type, info] = newProps.animText.variant; + const [type, info] = newProps.animText.event; if (info.target === this.props.construct.id && (type === 'Damage' || type === 'Healing' || type === 'Recharge')) return true; } @@ -38,7 +38,7 @@ class GameConstructLife extends preact.Component { }; if (animText) { - const { red, blue, green } = animText.variant[1].display; + const { red, blue, green } = animText.event[1].display; return lifeBars(red, green, blue); } diff --git a/client/src/events.jsx b/client/src/events.jsx index 5230b256..ea02db70 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -82,11 +82,12 @@ function registerEvents(store) { if (animating) return false; if (game && currentGame) { - if (game.events.length !== currentGame.events.length) { + if (game.resolutions.length !== currentGame.resolutions.length) { store.dispatch(actions.setAnimating(true)); store.dispatch(actions.setGameSkillInfo(null)); // stop fetching the game state til animations are done - const newRes = game.events[game.events.length - 1]; + const newRes = game.resolutions[game.resolutions.length - 2]; + console.log(newRes); return eachSeries(newRes, (r, cb) => { const timeout = r.delay; setAnimations(r, store, account);