From b71cc8fc0fed8df0bd24d26d733785e67788a4b0 Mon Sep 17 00:00:00 2001 From: Mashy Date: Thu, 17 Oct 2019 21:47:55 +1000 Subject: [PATCH] effect descriptions, skill speed in game info, fix block stages --- client/src/actions.jsx | 5 +- client/src/components/game.construct.jsx | 41 +++++++++++---- client/src/components/skill.btn.jsx | 12 ++--- client/src/components/targeting.arrows.jsx | 22 ++++++-- client/src/events.jsx | 2 +- client/src/reducers.jsx | 3 +- client/src/utils.jsx | 59 ++++++++++++++++++++++ server/src/skill.rs | 4 +- 8 files changed, 121 insertions(+), 27 deletions(-) diff --git a/client/src/actions.jsx b/client/src/actions.jsx index 01b1cd88..c5b33d35 100644 --- a/client/src/actions.jsx +++ b/client/src/actions.jsx @@ -17,9 +17,12 @@ export const setCombiner = value => ({ type: 'SET_COMBINER', value: Array.from(v export const setConstructEditId = value => ({ type: 'SET_CONSTRUCT_EDIT_ID', value }); export const setConstructs = value => ({ type: 'SET_CONSTRUCTS', value }); export const setConstructRename = value => ({ type: 'SET_CONSTRUCT_RENAME', value }); + export const setGame = value => ({ type: 'SET_GAME', value }); -export const setGameInfo = value => ({ type: 'SET_GAME_INFO', value }); +export const setGameSkillInfo = value => ({ type: 'SET_GAME_SKILL_INFO', value }); +export const setGameEffectInfo = value => ({ type: 'SET_GAME_EFFECT_INFO', value }); export const setInfo = value => ({ type: 'SET_INFO', value }); + export const setEmail = value => ({ type: 'SET_EMAIL', value }); export const setInvite = value => ({ type: 'SET_INVITE', value }); export const setInstance = value => ({ type: 'SET_INSTANCE', value }); diff --git a/client/src/components/game.construct.jsx b/client/src/components/game.construct.jsx index 204e5bda..186a55ef 100644 --- a/client/src/components/game.construct.jsx +++ b/client/src/components/game.construct.jsx @@ -8,6 +8,7 @@ const { STATS } = require('../utils'); const { ConstructAvatar, ConstructText } = require('./construct'); const shapes = require('./shapes'); const { INFO } = require('./../constants'); +const actions = require('../actions'); const SkillBtn = require('./skill.btn'); @@ -21,8 +22,7 @@ const addState = connect( animFocus, animating, animText, - - gameInfo, + gameSkillInfo, itemInfo, } = state; @@ -45,11 +45,19 @@ const addState = connect( animText, activeSkill, selectSkillTarget, - - gameInfo, + gameSkillInfo, itemInfo, }; + }, + + function receiveDispatch(dispatch) { + function setGameEffectInfo(info) { + dispatch(actions.setGameEffectInfo(info)); + } + + return { setGameEffectInfo }; } + ); const eventClasses = (animating, animFocus, construct, postSkill) => { @@ -85,8 +93,9 @@ class GameConstruct extends Component { selectSkillTarget, animFocus, animText, - - gameInfo, + + setGameEffectInfo, + gameSkillInfo, itemInfo, } = this.props; @@ -107,20 +116,30 @@ class GameConstruct extends Component { let crypSkills =
; if (player) crypSkills = (
{skills}
); - + function hoverInfo(e, info) { + e.stopPropagation(); + return setGameEffectInfo(info); + } const effectBox = () => { - if (gameInfo && gameInfo.constructId === construct.id) { - const fullInfo = itemInfo.items.find(k => k.item === gameInfo.skill) || INFO[gameInfo.skill]; + if (gameSkillInfo && gameSkillInfo.constructId === construct.id) { + const fullInfo = itemInfo.items.find(k => k.item === gameSkillInfo.skill) || INFO[gameSkillInfo.skill]; const regEx = /(RedPower|BluePower|GreenPower|RedLife|BlueLife|GreenLife|SpeedStat)/; const infoDescription = reactStringReplace(fullInfo.description, regEx, match => shapes[match]()); + const speed =
Speed {shapes.SpeedStat()} multiplier {fullInfo.speed * 4}%
; return (
-

{gameInfo.skill}

+

{gameSkillInfo.skill}

{infoDescription}
+ {speed}
); } const effects = construct.effects.length - ? construct.effects.map(c =>
{c.effect} - {c.duration}T
) + ? construct.effects.map(c => +
hoverInfo(e, c)} + onMouseOut={e => hoverInfo(e, null)} + > {c.effect} - {c.duration}T
) : null; return (
{effects}
); } diff --git a/client/src/components/skill.btn.jsx b/client/src/components/skill.btn.jsx index 93a15816..87d0cc89 100644 --- a/client/src/components/skill.btn.jsx +++ b/client/src/components/skill.btn.jsx @@ -23,11 +23,11 @@ const addState = connect( dispatch(actions.setActiveSkill(constructId, skill)); } - function setGameInfo(info) { - dispatch(actions.setGameInfo(info)); + function setGameSkillInfo(info) { + dispatch(actions.setGameSkillInfo(info)); } - return { setActiveSkill, setGameInfo }; + return { setActiveSkill, setGameSkillInfo }; } ); @@ -40,18 +40,18 @@ function Skill(props) { i, activeSkill, setActiveSkill, - setGameInfo, + setGameSkillInfo, } = props; if (!game) return false; const s = construct.skills[i]; const ko = construct.green_life.value === 0 ? 'ko' : ''; - + function hoverInfo(e, info) { e.stopPropagation(); if (animating) return false; - return setGameInfo(info); + return setGameSkillInfo(info); } if (!s || !game) { return ( diff --git a/client/src/components/targeting.arrows.jsx b/client/src/components/targeting.arrows.jsx index 0fe0fcb3..c9e0f57c 100644 --- a/client/src/components/targeting.arrows.jsx +++ b/client/src/components/targeting.arrows.jsx @@ -6,11 +6,11 @@ const reactStringReplace = require('react-string-replace'); const throttle = require('lodash/throttle'); const shapes = require('./shapes'); -const { removeTier } = require('../utils'); +const { effectInfo, removeTier } = require('../utils'); const addState = connect( - ({ game, account, animSkill, animating, itemInfo }) => - ({ game, account, animSkill, animating, itemInfo }) + ({ game, account, animSkill, animating, itemInfo, gameEffectInfo }) => + ({ game, account, animSkill, animating, itemInfo, gameEffectInfo }) ); class TargetSvg extends Component { @@ -28,10 +28,24 @@ class TargetSvg extends Component { } render(props, state) { - const { game, account, animating, animSkill, itemInfo } = props; + const { game, account, animating, animSkill, itemInfo, gameEffectInfo } = props; const { width, height } = state; if (!game) return false; // game will be null when battle ends + // Whenever someones looking at effects throw it up here + if (gameEffectInfo) { + const regEx = /(RedPower|BluePower|GreenPower|RedLife|BlueLife|GreenLife|SpeedStat)/; + const infoString = effectInfo(gameEffectInfo); + const infoDescription = reactStringReplace(infoString, regEx, match => shapes[match]()); + + return ( +
+

{gameEffectInfo.effect}

+
{infoDescription}
+
+ ); + } + // resolutions happening // just put skill name up if (animating) { diff --git a/client/src/events.jsx b/client/src/events.jsx index 07a8262b..ec044b4c 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -109,7 +109,7 @@ function registerEvents(store) { store.dispatch(actions.setAnimTarget(null)); store.dispatch(actions.setAnimText(null)); store.dispatch(actions.setAnimating(false)); - + store.dispatch(actions.setGameEffectInfo(null)); store.dispatch(actions.setSkip(false)); // set the game state so resolutions don't fire twice diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx index 682667c6..9cc396c6 100644 --- a/client/src/reducers.jsx +++ b/client/src/reducers.jsx @@ -29,7 +29,8 @@ module.exports = { constructEditId: createReducer(null, 'SET_CONSTRUCT_EDIT_ID'), constructRename: createReducer(null, 'SET_CONSTRUCT_RENAME'), game: createReducer(null, 'SET_GAME'), - gameInfo: createReducer(null, 'SET_GAME_INFO'), + gameSkillInfo: createReducer(null, 'SET_GAME_SKILL_INFO'), + gameEffectInfo: createReducer(null, 'SET_GAME_EFFECT_INFO'), email: createReducer(null, 'SET_EMAIL'), invite: createReducer(null, 'SET_INVITE'), info: createReducer(null, 'SET_INFO'), diff --git a/client/src/utils.jsx b/client/src/utils.jsx index b78a2b44..140ff26a 100644 --- a/client/src/utils.jsx +++ b/client/src/utils.jsx @@ -237,6 +237,64 @@ function convertItem(v) { // return; } +function effectInfo(i) { + console.log(i); + + function multiplier(s) { // Update later to use server info in future + if (s === 'CounterAttack') return 70; + if (s === 'CounterAttack+') return 95; + if (s === 'CounterAttack++') return 120; + + if (s === 'DecayTick') return 33; + if (s === 'DecayTick+') return 45; + if (s === 'DecayTick++') return 70; + + if (s === 'SiphonTick') return 40; + if (s === 'SiphonTick+') return 50; + if (s === 'SiphonTick++') return 60; + + if (s === 'TriageTick') return 75; + if (s === 'TriageTick+') return 110; + if (s === 'TriageTick++') return 140; + + if (s === 'Electrocute' || s === 'ElectrocuteTick') return 80; + if (s === 'Electrocute+' || s === 'ElectrocuteTick+') return 100; + if (s === 'Electrocute++' || s === 'ElectrocuteTick++') return 130; + return 0; + } + + switch (i.effect) { + case 'Amplify': return `Increases construct RedPower and BluePower by ${i.meta[1] - 100}%`; + case 'Banish': return 'Banished construct cannot cast or take damage'; + case 'Block': return `Reduces construct red damage taken by ${100 - i.meta[1]}%`; + case 'Buff': return `Increases construct RedPower and SpeedStat by ${i.meta[1] - 100}%`; + case 'Sustain': return 'Construct cannot be KO while active. Additionally provides immunity to disables'; + case 'Curse': return `Construct will take ${i.meta[1] - 100}% increased red and blue damage`; + case 'Haste': return `Construct has ${i.meta[1] - 100}% increased SpeedStat. Red attack skills will trigger a HasteStrike dealing 30% SpeedStat as red damage.`; + case 'Hybrid': return `Construct has ${i.meta[1] - 100}% increased GreenPower. Blue attack skills will trigger a HybridBlast dealing 25% GreenPower as red damage.`; + case 'Invert': return 'Reverses damage and healing. Healing will damage this construct and damage will heal.'; + case 'Counter': return `Red damage taken by this construct will trigger a CounterAttack. CounterAttack deals ${multiplier(i.meta[1])}% RedPower as red damage.`; + case 'Purge': return 'Disable construct from casting any green skills'; + case 'Reflect': return 'Reflect blue skills back to caster'; + case 'Slow': return `Reduces construct SpeedStat by ${100 - i.meta[1]}%`; + case 'Restrict': return 'Disable construct from casting any red skills'; + case 'Stun': return 'Stunned construct cannot use skills'; + case 'Intercept': return 'Redirect any skills on team to this target construct'; + case 'Vulnerable': return `Construct will take ${i.meta[1] - 100}% increased red damage`; + case 'Silence': return 'Disable construct from casting any blue skills'; + case 'Wither': return `Construct will take ${100 - i.meta[1]}% reduced healing`; // + case 'Decay': return `Construct will take ${multiplier(i.tick.skill)}% of caster's BluePower as blue damage each turn.`; // + case 'Electric': return `Attacks against this construct will apply Electrocute dealing ${multiplier(i.meta[1])}% of construct BluePower as blue damage each turn.`; + case 'Electrocute': return `Construct will take ${multiplier(i.tick.skill)}% of caster's BluePower as blue damage each turn.`; + case 'Absorb': return 'If construct takes damage, Absorption will be applied increasing RedPower and BluePower based on damage taken.'; + case 'Absorption': return `Increasing construct RedPower and BluePower by ${i.meta[1]}`; + case 'Triage': return `Construct will be healed for ${multiplier(i.tick.skill)}% of caster's GreenPower each turn.`; + case 'Siphon': return `Construct will take ${multiplier(i.tick.skill)}% of caster's BluePower as blue damage each turn, healing the caster.`; + + default: return 'Missing Effect Text'; + } +} + module.exports = { stringSort, numSort, @@ -251,4 +309,5 @@ module.exports = { randomPoints, removeTier, match, + effectInfo, }; diff --git a/server/src/skill.rs b/server/src/skill.rs index 5bb44cea..5af07155 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -1420,9 +1420,7 @@ fn break_(source: &mut Construct, target: &mut Construct, mut results: Resolutio } fn block(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { - results.push(Resolution::new(source, target) - .event(target.add_effect(skill, skill.effect()[0])) - .stages(EventStages::StartEnd)); + results.push(Resolution::new(source, target).event(target.add_effect(skill, skill.effect()[0]))); return results; }