diff --git a/client/src/actions.jsx b/client/src/actions.jsx
index c44b8f2d..088b7d4a 100644
--- a/client/src/actions.jsx
+++ b/client/src/actions.jsx
@@ -10,11 +10,14 @@ export const setItems = (value) => ({ type: SET_ITEMS, value });
export const SET_GAME = 'SET_GAME';
export const setGame = (value) => ({ type: SET_GAME, value });
-export const SET_ACTIVE_CRYP = 'SET_ACTIVE_CRYP';
-export const setActiveCryp = (value) => ({ type: SET_ACTIVE_CRYP, value });
-
export const SET_ACTIVE_ITEM = 'SET_ACTIVE_ITEM';
export const setActiveItem = (value) => ({ type: SET_ACTIVE_ITEM, value });
+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 SET_WS = 'SET_WS';
export const setWs = (value) => ({ type: SET_WS, value });
diff --git a/client/src/components/cryp.spawn.container.js b/client/src/components/cryp.spawn.container.js
index 23d918fa..7dd8bfac 100644
--- a/client/src/components/cryp.spawn.container.js
+++ b/client/src/components/cryp.spawn.container.js
@@ -9,8 +9,6 @@ const addState = connect(
return ws.sendCrypSpawn(name);
}
- console.log(ws);
-
return { account: state.account, sendCrypSpawn };
}
);
diff --git a/client/src/components/game.container.js b/client/src/components/game.container.js
index b487d3cd..6aaf4dac 100644
--- a/client/src/components/game.container.js
+++ b/client/src/components/game.container.js
@@ -1,20 +1,33 @@
const { connect } = require('preact-redux');
+const actions = require('../actions');
+
const Game = require('./game');
const addState = connect(
function receiveState(state) {
- const { ws, game, account } = state;
- function sendGameSkill(crypId, targetTeamId, skill) {
- return ws.sendGameSkill(game.id, crypId, targetTeamId, skill);
+ const { ws, game, account, activeSkill } = state;
+ function selectSkillTarget(targetTeamId) {
+ if (activeSkill) {
+ return ws.sendGameSkill(game.id, activeSkill.crypId, targetTeamId, activeSkill.skill);
+ }
+ return false;
}
function sendGameTarget(crypId, skillId) {
return ws.sendGameTarget(game.id, crypId, skillId);
}
- return { game, account, sendGameSkill, sendGameTarget };
+ return { game, account, activeSkill, selectSkillTarget, sendGameTarget };
+ },
+ function receiveDispatch(dispatch) {
+ function setActiveSkill(crypId, skill) {
+ dispatch(actions.setActiveSkill(crypId, skill))
+ }
+
+ return { setActiveSkill };
}
+
);
module.exports = addState(Game);
diff --git a/client/src/components/game.jsx b/client/src/components/game.jsx
index 9e02b17d..8eee0b69 100644
--- a/client/src/components/game.jsx
+++ b/client/src/components/game.jsx
@@ -1,104 +1,100 @@
const preact = require('preact');
-function PlayerCrypCard(cryp) {
- return (
-
-
-
-
-
{cryp.name}
-
Level {cryp.lvl}
-
-
-
-
-
-
-
-
-
{cryp.hp.value} / {cryp.stam.value} HP
-
-
-
{cryp.xp} / {Math.pow(2,cryp.lvl+1)} XP
-
-
-
-
-
- );
-}
-
-function PlayerTeam(team) {
- const cryps = team.cryps.map(PlayerCrypCard);
-
- return (
-
- {cryps}
-
- )
-}
-
-function OpponentCrypCard(cryp) {
- return (
-
-
-
-
-
{cryp.name}
-
Level {cryp.lvl}
-
-
-
-
-
-
-
-
-
{cryp.hp.value} / {cryp.stam.value} HP
-
-
-
{cryp.xp} / {Math.pow(2,cryp.lvl+1)} XP
-
-
-
-
- );
-}
-
-function OpponentTeam(team) {
- const cryps = team.cryps.map(OpponentCrypCard);
-
- return (
-
- {cryps}
-
- )
-}
-
-function GameState(game) {
- return (
-
- )
-}
-
-function GamePanel({ game, sendGameSkill, sendGameTarget, account }) {
+function GamePanel({ game, activeSkill, setActiveSkill, selectSkillTarget, account }) {
if (!game) return ...
;
const otherTeams = game.teams.filter(t => t.id !== account.id);
const playerTeam = game.teams.find(t => t.id === account.id);
- const gameState = GameState(game);
+ const incoming = playerTeam.incoming.map((inc, i) => (
+ {JSON.stringify(inc)}
+ ));
+
+ function PlayerCrypCard(cryp) {
+ return (
+
+
+
+
+
{cryp.name}
+
Level {cryp.lvl}
+
+
+
+
+
+
+
+
+
{cryp.hp.value} / {cryp.stam.value} HP
+
+
+
{cryp.xp} / {Math.pow(2,cryp.lvl+1)} XP
+
+
+
+
+
+ );
+ }
+
+ function PlayerTeam(team) {
+ const cryps = team.cryps.map(c => PlayerCrypCard(c, setActiveSkill));
+
+ return (
+
+ {cryps}
+
+ )
+ }
+
+ function OpponentCrypCard(cryp) {
+ return (
+
+
+
+
+
{cryp.name}
+
Level {cryp.lvl}
+
+
+
+
+
+
+
+
+
{cryp.hp.value} / {cryp.stam.value} HP
+
+
+
{cryp.xp} / {Math.pow(2,cryp.lvl+1)} XP
+
+
+
+
+ );
+ }
+
+ function OpponentTeam(team) {
+ const cryps = team.cryps.map(OpponentCrypCard);
+
+ return (
+ selectSkillTarget(team.id)} >
+ {cryps}
+
+ )
+ }
// const targetBtn = playerTeam.incoming.map(i => (
//