From b896a7ee42ba81315e8e9d54de38ade097c9e880 Mon Sep 17 00:00:00 2001 From: Mashy Date: Thu, 17 Oct 2019 16:25:31 +1000 Subject: [PATCH] skill info on hover in effect box --- WORKLOG.md | 3 +-- client/assets/styles/game.less | 12 +++++++++ client/src/actions.jsx | 1 + client/src/components/game.construct.jsx | 33 +++++++++++++++++++++--- client/src/components/skill.btn.jsx | 15 +++++++++-- client/src/reducers.jsx | 1 + 6 files changed, 57 insertions(+), 8 deletions(-) diff --git a/WORKLOG.md b/WORKLOG.md index 4aa80673..fc056a15 100644 --- a/WORKLOG.md +++ b/WORKLOG.md @@ -3,10 +3,8 @@ *PRODUCTION* -* border colours for skills e.g. strike red border, slay half red half green * rename vbox to shop * combat phase info system -* drag and drop buy / equip / unequip items * mobile styles * mobile info page @@ -71,6 +69,7 @@ $$$ * Highlight (dota) colour * fx colours + styles +* ??? (PROBS NOT) drag and drop buy / equip / unequip items ??? * modules * troll life -> dmg * prince of peace diff --git a/client/assets/styles/game.less b/client/assets/styles/game.less index 4f22174a..415174ff 100644 --- a/client/assets/styles/game.less +++ b/client/assets/styles/game.less @@ -204,6 +204,7 @@ .resolving-skill { grid-area: target; + text-align: center; align-self: center; height: auto; svg { @@ -213,6 +214,17 @@ } } +.skill-description { + padding-left: 1em; + padding-right: 1em; + text-align: center; + svg { + display: inline; + height: 1em; + margin-right: 0.1em + } +} + /* some stupid bug in chrome makes it fill the entire screen */ @media screen and (-webkit-min-device-pixel-ratio:0) { #targeting { diff --git a/client/src/actions.jsx b/client/src/actions.jsx index 85b113de..01b1cd88 100644 --- a/client/src/actions.jsx +++ b/client/src/actions.jsx @@ -18,6 +18,7 @@ export const setConstructEditId = value => ({ type: 'SET_CONSTRUCT_EDIT_ID', val 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 setInfo = value => ({ type: 'SET_INFO', value }); export const setEmail = value => ({ type: 'SET_EMAIL', value }); export const setInvite = value => ({ type: 'SET_INVITE', value }); diff --git a/client/src/components/game.construct.jsx b/client/src/components/game.construct.jsx index 34349422..204e5bda 100644 --- a/client/src/components/game.construct.jsx +++ b/client/src/components/game.construct.jsx @@ -2,10 +2,12 @@ const { connect } = require('preact-redux'); const { Component } = require('preact'); const preact = require('preact'); const range = require('lodash/range'); +const reactStringReplace = require('react-string-replace'); const { STATS } = require('../utils'); const { ConstructAvatar, ConstructText } = require('./construct'); const shapes = require('./shapes'); +const { INFO } = require('./../constants'); const SkillBtn = require('./skill.btn'); @@ -19,6 +21,9 @@ const addState = connect( animFocus, animating, animText, + + gameInfo, + itemInfo, } = state; function selectSkillTarget(targetConstructId) { @@ -40,6 +45,9 @@ const addState = connect( animText, activeSkill, selectSkillTarget, + + gameInfo, + itemInfo, }; } ); @@ -77,6 +85,9 @@ class GameConstruct extends Component { selectSkillTarget, animFocus, animText, + + gameInfo, + itemInfo, } = this.props; const ko = construct.green_life.value === 0 ? 'ko' : ''; @@ -96,9 +107,23 @@ class GameConstruct extends Component { let crypSkills =
; if (player) crypSkills = (
{skills}
); - const effects = construct.effects.length - ? construct.effects.map(c =>
{c.effect} - {c.duration}T
) - : null; + + const effectBox = () => { + if (gameInfo && gameInfo.constructId === construct.id) { + const fullInfo = itemInfo.items.find(k => k.item === gameInfo.skill) || INFO[gameInfo.skill]; + const regEx = /(RedPower|BluePower|GreenPower|RedLife|BlueLife|GreenLife|SpeedStat)/; + const infoDescription = reactStringReplace(fullInfo.description, regEx, match => shapes[match]()); + return ( +
+

{gameInfo.skill}

+
{infoDescription}
+
); + } + const effects = construct.effects.length + ? construct.effects.map(c =>
{c.effect} - {c.duration}T
) + : null; + return (
{effects}
); + } return (
{crypSkills} -
{effects}
+ {effectBox()}
{stats}
diff --git a/client/src/components/skill.btn.jsx b/client/src/components/skill.btn.jsx index 32baa084..f8fdcc7e 100644 --- a/client/src/components/skill.btn.jsx +++ b/client/src/components/skill.btn.jsx @@ -23,7 +23,11 @@ const addState = connect( dispatch(actions.setActiveSkill(constructId, skill)); } - return { setActiveSkill }; + function setGameInfo(info) { + dispatch(actions.setGameInfo(info)); + } + + return { setActiveSkill, setGameInfo }; } ); @@ -35,13 +39,18 @@ function Skill(props) { i, activeSkill, setActiveSkill, + setGameInfo, } = props; if (!game) return false; const s = construct.skills[i]; const ko = construct.green_life.value === 0 ? 'ko' : ''; - + + function hoverInfo(e, info) { + e.stopPropagation(); + return setGameInfo(info); + } if (!s || !game) { return (