Skip to content

Commit

Permalink
test(acceptance): acceptances tests for three brothers (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinezanardi committed Aug 31, 2023
1 parent caa3960 commit df6c976
Show file tree
Hide file tree
Showing 8 changed files with 14,843 additions and 14,872 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ export class GamePlayService {

private isThreeBrothersGamePlaySuitableForCurrentPhase(game: CreateGameDto | Game): boolean {
const { wakingUpInterval } = game.options.roles.threeBrothers;
const shouldThreeBrothersBeCalled = wakingUpInterval > 0;
const shouldThreeBrothersBeCalledOnCurrentTurn = this.shouldBeCalledOnCurrentTurnInterval(wakingUpInterval, game);
if (game instanceof CreateGameDto) {
return shouldThreeBrothersBeCalled && !!getPlayerDtoWithRole(game, RoleNames.THREE_BROTHERS);
return shouldThreeBrothersBeCalledOnCurrentTurn && !!getPlayerDtoWithRole(game, RoleNames.THREE_BROTHERS);
}
const threeBrothersPlayers = getPlayersWithCurrentRole(game, RoleNames.THREE_BROTHERS);
const minimumBrotherCountToCall = 2;
return shouldThreeBrothersBeCalled && threeBrothersPlayers.filter(brother => brother.isAlive).length >= minimumBrotherCountToCall;
return shouldThreeBrothersBeCalledOnCurrentTurn && threeBrothersPlayers.filter(brother => brother.isAlive).length >= minimumBrotherCountToCall;
}

private isTwoSistersGamePlaySuitableForCurrentPhase(game: CreateGameDto | Game): boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"roles": {
"threeBrothers": {
"wakingUpInterval": 0
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"roles": {
"threeBrothers": {
"wakingUpInterval": 1
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@three-brothers-role

Feature: 👨‍👨‍👦 Three Brothers role

Scenario: 👨‍👨‍👦 Three Brothers are called every other night and not called anymore if two die
Given a created game with options described in file no-sheriff-option.json and with the following players
| name | role |
| Antoine | three-brothers |
| Olivia | three-brothers |
| Thomas | three-brothers |
| JB | werewolf |
| Maxime | villager |
| Julien | villager |
Then the game's current play should be three-brothers to meet-each-other

When the three brothers meet each other
Then the game's current play should be werewolves to eat

When the werewolves eat the player named Thomas
Then the player named Thomas should be murdered by werewolves from eaten
And the game's current play should be all to vote

When the player or group skips his turn
Then the game's current play should be werewolves to eat

When the werewolves eat the player named Maxime
Then the player named Maxime should be murdered by werewolves from eaten
And the game's current play should be all to vote

When the player or group skips his turn
Then the game's current play should be three-brothers to meet-each-other

When the three brothers meet each other
Then the game's current play should be werewolves to eat

When the werewolves eat the player named Olivia
Then the player named Olivia should be murdered by werewolves from eaten
And the game's current play should be all to vote

When the player or group skips his turn
Then the game's current play should be werewolves to eat

When the werewolves eat the player named Julien
Then the player named Julien should be murdered by werewolves from eaten
And the game's current play should be all to vote

When the player or group skips his turn
Then the game's current play should be werewolves to eat

Scenario: 👨‍👨‍👦 Three Brothers are never called when options say they are not called at all
Given a created game with options described in file no-sheriff-option.json, three-brothers-never-waking-up-option.json and with the following players
| name | role |
| Antoine | three-brothers |
| Olivia | three-brothers |
| Thomas | three-brothers |
| JB | werewolf |
| Maxime | villager |
| Julien | villager |
Then the game's current play should be werewolves to eat

Scenario: 👨‍👨‍👦 Three Brothers are waking up every night when options say they are called every night
Given a created game with options described in file no-sheriff-option.json, three-brothers-waking-up-every-night-option.json and with the following players
| name | role |
| Antoine | three-brothers |
| Olivia | three-brothers |
| Thomas | three-brothers |
| JB | werewolf |
| Maxime | villager |
| Julien | villager |
Then the game's current play should be three-brothers to meet-each-other

When the three brothers meet each other
Then the game's current play should be werewolves to eat

When the werewolves eat the player named Thomas
Then the player named Thomas should be murdered by werewolves from eaten
And the game's current play should be all to vote

When the player or group skips his turn
Then the game's current play should be three-brothers to meet-each-other
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Feature: 👯‍ Two sisters role
When the player or group skips his turn
Then the game's current play should be werewolves to eat

Scenario: 👯‍ Two sisters are called never called when options say they are not called
Scenario: 👯‍ Two sisters are called never called when options say they are not called at all
Given a created game with options described in file no-sheriff-option.json, two-sisters-never-waking-up-option.json and with the following players
| name | role |
| Antoine | two-sisters |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ When(/^the two sisters meet each other$/u, async function(this: CustomWorld): Pr
this.game = this.response.json<Game>();
});

When(/^the three brothers meet each other$/u, async function(this: CustomWorld): Promise<void> {
this.response = await makeGamePlayRequest({}, this.game, this.app);
this.game = this.response.json<Game>();
});

When(/^the guard protects the player named (?<name>.+)$/u, async function(this: CustomWorld, targetName: string): Promise<void> {
const target = getPlayerWithNameOrThrow(targetName, this.game, new Error("Player name not found"));
const makeGamePlayDto: MakeGamePlayDto = { targets: [{ playerId: target._id }] };
Expand Down

0 comments on commit df6c976

Please sign in to comment.