diff --git a/client/src/components/body.component.jsx b/client/src/components/body.component.jsx old mode 100644 new mode 100755 index f031f99b..2fb12551 --- a/client/src/components/body.component.jsx +++ b/client/src/components/body.component.jsx @@ -1,5 +1,7 @@ // eslint-disable-next-line const preact = require('preact'); +const { connect } = require('preact-redux'); +const actions = require('../actions'); const ItemListContainer = require('./item.list.container'); const CrypSpawnContainer = require('./cryp.spawn.container'); @@ -7,13 +9,41 @@ const GameJoinButton = require('./game.join.button'); const CrypListContainer = require('./cryp.list.container'); const GameContainer = require('./game.container'); -function renderBody() { +const addState = connect( + function receiveState(state) { + const {game} = state; + return {game}; + }, + function receiveDispatch(dispatch) { + function setGame(game) { + dispatch(actions.setGame(game)) + } + return {setGame} + } +); + +function renderBody(props){ + const {game, setGame} = props; + if(game){ + return( +
+ + +
+ ) + } return (
- +
@@ -26,11 +56,8 @@ function renderBody() {
-
- -
); } -module.exports = renderBody; +module.exports = addState(renderBody); diff --git a/client/src/components/game.jsx b/client/src/components/game.jsx old mode 100644 new mode 100755 index 052c7e65..b7dd13e6 --- a/client/src/components/game.jsx +++ b/client/src/components/game.jsx @@ -1,4 +1,5 @@ const preact = require('preact'); +const key = require('keymaster'); function GamePanel(props) { const { @@ -19,6 +20,8 @@ function GamePanel(props) { const playerTeam = game.teams.find(t => t.id === account.id); const incoming = playerTeam.incoming.map(inc => { + key.unbind('1'); + key('1', () => setActiveIncoming(inc.id)); return (
{JSON.stringify(inc)}
@@ -26,13 +29,16 @@ function GamePanel(props) { className="button is-dark is-fullwidth" type="submit" onClick={() => setActiveIncoming(inc.id)}> - {inc.skill} + (1) Block skill: {inc.skill}
); }); function PlayerCrypCard(cryp) { + key.unbind('q'); + key('q', () => setActiveSkill(cryp.id, 'Attack')); + if (activeIncoming) console.log('should be a pointer'); return (
setActiveSkill(cryp.id, 'Attack')} > - Attack + (Q) Attack
); @@ -108,7 +114,6 @@ function GamePanel(props) { function OpponentTeam(team) { const cryps = team.cryps.map(OpponentCrypCard); - return (
-
-
{otherTeams.map(OpponentTeam)}
-
-
{game.phase}
-
{game.id}
+
+
+ {phaseText(game.phase)} +
+
+ {PlayerTeam(playerTeam, setActiveSkill)} +
+
+
+ {otherTeams.map(OpponentTeam)}
-
+
{incoming}
-
{PlayerTeam(playerTeam, setActiveSkill)}
-
-
log
+
+
log
-
+
) } diff --git a/client/src/keyboard.jsx b/client/src/keyboard.jsx old mode 100644 new mode 100755 index dfa58da6..04a53b6b --- a/client/src/keyboard.jsx +++ b/client/src/keyboard.jsx @@ -6,9 +6,18 @@ function setupKeys(store) { const state = store.getState(); key.unbind('esc'); + if (state.activeItem) { key('esc', () => store.dispatch(actions.setActiveItem(null))); } + if (state.activeSkill) { + key('esc', () => store.dispatch(actions.setActiveSkill(null))); + } + if (state.activeIncoming) { + key('esc', () => store.dispatch(actions.setActiveIncoming(null))); + } + + }); }