Battles are back on the menu

This commit is contained in:
Mashy 2019-03-29 13:33:44 +10:00
parent e9817f75e0
commit 383330ddad
4 changed files with 33 additions and 20 deletions

View File

@ -8,9 +8,9 @@ const addState = connect(
function receiveState(state) { function receiveState(state) {
const { ws, game, account, activeSkill, activeIncoming } = state; const { ws, game, account, activeSkill, activeIncoming } = state;
function selectSkillTarget(targetTeamId) { function selectSkillTarget(targetCrypId) {
if (activeSkill) { 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; return false;
} }

View File

@ -103,6 +103,9 @@ function GamePanel(props) {
)); ));
return ( return (
<div className="tile"
style={activeSkill ? { cursor: 'pointer' } : {}}
onClick={() => selectSkillTarget(cryp.id)} >
<div key={cryp.id} className="tile is-vertical"> <div key={cryp.id} className="tile is-vertical">
<div className="tile is-child"> <div className="tile is-child">
<div className="columns" > <div className="columns" >
@ -122,16 +125,14 @@ function GamePanel(props) {
</div> </div>
{effects} {effects}
</div> </div>
</div>
); );
} }
function OpponentTeam(team) { function OpponentTeam(team) {
const cryps = team.cryps.map(OpponentCrypCard); const cryps = team.cryps.map(OpponentCrypCard);
return ( return (
<div <div>
className="tile"
style={activeSkill ? { cursor: 'pointer' } : {}}
onClick={() => console.log(activeSkill)} >
{cryps} {cryps}
</div> </div>
); );

View File

@ -17,6 +17,7 @@ const Body = require('./components/body.component');
const store = createStore( const store = createStore(
combineReducers({ combineReducers({
account: reducers.accountReducer, account: reducers.accountReducer,
activeSkill: reducers.activeSkillReducer,
combiner: reducers.combinerReducer, combiner: reducers.combinerReducer,
game: reducers.gameReducer, game: reducers.gameReducer,
cryps: reducers.crypsReducer, cryps: reducers.crypsReducer,

View File

@ -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; const defaultCryps = null;
function crypsReducer(state = defaultCryps, action) { function crypsReducer(state = defaultCryps, action) {
switch (action.type) { switch (action.type) {
@ -72,6 +82,7 @@ function wsReducer(state = defaultWs, action) {
module.exports = { module.exports = {
accountReducer, accountReducer,
activeSkillReducer,
combinerReducer, combinerReducer,
crypsReducer, crypsReducer,
gameReducer, gameReducer,