diff --git a/client/src/Winner.js b/client/src/Winner.js index feac1b4..107bea4 100644 --- a/client/src/Winner.js +++ b/client/src/Winner.js @@ -94,6 +94,9 @@ const Winner = ({ winnerDismissed, setWinnerDismissed }) => { let playerStolen = []; const stats = winner.stolen; for (let player in stats) { + if (player === 'total') { + continue; + } if (player === 'robber') { robber = <>; for (let type in stats.robber.stole) { @@ -112,7 +115,7 @@ const Winner = ({ winnerDismissed, setWinnerDismissed }) => { continue; } - if (stats[player].stolen.total < max) { + if ( stats[player].stolen.total < max) { continue; } if (stats[player].stolen.total > max) { diff --git a/server/routes/games.js b/server/routes/games.js index 3b50d28..451753b 100755 --- a/server/routes/games.js +++ b/server/routes/games.js @@ -292,7 +292,7 @@ const distributeResources = (game, roll) => { if (!tile.robber) { receives[active.color][resource.type] += count; } else { - trackTheft(game, active.color, robber, resource.type, count); + trackTheft(game, active.color, 'robber', resource.type, count); receives.robber[resource.type] += count; } } @@ -4072,11 +4072,11 @@ const trackTheft = (game, from, to, type, count) => { }); /* Initialize 'type' field in structures */ - if (!(type in stats[from].stole)) { - stats[from].stole[type] = 0; + if (!(type in stats[from].stolen)) { + stats[from].stolen[type] = 0; } - if (!(type in stats[to].stolen)) { - stats[to].stolen[type] = 0; + if (!(type in stats[to].stole)) { + stats[to].stole[type] = 0; } /* Update counts */ @@ -4112,7 +4112,9 @@ const resetGame = (game) => { players: game.players, stolen: { robber: { - stole: 0 + stole: { + total: 0 + } }, total: 0 },