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 [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> }
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user