diff --git a/client/src/Winner.js b/client/src/Winner.js
index 107bea4..c8ca94e 100644
--- a/client/src/Winner.js
+++ b/client/src/Winner.js
@@ -91,10 +91,10 @@ const Winner = ({ winnerDismissed, setWinnerDismissed }) => {
let robber;
let max = 0;
- let playerStolen = [];
+ let playerStolen = {};
const stats = winner.stolen;
for (let player in stats) {
- if (player === 'total') {
+ if (player === 'total' || player === 'player') {
continue;
}
if (player === 'robber') {
@@ -109,7 +109,7 @@ const Winner = ({ winnerDismissed, setWinnerDismissed }) => {
>;
}
robber =
- Throughout the game, the robber stole
{stats.robber.stole.total}
+ Throughout the game, the robber blocked {stats.robber.stole.total}
resources:
{robber}
;
continue;
@@ -120,12 +120,16 @@ const Winner = ({ winnerDismissed, setWinnerDismissed }) => {
}
if (stats[player].stolen.total > max) {
max = stats[player].stolen.total;
- playerStolen = [];
+ playerStolen = {
+ robber: stats[player].stolen.robber,
+ player: stats[player].stolen.player,
+ element: <>>
+ };
}
let stolen;
for (let type in stats[player].stolen) {
- if (type === 'total') {
+ if ([ 'total', 'robber', 'player' ].indexOf(type) !== -1) {
continue;
}
if (!stolen) {
@@ -137,15 +141,15 @@ const Winner = ({ winnerDismissed, setWinnerDismissed }) => {
>;
}
if (stolen) {
- playerStolen.push(
+ playerStolen.element =
{winner.players[player].name}
{stolen}
- );
+
;
}
}
if (!robber) {
- robber = The robber never stole any resources from anyone!
;
+ robber = The robber never blocked any resources from anyone!
;
}
const averageSeconds = Math.floor(winner.totalTime / turnCount / 1000),
@@ -178,10 +182,10 @@ const Winner = ({ winnerDismissed, setWinnerDismissed }) => {
The game took {totalTime}.
{ robber }
{ max !== 0 && <>
- The thief (and other players) stole the most resources
- from:
+ The robber stole {playerStolen.robber} and other players
+ stole {playerStolen.player} resources from:
- { playerStolen }
+ { playerStolen.element }
> }
diff --git a/server/routes/games.js b/server/routes/games.js
index c20d4ae..9ee4482 100755
--- a/server/routes/games.js
+++ b/server/routes/games.js
@@ -4396,7 +4396,9 @@ const trackTheft = (game, from, to, type, count) => {
total: 0
},
stolen: { /* the resources stolen from this player */
- total: 0
+ total: 0,
+ player: 0, /* by players */
+ robber: 0 /* by robber */
}
};
}
@@ -4412,6 +4414,11 @@ const trackTheft = (game, from, to, type, count) => {
/* Update counts */
stats[from].stolen.total += count;
+ if (to === 'robber') {
+ stats[from].stolen.robber += count;
+ } else {
+ stats[from].stolen.player += count;
+ }
stats[from].stolen[type] += count;
stats[to].stole.total += count;
stats[to].stole[type] += count;