Skip to content

Commit

Permalink
feat(game-options): thief chosen card revealed option (#713)
Browse files Browse the repository at this point in the history
Closes #705
  • Loading branch information
antoinezanardi committed Dec 3, 2023
1 parent 38aa021 commit f3277db
Show file tree
Hide file tree
Showing 8 changed files with 21,769 additions and 21,702 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const DEFAULT_GAME_OPTIONS: ReadonlyDeep<GameOptions> = {
},
thief: {
mustChooseBetweenWerewolves: true,
isChosenCardRevealed: false,
additionalCardsCount: 2,
},
piedPiper: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ class CreateThiefGameOptionsDto {
@IsBoolean()
public mustChooseBetweenWerewolves: boolean = THIEF_GAME_OPTIONS_FIELDS_SPECS.mustChooseBetweenWerewolves.default;

@ApiProperty({
...THIEF_GAME_OPTIONS_API_PROPERTIES.isChosenCardRevealed,
required: false,
} as ApiPropertyOptions)
@IsOptional()
@IsBoolean()
public isChosenCardRevealed: boolean = THIEF_GAME_OPTIONS_FIELDS_SPECS.isChosenCardRevealed.default;

@ApiProperty({
...THIEF_GAME_OPTIONS_API_PROPERTIES.additionalCardsCount,
required: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const THIEF_GAME_OPTIONS_FIELDS_SPECS = {
required: true,
default: DEFAULT_GAME_OPTIONS.roles.thief.mustChooseBetweenWerewolves,
},
isChosenCardRevealed: {
required: true,
default: DEFAULT_GAME_OPTIONS.roles.thief.isChosenCardRevealed,
},
additionalCardsCount: {
required: true,
default: DEFAULT_GAME_OPTIONS.roles.thief.additionalCardsCount,
Expand All @@ -25,6 +29,10 @@ const THIEF_GAME_OPTIONS_API_PROPERTIES: ReadonlyDeep<Record<keyof ThiefGameOpti
description: "If set to `true`, if all `thief` additional cards are from the `werewolves` side, he can't skip and must choose one",
...convertMongoosePropOptionsToApiPropertyOptions(THIEF_GAME_OPTIONS_FIELDS_SPECS.mustChooseBetweenWerewolves),
},
isChosenCardRevealed: {
description: "If set to `true`, the `thief` chosen card is revealed to every other players",
...convertMongoosePropOptionsToApiPropertyOptions(THIEF_GAME_OPTIONS_FIELDS_SPECS.isChosenCardRevealed),
},
additionalCardsCount: {
description: "Number of additional cards for the `thief` at the beginning of the game",
...convertMongoosePropOptionsToApiPropertyOptions(THIEF_GAME_OPTIONS_FIELDS_SPECS.additionalCardsCount),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class ThiefGameOptions {
@Expose()
public mustChooseBetweenWerewolves: boolean;

@ApiProperty(THIEF_GAME_OPTIONS_API_PROPERTIES.isChosenCardRevealed as ApiPropertyOptions)
@Prop(THIEF_GAME_OPTIONS_FIELDS_SPECS.isChosenCardRevealed)
@Expose()
public isChosenCardRevealed: boolean;

@ApiProperty(THIEF_GAME_OPTIONS_API_PROPERTIES.additionalCardsCount as ApiPropertyOptions)
@Prop(THIEF_GAME_OPTIONS_FIELDS_SPECS.additionalCardsCount)
@Expose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ describe("Game Controller", () => {
},
thief: {
mustChooseBetweenWerewolves: false,
isChosenCardRevealed: true,
additionalCardsCount: 4,
},
piedPiper: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function createFakeCreatePiedPiperGameOptionsDto(piedPiperGameOptions: Partial<C
function createFakeCreateThiefGameOptionsDto(thiefGameOptions: Partial<CreateThiefGameOptionsDto> = {}, override: object = {}): CreateThiefGameOptionsDto {
return plainToInstance(CreateThiefGameOptionsDto, {
mustChooseBetweenWerewolves: thiefGameOptions.mustChooseBetweenWerewolves ?? faker.datatype.boolean(),
isChosenCardRevealed: thiefGameOptions.isChosenCardRevealed ?? faker.datatype.boolean(),
additionalCardsCount: thiefGameOptions.additionalCardsCount ?? faker.number.int({ min: 1, max: 5 }),
...override,
}, DEFAULT_PLAIN_TO_INSTANCE_OPTIONS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function createFakePiedPiperGameOptions(piedPiperGameOptions: Partial<PiedPiperG
function createFakeThiefGameOptions(thiefGameOptions: Partial<ThiefGameOptions> = {}, override: object = {}): ThiefGameOptions {
return plainToInstance(ThiefGameOptions, {
mustChooseBetweenWerewolves: thiefGameOptions.mustChooseBetweenWerewolves ?? faker.datatype.boolean(),
isChosenCardRevealed: thiefGameOptions.isChosenCardRevealed ?? faker.datatype.boolean(),
additionalCardsCount: thiefGameOptions.additionalCardsCount ?? faker.number.int({ min: 1, max: 5 }),
...override,
}, DEFAULT_PLAIN_TO_INSTANCE_OPTIONS);
Expand Down

0 comments on commit f3277db

Please sign in to comment.