From a8cf47ff518c47f52d450c3b55f600b9895936f7 Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 15 Apr 2019 16:33:15 +1000 Subject: [PATCH] Combat source / target text --- client/src/constants.jsx | 6 +++--- client/src/utils.jsx | 27 ++++++++++++++++----------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/client/src/constants.jsx b/client/src/constants.jsx index dbe87b53..4f8ac7c3 100644 --- a/client/src/constants.jsx +++ b/client/src/constants.jsx @@ -1,9 +1,9 @@ module.exports = { TIMES: { RESOLUTION_TIME_MS: 2000, - START_SKILL: 1000, - END_SKILL: 1000, - POST_SKILL: 1500, + START_SKILL: 750, + END_SKILL: 750, + POST_SKILL: 750, }, ITEMS: { diff --git a/client/src/utils.jsx b/client/src/utils.jsx index b97f3b2b..bf124627 100644 --- a/client/src/utils.jsx +++ b/client/src/utils.jsx @@ -32,7 +32,7 @@ const numSort = (k, desc) => { }; }; -const genAvatar = (name) => { +const genAvatar = name => { let hash = 0; if (name.length === 0) return hash; // Probs don't need to hash using the whole string @@ -164,13 +164,16 @@ function eventClasses(resolution, cryp) { function getCombatText(cryp, resolution) { if (!resolution) return ''; - if (resolution.stage !== 'POST_SKILL') return ''; - if (cryp.id !== resolution.target.id) return ''; const [type, event] = resolution.event; + const source = cryp.id === resolution.source.id; + const target = cryp.id === resolution.target.id; + const startSkill = resolution.stage === 'START_SKILL'; + const endSkill = resolution.stage === 'END_SKILL'; + const postSkill = resolution.stage === 'POST_SKILL'; if (type === 'Ko') { - return 'KO!'; + if (postSkill && target) return 'KO!'; } if (type === 'Disable') { @@ -179,7 +182,7 @@ function getCombatText(cryp, resolution) { if (type === 'Immunity') { const { skill, immunity } = event; - return 'IMMUNE'; + if (postSkill && target) return 'IMMUNE'; } if (type === 'TargetKo') { @@ -191,32 +194,34 @@ function getCombatText(cryp, resolution) { const mitigationText = mitigation ? `(${mitigation})` : ''; - return `${amount} ${mitigationText}`; + if (startSkill && source) return `${skill}`; + if (endSkill && target) return `${skill}`; + if (postSkill && target) return `${amount} ${mitigationText}`; } if (type === 'Healing') { const { skill, amount, overhealing } = event; - return `${amount} (${overhealing}OH)`; + if (postSkill && target) return `${amount} (${overhealing}OH)`; } if (type === 'Inversion') { const { skill } = event; - return 'INVERT'; + if (postSkill && target) return 'INVERT'; } if (type === 'Reflection') { const { skill } = event; - return 'REFLECT'; + if (postSkill && target) return 'REFLECT'; } if (type === 'Effect') { const { skill, effect, duration } = event; - return `+ ${effect} ${duration}T`; + if (postSkill && target) return `+ ${effect} ${duration}T`; } if (type === 'Removal') { const { effect } = event; - return `- ${effect}`; + if (postSkill && target) return `- ${effect}`; }