diff --git a/client/cryps.css b/client/cryps.css index efbe85e0..69982099 100644 --- a/client/cryps.css +++ b/client/cryps.css @@ -816,12 +816,7 @@ CRYP DAMAGE } .cryp-box { - margin: 0; - border-left-width: 0px; - } - - .cryp-box:first-child { - border-left-width: 1px; + margin: 0 0.2em; } .spawn-btn button { diff --git a/client/src/components/game.component.jsx b/client/src/components/game.component.jsx index e35d4bb6..3a095f43 100644 --- a/client/src/components/game.component.jsx +++ b/client/src/components/game.component.jsx @@ -6,6 +6,7 @@ const molecule = require('./molecule'); const { STATS, eventClasses, getCombatText } = require('../utils'); const GameCryp = require('./game.cryp'); +const SkillBtn = require('./skill.btn'); // const SKILL_HOT_KEYS = ['Q', 'W', 'E', 'R']; @@ -97,7 +98,7 @@ function GamePanel(props) { } function PlayerTeam(team) { - const cryps = team.cryps.map((c, i) => ); + const cryps = team.cryps.map((c, i) => ); return (
@@ -152,15 +153,16 @@ function GamePanel(props) { ?
 
: playerTeam.cryps.map((c, i) => stackElement(c, i)); - // const mobileSkills = activeCryp - // ? range(0, 3).map(i => Skill(activeCryp, i, true)) - // : (
); + const mobileSkills = activeCryp && activeCryp.green_life.value + ? range(0, 3).map(i => ) + : (
); return (
setActiveCryp(null)} > {header} {PlayerTeam(playerTeam, setActiveSkill)}
+ {mobileSkills}
{selectedSkills} diff --git a/client/src/components/game.cryp.jsx b/client/src/components/game.cryp.jsx index ad864488..2bcf6b0b 100644 --- a/client/src/components/game.cryp.jsx +++ b/client/src/components/game.cryp.jsx @@ -6,6 +6,8 @@ const molecule = require('./molecule'); const actions = require('../actions'); const { STATS, eventClasses, getCombatText } = require('../utils'); +const SkillBtn = require('./skill.btn'); + const addState = connect( function receiveState(state) { const { @@ -37,15 +39,11 @@ const addState = connect( }, function receiveDispatch(dispatch) { - function setActiveSkill(crypId, skill) { - dispatch(actions.setActiveSkill(crypId, skill)); - } - function setActiveCryp(cryp) { dispatch(actions.setActiveCryp(cryp)); } - return { setActiveSkill, setActiveCryp }; + return { setActiveCryp }; } ); @@ -56,58 +54,16 @@ function GameCryp(props) { resolution, activeSkill, - setActiveSkill, setActiveCryp, selectSkillTarget, } = props; const ko = cryp.green_life.value === 0 ? 'ko' : ''; - function Skill(i, mobile) { - const s = cryp.skills[i]; - if (!s) { - return ( - - ); - } - - const side = mobile - ? 'top' - : 'right'; - - const cdText = cryp.skills[i].cd > 0 - ? `- ${s.cd}` - : ''; - - const highlight = activeSkill - ? activeSkill.crypId === cryp.id && activeSkill.skill === s - : false; - - function onClick(e) { - e.stopPropagation(); - return setActiveSkill(cryp.id, s.skill); - } - - return ( - - ); - } - const classes = eventClasses(resolution, cryp); - const skills = range(0, 3).map(i => Skill(i)); + const skills = range(0, 3) + .map(i => ); const stats = [STATS.greenLife, STATS.redLife, STATS.blueLife].map((s, j) => (
diff --git a/client/src/components/skill.btn.jsx b/client/src/components/skill.btn.jsx new file mode 100644 index 00000000..aff80371 --- /dev/null +++ b/client/src/components/skill.btn.jsx @@ -0,0 +1,77 @@ +const preact = require('preact'); +const { connect } = require('preact-redux'); + +const actions = require('../actions'); + +const addState = connect( + function receiveState(state) { + const { + activeSkill, + } = state; + + return { + activeSkill, + }; + }, + + function receiveDispatch(dispatch) { + function setActiveSkill(crypId, skill) { + dispatch(actions.setActiveSkill(crypId, skill)); + } + + return { setActiveSkill }; + } +); + + +function Skill(props) { + const { + cryp, + i, + mobile, + activeSkill, + setActiveSkill, + } = props; + + const s = cryp.skills[i]; + const ko = cryp.green_life.value === 0 ? 'ko' : ''; + + if (!s) { + return ( + + ); + } + + const side = mobile + ? 'top' + : 'right'; + + const cdText = cryp.skills[i].cd > 0 + ? `- ${s.cd}` + : ''; + + const highlight = activeSkill + ? activeSkill.crypId === cryp.id && activeSkill.skill === s + : false; + + function onClick(e) { + e.stopPropagation(); + return setActiveSkill(cryp.id, s.skill); + } + + return ( + + ); +} + +module.exports = addState(Skill);