Fix VP not counting on placement
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
b66e1fb6e5
commit
80bc3642c2
@ -3270,6 +3270,8 @@ const calculatePoints = (game, update) => {
|
|||||||
if (player.status === 'Not active') {
|
if (player.status === 'Not active') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const currentPoints = player.points;
|
||||||
|
|
||||||
player.points = 0;
|
player.points = 0;
|
||||||
if (key === game.longestRoad) {
|
if (key === game.longestRoad) {
|
||||||
player.points += 2;
|
player.points += 2;
|
||||||
@ -3295,37 +3297,45 @@ const calculatePoints = (game, update) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (player.points === currentPoints) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.points < 10) {
|
||||||
|
update.players = getFilteredPlayers(game);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* This player has 10 points! Check if they are the current
|
/* This player has 10 points! Check if they are the current
|
||||||
* player and if so, declare victory! */
|
* player and if so, declare victory! */
|
||||||
if (player.points >= 10) {
|
console.log(`${info}: Whoa! ${player.name} has ${player.points}!`);
|
||||||
console.log(`${info}: Whoa! ${player.name} has ${player.points}!`);
|
for (let key in game.sessions) {
|
||||||
for (let key in game.sessions) {
|
if (game.sessions[key].color !== player.color
|
||||||
if (game.sessions[key].color !== player.color
|
|| game.sessions[key].status === 'Not active') {
|
||||||
|| game.sessions[key].status === 'Not active') {
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const message = `Wahoo! ${player.name} has 10 points on their turn and has won!`;
|
|
||||||
addChatMessage(game, null, message)
|
|
||||||
console.log(`${info}: ${message}`);
|
|
||||||
update.winner = Object.assign({}, player, {
|
|
||||||
state: 'winner',
|
|
||||||
robberStole: game.robberStole,
|
|
||||||
stolen: game.stolen,
|
|
||||||
chat: game.chat,
|
|
||||||
turns: game.turns,
|
|
||||||
players: game.players,
|
|
||||||
elapsedTime: Date.now() - game.startTime
|
|
||||||
});
|
|
||||||
game.winner = update.winner;
|
|
||||||
game.state = 'winner';
|
|
||||||
game.waiting = [];
|
|
||||||
stopTurnTimer(game);
|
|
||||||
sendUpdateToPlayers(game, {
|
|
||||||
state: game.state,
|
|
||||||
winner: game.winner,
|
|
||||||
players: game.players /* unfiltered */
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
const message = `Wahoo! ${player.name} has 10 points on their turn and has won!`;
|
||||||
|
addChatMessage(game, null, message)
|
||||||
|
console.log(`${info}: ${message}`);
|
||||||
|
update.winner = Object.assign({}, player, {
|
||||||
|
state: 'winner',
|
||||||
|
robberStole: game.robberStole,
|
||||||
|
stolen: game.stolen,
|
||||||
|
chat: game.chat,
|
||||||
|
turns: game.turns,
|
||||||
|
players: game.players,
|
||||||
|
elapsedTime: Date.now() - game.startTime
|
||||||
|
});
|
||||||
|
game.winner = update.winner;
|
||||||
|
game.state = 'winner';
|
||||||
|
game.waiting = [];
|
||||||
|
stopTurnTimer(game);
|
||||||
|
sendUpdateToPlayers(game, {
|
||||||
|
state: game.state,
|
||||||
|
winner: game.winner,
|
||||||
|
players: game.players /* unfiltered */
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user