feature/MAPG-213-user-shouldn-t-be-able-to-re-guess-when-page-is-reloaded #17

Merged
bence merged 3 commits from feature/MAPG-213-user-shouldn-t-be-able-to-re-guess-when-page-is-reloaded into develop 2021-04-04 22:31:29 +02:00
Showing only changes of commit 6342bb1e79 - Show all commits

View File

@ -165,9 +165,18 @@ class MultiGame {
} }
_endRound(room, round) { _endRound(room, round) {
var data = { position: round.place.position, allResults: this._collectResultsInRound(room, round) }; var allResults = this._collectResultsInRound(room, round);
var self = this; var self = this;
room.members.forEach(function (member) { room.members.forEach(function (member, token) {
var result = { guessPosition: null, distance: null, score: 0 };
if (round.results.has(token)) {
result = round.results.get(token);
} else {
round.results.set(token, result);
}
var data = { position: round.place.position, result: result, allResults: allResults };
self._sendToMember(member, 'end_round', data); self._sendToMember(member, 'end_round', data);
}); });
} }
@ -183,9 +192,13 @@ class MultiGame {
} }
data.history = []; data.history = [];
for (var i = 0; i < room.currentRound; ++i) { for (var i = 0; i <= room.currentRound; ++i) {
var round = room.rounds[i]; var round = room.rounds[i];
if (i === room.currentRound && !round.results.has(token)) {
continue;
}
var result = { guessPosition: null, distance: null, score: 0 }; var result = { guessPosition: null, distance: null, score: 0 };
var allResults = []; var allResults = [];
@ -210,6 +223,8 @@ class MultiGame {
data.members.push({ userName: currentMember.userName, me: member === currentMember }); data.members.push({ userName: currentMember.userName, me: member === currentMember });
}); });
data.readyToContinue = room.currentRound >= 0 && room.members.size === room.rounds[room.currentRound].results.size
this._sendToMember(member, 'initialize', data); this._sendToMember(member, 'initialize', data);
} }