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) {
const { ws, game, account, activeSkill, activeIncoming } = state;
function selectSkillTarget(targetTeamId) {
function selectSkillTarget(targetCrypId) {
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;
}

View File

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

View File

@ -17,6 +17,7 @@ const Body = require('./components/body.component');
const store = createStore(
combineReducers({
account: reducers.accountReducer,
activeSkill: reducers.activeSkillReducer,
combiner: reducers.combinerReducer,
game: reducers.gameReducer,
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;
function crypsReducer(state = defaultCryps, action) {
switch (action.type) {
@ -72,6 +82,7 @@ function wsReducer(state = defaultWs, action) {
module.exports = {
accountReducer,
activeSkillReducer,
combinerReducer,
crypsReducer,
gameReducer,