From 383330ddada9d93b333fbd666b0717c9a4647a23 Mon Sep 17 00:00:00 2001 From: Mashy Date: Fri, 29 Mar 2019 13:33:44 +1000 Subject: [PATCH] Battles are back on the menu --- html-client/src/components/game.container.js | 4 +-- html-client/src/components/game.jsx | 37 ++++++++++---------- html-client/src/main.jsx | 1 + html-client/src/reducers.jsx | 11 ++++++ 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/html-client/src/components/game.container.js b/html-client/src/components/game.container.js index 8adac3fd..17a41dba 100644 --- a/html-client/src/components/game.container.js +++ b/html-client/src/components/game.container.js @@ -8,9 +8,9 @@ const addState = connect( function receiveState(state) { const { ws, game, account, activeSkill, activeIncoming } = state; - function selectSkillTarget(targetTeamId) { + function selectSkillTarget(targetCrypId) { if (activeSkill) { - return ws.sendGameSkill(game.id, activeSkill.crypId, targetTeamId, activeSkill.skill.skill); + return ws.sendGameSkill(game.id, activeSkill.crypId, targetCrypId, activeSkill.skill.skill); } return false; } diff --git a/html-client/src/components/game.jsx b/html-client/src/components/game.jsx index 4327a515..f1a2f004 100644 --- a/html-client/src/components/game.jsx +++ b/html-client/src/components/game.jsx @@ -103,24 +103,28 @@ function GamePanel(props) { )); return ( -
-
-
-
-

{cryp.name}

-
-
-
- -
+
selectSkillTarget(cryp.id)} > +
+
+
+
+

{cryp.name}

+
+
+
+ +
+
+
+
{cryp.hp.value} / {cryp.hp.value} HP
+
-
{cryp.hp.value} / {cryp.hp.value} HP
- - + {effects}
- {effects}
); } @@ -128,10 +132,7 @@ function GamePanel(props) { function OpponentTeam(team) { const cryps = team.cryps.map(OpponentCrypCard); return ( -
console.log(activeSkill)} > +
{cryps}
); diff --git a/html-client/src/main.jsx b/html-client/src/main.jsx index 026fcc79..5b414a0c 100644 --- a/html-client/src/main.jsx +++ b/html-client/src/main.jsx @@ -17,6 +17,7 @@ const Body = require('./components/body.component'); const store = createStore( combineReducers({ account: reducers.accountReducer, + activeSkill: reducers.activeSkillReducer, combiner: reducers.combinerReducer, game: reducers.gameReducer, cryps: reducers.crypsReducer, diff --git a/html-client/src/reducers.jsx b/html-client/src/reducers.jsx index 2da78ba3..1e44c353 100644 --- a/html-client/src/reducers.jsx +++ b/html-client/src/reducers.jsx @@ -10,6 +10,16 @@ function accountReducer(state = defaultAccount, action) { } } +const defaultActiveSkill = null; +function activeSkillReducer(state = defaultActiveSkill, action) { + switch (action.type) { + case actions.SET_ACTIVE_SKILL: + return action.value; + default: + return state; + } +} + const defaultCryps = null; function crypsReducer(state = defaultCryps, action) { switch (action.type) { @@ -72,6 +82,7 @@ function wsReducer(state = defaultWs, action) { module.exports = { accountReducer, + activeSkillReducer, combinerReducer, crypsReducer, gameReducer,