takin hits
This commit is contained in:
@@ -9,7 +9,11 @@ const addState = connect(
|
||||
return ws.sendGameAbility(game.id, crypId, targetTeamId, ability);
|
||||
}
|
||||
|
||||
return { game, account, sendGameAbility };
|
||||
function sendGameTarget(crypId, abilityId) {
|
||||
return ws.sendGameTarget(game.id, crypId, abilityId);
|
||||
}
|
||||
|
||||
return { game, account, sendGameAbility, sendGameTarget };
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
const preact = require('preact');
|
||||
|
||||
function GamePanel({ game, sendGameAbility, account }) {
|
||||
function GamePanel({ game, sendGameAbility, sendGameTarget, account }) {
|
||||
if (!game) return <div>...</div>;
|
||||
|
||||
const otherTeams = game.teams.filter(t => t.id !== account.id);
|
||||
|
||||
const playerTeam = game.teams.find(t => t.id === account.id);
|
||||
|
||||
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>
|
||||
));
|
||||
|
||||
const playerCryps = playerTeam.cryps.map(c => (
|
||||
<div key={c.id} >
|
||||
<div>{c.name}</div>
|
||||
@@ -21,6 +32,7 @@ function GamePanel({ game, sendGameAbility, account }) {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>{game.phase}</h1>
|
||||
<div>
|
||||
<h1>them</h1>
|
||||
<div>{JSON.stringify(otherTeams)}</div>
|
||||
@@ -28,6 +40,7 @@ function GamePanel({ game, sendGameAbility, account }) {
|
||||
<div>
|
||||
<h1>us</h1>
|
||||
{playerCryps}
|
||||
{targetBtn}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -117,6 +117,9 @@ function createSocket(store) {
|
||||
send({ method: 'game_ability', params: { game_id: gameId, cryp_id: crypId, target_team_id: targetTeamId, ability } });
|
||||
}
|
||||
|
||||
function sendGameTarget(gameId, crypId, abilityId) {
|
||||
send({ method: 'game_target', params: { game_id: gameId, cryp_id: crypId, ability_id: abilityId } });
|
||||
}
|
||||
|
||||
function sendItemUse(item, target) {
|
||||
console.log(item, target);
|
||||
@@ -160,6 +163,7 @@ function createSocket(store) {
|
||||
sendAccountRegister,
|
||||
sendGamePve,
|
||||
sendGameAbility,
|
||||
sendGameTarget,
|
||||
sendCrypSpawn,
|
||||
sendItemUse,
|
||||
connect,
|
||||
|
||||
Reference in New Issue
Block a user