Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 5 additions & 46 deletions src/gameplay/gameEngine/phases/common/votingTeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,53 +148,12 @@ class VotingTeam implements IPhase {
}

getStatusMessage(indexOfPlayer: number): string {
// If we are spectator
if (indexOfPlayer === -1) {
let str = '';
str += 'Waiting for votes: ';
for (let i = 0; i < this.thisRoom.playersYetToVote.length; i++) {
str = `${
str + this.thisRoom.anonymizer.anon(this.thisRoom.playersYetToVote[i])
}, `;
}
// Remove last , and replace with .
str = str.slice(0, str.length - 2);
str += '.';

return str;
}
// If user has voted already
if (
indexOfPlayer !== undefined &&
this.thisRoom.playersYetToVote.indexOf(
this.thisRoom.playersInGame[indexOfPlayer].username,
) === -1
) {
Comment on lines -166 to -172
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the "If user has voted already" branch was identical to the "If we are spectator" branch so the entire function can be replaced with the contents of either branch.

let str = '';
str += 'Waiting for votes: ';
for (let i = 0; i < this.thisRoom.playersYetToVote.length; i++) {
str = `${
str + this.thisRoom.anonymizer.anon(this.thisRoom.playersYetToVote[i])
}, `;
}
// Remove last , and replace with .
str = str.slice(0, str.length - 2);
str += '.';

return str;
}
// User has not voted yet or user is a spectator

const teamLeaderUsername =
this.thisRoom.playersInGame[this.thisRoom.teamLeader].username;

let str = '';
str += `${this.thisRoom.anonymizer.anon(teamLeaderUsername)} has picked: `;

for (let i = 0; i < this.thisRoom.proposedTeam.length; i++) {
str += `${this.thisRoom.anonymizer.anon(
this.thisRoom.proposedTeam[i],
)}, `;
str += 'Waiting for votes: ';
for (let i = 0; i < this.thisRoom.playersYetToVote.length; i++) {
str = `${
str + this.thisRoom.anonymizer.anon(this.thisRoom.playersYetToVote[i])
}, `;
}
// Remove last , and replace with .
str = str.slice(0, str.length - 2);
Expand Down