Skip to content

Commit

Permalink
fix(game-history-record): don't generate voting result if play type i…
Browse files Browse the repository at this point in the history
…s not vote (#970)
  • Loading branch information
antoinezanardi committed Apr 9, 2024
1 parent c687756 commit 42910b5
Show file tree
Hide file tree
Showing 5 changed files with 16,914 additions and 16,763 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export class GameHistoryRecordService {
revealedPlayers: this.generateCurrentGameHistoryRecordRevealedPlayersToInsert(baseGame, newGame),
deadPlayers: this.generateCurrentGameHistoryRecordDeadPlayersToInsert(baseGame, newGame),
};
gameHistoryRecordToInsert.play.voting = this.generateCurrentGameHistoryRecordPlayVotingToInsert(baseGame as GameWithCurrentPlay, newGame, gameHistoryRecordToInsert);
if (gameHistoryRecordToInsert.play.type === "vote") {
gameHistoryRecordToInsert.play.voting = this.generateCurrentGameHistoryRecordPlayVotingToInsert(baseGame as GameWithCurrentPlay, newGame, gameHistoryRecordToInsert);
}
return plainToInstance(GameHistoryRecordToInsert, gameHistoryRecordToInsert, DEFAULT_PLAIN_TO_INSTANCE_OPTIONS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ Feature: 📜 Game History
| name |
| JB |
And the play's votes from the previous history record should be undefined
And the play's voting result from the previous history record should be undefined
And the game's current play should be werewolves to eat

When the werewolves eat the player named Antoine
Expand Down Expand Up @@ -345,11 +346,13 @@ Feature: 📜 Game History
When the werewolves eat the player named Thomas
And the most recent history record is retrieved
Then the play's votes from the previous history record should be undefined
And the play's voting result from the previous history record should be undefined
And the game's current play should be survivors to bury-dead-bodies

When the survivors bury dead bodies
And the most recent history record is retrieved
Then the play's votes from the previous history record should be undefined
And the play's voting result from the previous history record should be undefined
And the game's current play should be survivors to vote

When the survivors vote with the following votes
Expand All @@ -373,16 +376,19 @@ Feature: 📜 Game History
When the sheriff breaks the tie in votes by choosing the player named Doudou
And the most recent history record is retrieved
Then the play's votes from the previous history record should be undefined
And the play's voting result from the previous history record should be undefined
And the game's current play should be survivors to bury-dead-bodies

When the survivors bury dead bodies
And the most recent history record is retrieved
Then the play's votes from the previous history record should be undefined
And the play's voting result from the previous history record should be undefined
And the game's current play should be stuttering-judge to request-another-vote

When the stuttering judge requests another vote
And the most recent history record is retrieved
Then the play's votes from the previous history record should be undefined
And the play's voting result from the previous history record should be undefined
And the play's targets from the previous history record should be undefined
And the play's from the previous history record should have the stuttering judge request
And the game's current play should be survivors to vote because stuttering-judge-request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ Then(/^the play's voting result from the previous history record should be (?<vo
expect(this.lastGameHistoryRecord.play.voting?.result).toBe(votingResult);
});

Then(/^the play's voting result from the previous history record should be undefined$/u, function(this: CustomWorld): void {
expect(this.lastGameHistoryRecord.play.voting?.result).toBeUndefined();
});

Then(/^the play's from the previous history record should (?<isNotRequested>not )?have the stuttering judge request$/u, function(this: CustomWorld, notRequested: string | null): void {
expect(this.lastGameHistoryRecord.play.didJudgeRequestAnotherVote).toBe(notRequested === null ? true : undefined);
});
Expand Down

0 comments on commit 42910b5

Please sign in to comment.