select targets
This commit is contained in:
parent
b7b5806d98
commit
89ffc2fca3
@ -17,7 +17,7 @@ export const SET_ACTIVE_INCOMING = 'SET_ACTIVE_INCOMING';
|
|||||||
export const setActiveIncoming = (value) => ({ type: SET_ACTIVE_INCOMING, value });
|
export const setActiveIncoming = (value) => ({ type: SET_ACTIVE_INCOMING, value });
|
||||||
|
|
||||||
export const SET_ACTIVE_SKILL = 'SET_ACTIVE_SKILL';
|
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 SET_WS = 'SET_WS';
|
||||||
export const setWs = (value) => ({ type: SET_WS, value });
|
export const setWs = (value) => ({ type: SET_WS, value });
|
||||||
|
|||||||
@ -6,7 +6,7 @@ const Game = require('./game');
|
|||||||
|
|
||||||
const addState = connect(
|
const addState = connect(
|
||||||
function receiveState(state) {
|
function receiveState(state) {
|
||||||
const { ws, game, account, activeSkill } = state;
|
const { ws, game, account, activeSkill, activeIncoming } = state;
|
||||||
function selectSkillTarget(targetTeamId) {
|
function selectSkillTarget(targetTeamId) {
|
||||||
if (activeSkill) {
|
if (activeSkill) {
|
||||||
return ws.sendGameSkill(game.id, activeSkill.crypId, targetTeamId, activeSkill.skill);
|
return ws.sendGameSkill(game.id, activeSkill.crypId, targetTeamId, activeSkill.skill);
|
||||||
@ -14,18 +14,27 @@ const addState = connect(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendGameTarget(crypId, skillId) {
|
function selectIncomingTarget(crypId) {
|
||||||
return ws.sendGameTarget(game.id, crypId, skillId);
|
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 receiveDispatch(dispatch) {
|
||||||
function setActiveSkill(crypId, skill) {
|
function setActiveSkill(crypId, skill) {
|
||||||
dispatch(actions.setActiveSkill(crypId, skill))
|
dispatch(actions.setActiveSkill(crypId, skill))
|
||||||
}
|
}
|
||||||
|
|
||||||
return { setActiveSkill };
|
function setActiveIncoming(skillId) {
|
||||||
|
dispatch(actions.setActiveIncoming(skillId))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return { setActiveSkill, setActiveIncoming };
|
||||||
}
|
}
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,19 +1,44 @@
|
|||||||
const preact = require('preact');
|
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 <div>...</div>;
|
if (!game) return <div>...</div>;
|
||||||
|
|
||||||
const otherTeams = game.teams.filter(t => t.id !== account.id);
|
const otherTeams = game.teams.filter(t => t.id !== account.id);
|
||||||
|
|
||||||
const playerTeam = game.teams.find(t => t.id === account.id);
|
const playerTeam = game.teams.find(t => t.id === account.id);
|
||||||
|
|
||||||
const incoming = playerTeam.incoming.map((inc, i) => (
|
const incoming = playerTeam.incoming.map(inc => {
|
||||||
<div key={inc}>{JSON.stringify(inc)}</div>
|
return (
|
||||||
));
|
<div className="tile is-child" key={inc.id}>
|
||||||
|
<div>{JSON.stringify(inc)}</div>
|
||||||
|
<button
|
||||||
|
className="button is-dark is-fullwidth"
|
||||||
|
type="submit"
|
||||||
|
onClick={() => setActiveIncoming(inc.id)}>
|
||||||
|
{inc.skill}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
function PlayerCrypCard(cryp) {
|
function PlayerCrypCard(cryp) {
|
||||||
|
if (activeIncoming) console.log('should be a pointer');
|
||||||
return (
|
return (
|
||||||
<div key={cryp.id}
|
<div
|
||||||
|
key={cryp.id}
|
||||||
|
style={ activeIncoming ? { cursor: 'pointer' } : {}}
|
||||||
|
onClick={() => selectIncomingTarget(cryp.id)}
|
||||||
className="tile is-vertical">
|
className="tile is-vertical">
|
||||||
<div className="tile is-child">
|
<div className="tile is-child">
|
||||||
<div className="columns" >
|
<div className="columns" >
|
||||||
@ -33,7 +58,6 @@ function GamePanel({ game, activeSkill, setActiveSkill, selectSkillTarget, accou
|
|||||||
|
|
||||||
<div className="has-text-centered">{cryp.xp} / {Math.pow(2,cryp.lvl+1)} XP </div>
|
<div className="has-text-centered">{cryp.xp} / {Math.pow(2,cryp.lvl+1)} XP </div>
|
||||||
<progress className="progress is-dark" value={cryp.xp} max={Math.pow(2,cryp.lvl+1)}></progress>
|
<progress className="progress is-dark" value={cryp.xp} max={Math.pow(2,cryp.lvl+1)}></progress>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
className="button is-dark is-fullwidth"
|
className="button is-dark is-fullwidth"
|
||||||
@ -96,16 +120,6 @@ function GamePanel({ game, activeSkill, setActiveSkill, selectSkillTarget, accou
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// const targetBtn = playerTeam.incoming.map(i => (
|
|
||||||
// <button
|
|
||||||
// key={i.id}
|
|
||||||
// className="button is-dark is-fullwidth"
|
|
||||||
// type="submit"
|
|
||||||
// onClick={() => sendGameTarget(playerTeam.cryps[0].id, i.id)}>
|
|
||||||
// take the hit
|
|
||||||
// </button>
|
|
||||||
// ));
|
|
||||||
|
|
||||||
// style={{ "min-height": "100%" }}
|
// style={{ "min-height": "100%" }}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -18,6 +18,7 @@ const store = createStore(
|
|||||||
combineReducers({
|
combineReducers({
|
||||||
activeItem: reducers.activeItemReducer,
|
activeItem: reducers.activeItemReducer,
|
||||||
activeSkill: reducers.activeSkillReducer,
|
activeSkill: reducers.activeSkillReducer,
|
||||||
|
activeIncoming: reducers.activeIncomingReducer,
|
||||||
account: reducers.accountReducer,
|
account: reducers.accountReducer,
|
||||||
game: reducers.gameReducer,
|
game: reducers.gameReducer,
|
||||||
cryps: reducers.crypsReducer,
|
cryps: reducers.crypsReducer,
|
||||||
|
|||||||
@ -115,10 +115,12 @@ function createSocket(store) {
|
|||||||
|
|
||||||
function sendGameSkill(gameId, crypId, targetTeamId, skill) {
|
function sendGameSkill(gameId, crypId, targetTeamId, skill) {
|
||||||
send({ method: 'game_skill', params: { game_id: gameId, cryp_id: crypId, target_team_id: 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) {
|
function sendGameTarget(gameId, crypId, skillId) {
|
||||||
send({ method: 'game_target', params: { game_id: gameId, cryp_id: crypId, skill_id: skillId } });
|
send({ method: 'game_target', params: { game_id: gameId, cryp_id: crypId, skill_id: skillId } });
|
||||||
|
store.dispatch(actions.setActiveIncoming(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendItemUse(item, target) {
|
function sendItemUse(item, target) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user