Working on turn timer
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
391e438990
commit
226d653455
@ -43,7 +43,6 @@ const Table = () => {
|
|||||||
const [connection, setConnection] = useState(undefined);
|
const [connection, setConnection] = useState(undefined);
|
||||||
const [state, setState] = useState(undefined);
|
const [state, setState] = useState(undefined);
|
||||||
const [color, setColor] = useState(undefined);
|
const [color, setColor] = useState(undefined);
|
||||||
const [setPlayers] = useState(undefined);
|
|
||||||
const [priv, setPriv] = useState(undefined);
|
const [priv, setPriv] = useState(undefined);
|
||||||
const [buildActive, setBuildActive] = useState(false);
|
const [buildActive, setBuildActive] = useState(false);
|
||||||
const [cardActive, setCardActive] = useState(undefined);
|
const [cardActive, setCardActive] = useState(undefined);
|
||||||
@ -110,9 +109,6 @@ const Table = () => {
|
|||||||
setPriv(priv);
|
setPriv(priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('players' in data.update) {
|
|
||||||
setPlayers(data.update.players);
|
|
||||||
}
|
|
||||||
if ('name' in data.update && data.update.name !== name) {
|
if ('name' in data.update && data.update.name !== name) {
|
||||||
console.log(`App - setting name: ${data.update.name}`);
|
console.log(`App - setting name: ${data.update.name}`);
|
||||||
setName(data.update.name);
|
setName(data.update.name);
|
||||||
@ -298,8 +294,7 @@ const Table = () => {
|
|||||||
{ priv && priv.turnNotice && <div className="Dialog TurnNoticeDialog">
|
{ priv && priv.turnNotice && <div className="Dialog TurnNoticeDialog">
|
||||||
<Paper className="TurnNotice">
|
<Paper className="TurnNotice">
|
||||||
<div>{ priv.turnNotice }</div>
|
<div>{ priv.turnNotice }</div>
|
||||||
<Button onClick={() => { sendUpdate({type: 'pass'}) }}>done</Button>
|
<Button onClick={() => { sendUpdate({type: 'turn-notice'}) }}>dismiss</Button>
|
||||||
<Button onClick={() => { sendUpdate({type: 'turn-notice'}) }}>dismiss</Button>
|
|
||||||
</Paper>
|
</Paper>
|
||||||
</div> }
|
</div> }
|
||||||
{ warning && <div className="Dialog WarningDialog">
|
{ warning && <div className="Dialog WarningDialog">
|
||||||
|
@ -1915,6 +1915,9 @@ const pass = (game, session) => {
|
|||||||
game.turns++;
|
game.turns++;
|
||||||
addActivity(game, session, `${name} passed their turn.`);
|
addActivity(game, session, `${name} passed their turn.`);
|
||||||
addChatMessage(game, null, `It is ${next.name}'s turn.`);
|
addChatMessage(game, null, `It is ${next.name}'s turn.`);
|
||||||
|
sendUpdateToPlayer(game, next, {
|
||||||
|
private: next.player
|
||||||
|
});
|
||||||
sendUpdateToPlayer(game, session, {
|
sendUpdateToPlayer(game, session, {
|
||||||
private: session.player
|
private: session.player
|
||||||
});
|
});
|
||||||
@ -3070,6 +3073,10 @@ const todo = `[ todo ]`;
|
|||||||
|
|
||||||
const sendGameToPlayer = (game, session) => {
|
const sendGameToPlayer = (game, session) => {
|
||||||
console.log(`${session.id}: -> sendGamePlayer:${getName(session)} - full game`);
|
console.log(`${session.id}: -> sendGamePlayer:${getName(session)} - full game`);
|
||||||
|
if (!session.ws) {
|
||||||
|
console.log(`${session.id}: -> sendGamePlayer:: Currently no connection`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
session.ws.send(JSON.stringify({
|
session.ws.send(JSON.stringify({
|
||||||
type: 'game-update',
|
type: 'game-update',
|
||||||
update: getFilteredGameForPlayer(game, session)
|
update: getFilteredGameForPlayer(game, session)
|
||||||
@ -3080,14 +3087,7 @@ const sendGameToPlayers = (game) => {
|
|||||||
console.log(`${all}: -> sendGamePlayers - full game`);
|
console.log(`${all}: -> sendGamePlayers - full game`);
|
||||||
|
|
||||||
for (let key in game.sessions) {
|
for (let key in game.sessions) {
|
||||||
const _session = game.sessions[key];
|
sendGameToPlayer(game, game.sessions[key]);
|
||||||
if (!_session.ws) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
_session.ws.send(JSON.stringify({
|
|
||||||
type: 'game-update',
|
|
||||||
update: getFilteredGameForPlayer(game, _session)
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3590,6 +3590,8 @@ router.ws("/ws/:id", async (ws, req) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processed = true;
|
processed = true;
|
||||||
|
const priorSession = session;
|
||||||
|
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'roll':
|
case 'roll':
|
||||||
console.log(`${short}: <- roll:${getName(session)}`);
|
console.log(`${short}: <- roll:${getName(session)}`);
|
||||||
@ -3741,6 +3743,7 @@ router.ws("/ws/:id", async (ws, req) => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If the current player took an action, reset the session timer */
|
||||||
if (processed && session.color === game.turn.color) {
|
if (processed && session.color === game.turn.color) {
|
||||||
resetTurnTimer(game, session);
|
resetTurnTimer(game, session);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user