diff --git a/client/src/actions.jsx b/client/src/actions.jsx index 088b7d4a..8c584450 100644 --- a/client/src/actions.jsx +++ b/client/src/actions.jsx @@ -17,7 +17,7 @@ export const SET_ACTIVE_INCOMING = 'SET_ACTIVE_INCOMING'; export const setActiveIncoming = (value) => ({ type: SET_ACTIVE_INCOMING, value }); export const SET_ACTIVE_SKILL = 'SET_ACTIVE_SKILL'; -export const setActiveSkill = (crypId, skill) => ({ type: SET_ACTIVE_SKILL, value: { crypId, skill} }); +export const setActiveSkill = (crypId, skill) => ({ type: SET_ACTIVE_SKILL, value: crypId ? { crypId, skill} : null }); export const SET_WS = 'SET_WS'; export const setWs = (value) => ({ type: SET_WS, value }); diff --git a/client/src/components/game.container.js b/client/src/components/game.container.js index 6aaf4dac..93db4b03 100644 --- a/client/src/components/game.container.js +++ b/client/src/components/game.container.js @@ -6,7 +6,7 @@ const Game = require('./game'); const addState = connect( function receiveState(state) { - const { ws, game, account, activeSkill } = state; + const { ws, game, account, activeSkill, activeIncoming } = state; function selectSkillTarget(targetTeamId) { if (activeSkill) { return ws.sendGameSkill(game.id, activeSkill.crypId, targetTeamId, activeSkill.skill); @@ -14,18 +14,27 @@ const addState = connect( return false; } - function sendGameTarget(crypId, skillId) { - return ws.sendGameTarget(game.id, crypId, skillId); + function selectIncomingTarget(crypId) { + if (activeIncoming) { + return ws.sendGameTarget(game.id, crypId, activeIncoming); + } + return false; } - return { game, account, activeSkill, selectSkillTarget, sendGameTarget }; + return { game, account, activeSkill, activeIncoming, selectSkillTarget, selectIncomingTarget }; }, + function receiveDispatch(dispatch) { function setActiveSkill(crypId, skill) { dispatch(actions.setActiveSkill(crypId, skill)) } - return { setActiveSkill }; + function setActiveIncoming(skillId) { + dispatch(actions.setActiveIncoming(skillId)) + } + + + return { setActiveSkill, setActiveIncoming }; } ); diff --git a/client/src/components/game.jsx b/client/src/components/game.jsx index 8eee0b69..39416b19 100644 --- a/client/src/components/game.jsx +++ b/client/src/components/game.jsx @@ -1,19 +1,44 @@ const preact = require('preact'); -function GamePanel({ game, activeSkill, setActiveSkill, selectSkillTarget, account }) { +function GamePanel(props) { + const { + game, + activeSkill, + activeIncoming, + setActiveSkill, + setActiveIncoming, + selectSkillTarget, + selectIncomingTarget, + account + } = props; + if (!game) return