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
...
; const otherTeams = game.teams.filter(t => t.id !== account.id); const playerTeam = game.teams.find(t => t.id === account.id); - const incoming = playerTeam.incoming.map((inc, i) => ( -
{JSON.stringify(inc)}
- )); + const incoming = playerTeam.incoming.map(inc => { + return ( +
+
{JSON.stringify(inc)}
+ +
+ ); + }); function PlayerCrypCard(cryp) { + if (activeIncoming) console.log('should be a pointer'); return ( -
selectIncomingTarget(cryp.id)} className="tile is-vertical">
@@ -33,7 +58,6 @@ function GamePanel({ game, activeSkill, setActiveSkill, selectSkillTarget, accou
{cryp.xp} / {Math.pow(2,cryp.lvl+1)} XP
-
- // )); - // style={{ "min-height": "100%" }} return ( diff --git a/client/src/main.jsx b/client/src/main.jsx index 67ae876c..78a17be3 100755 --- a/client/src/main.jsx +++ b/client/src/main.jsx @@ -18,6 +18,7 @@ const store = createStore( combineReducers({ activeItem: reducers.activeItemReducer, activeSkill: reducers.activeSkillReducer, + activeIncoming: reducers.activeIncomingReducer, account: reducers.accountReducer, game: reducers.gameReducer, cryps: reducers.crypsReducer, diff --git a/client/src/socket.jsx b/client/src/socket.jsx index 8373b183..0d547e60 100755 --- a/client/src/socket.jsx +++ b/client/src/socket.jsx @@ -115,10 +115,12 @@ function createSocket(store) { function sendGameSkill(gameId, crypId, targetTeamId, skill) { send({ method: 'game_skill', params: { game_id: gameId, cryp_id: crypId, target_team_id: targetTeamId, skill } }); + store.dispatch(actions.setActiveSkill(null)); } function sendGameTarget(gameId, crypId, skillId) { send({ method: 'game_target', params: { game_id: gameId, cryp_id: crypId, skill_id: skillId } }); + store.dispatch(actions.setActiveIncoming(null)); } function sendItemUse(item, target) {