1
0

Working on turn timer

Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
James Ketrenos 2022-03-15 13:24:21 -07:00
parent 391e438990
commit 226d653455
2 changed files with 12 additions and 14 deletions

View File

@ -43,7 +43,6 @@ const Table = () => {
const [connection, setConnection] = useState(undefined);
const [state, setState] = useState(undefined);
const [color, setColor] = useState(undefined);
const [setPlayers] = useState(undefined);
const [priv, setPriv] = useState(undefined);
const [buildActive, setBuildActive] = useState(false);
const [cardActive, setCardActive] = useState(undefined);
@ -110,9 +109,6 @@ const Table = () => {
setPriv(priv);
}
if ('players' in data.update) {
setPlayers(data.update.players);
}
if ('name' in data.update && data.update.name !== name) {
console.log(`App - setting name: ${data.update.name}`);
setName(data.update.name);
@ -298,7 +294,6 @@ const Table = () => {
{ priv && priv.turnNotice && <div className="Dialog TurnNoticeDialog">
<Paper className="TurnNotice">
<div>{ priv.turnNotice }</div>
<Button onClick={() => { sendUpdate({type: 'pass'}) }}>done</Button>
<Button onClick={() => { sendUpdate({type: 'turn-notice'}) }}>dismiss</Button>
</Paper>
</div> }

View File

@ -1915,6 +1915,9 @@ const pass = (game, session) => {
game.turns++;
addActivity(game, session, `${name} passed their turn.`);
addChatMessage(game, null, `It is ${next.name}'s turn.`);
sendUpdateToPlayer(game, next, {
private: next.player
});
sendUpdateToPlayer(game, session, {
private: session.player
});
@ -3070,6 +3073,10 @@ const todo = `[ todo ]`;
const sendGameToPlayer = (game, session) => {
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({
type: 'game-update',
update: getFilteredGameForPlayer(game, session)
@ -3080,14 +3087,7 @@ const sendGameToPlayers = (game) => {
console.log(`${all}: -> sendGamePlayers - full game`);
for (let key in game.sessions) {
const _session = game.sessions[key];
if (!_session.ws) {
continue;
}
_session.ws.send(JSON.stringify({
type: 'game-update',
update: getFilteredGameForPlayer(game, _session)
}));
sendGameToPlayer(game, game.sessions[key]);
}
};
@ -3590,6 +3590,8 @@ router.ws("/ws/:id", async (ws, req) => {
}
processed = true;
const priorSession = session;
switch (data.type) {
case 'roll':
console.log(`${short}: <- roll:${getName(session)}`);
@ -3741,6 +3743,7 @@ router.ws("/ws/:id", async (ws, req) => {
break;
}
/* If the current player took an action, reset the session timer */
if (processed && session.color === game.turn.color) {
resetTurnTimer(game, session);
}