-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(game-options): game option to prevent witch to know werewolves t…
- Loading branch information
1 parent
135aa63
commit 62b978f
Showing
11 changed files
with
2,425 additions
and
2,267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...reate-game/create-game-options/create-roles-game-options/create-witch-game-options.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { ApiPropertyOptions } from "@nestjs/swagger"; | ||
import { ApiProperty } from "@nestjs/swagger"; | ||
import { IsBoolean, IsOptional } from "class-validator"; | ||
|
||
import { WITCH_GAME_OPTIONS_API_PROPERTIES, WITCH_GAME_OPTIONS_FIELDS_SPECS } from "@/modules/game/schemas/game-options/roles-game-options/witch-game-options/witch-game-options.schema.constant"; | ||
|
||
class CreateWitchGameOptionsDto { | ||
@ApiProperty({ | ||
...WITCH_GAME_OPTIONS_API_PROPERTIES.doesKnowWerewolvesTargets, | ||
required: false, | ||
} as ApiPropertyOptions) | ||
@IsOptional() | ||
@IsBoolean() | ||
public doesKnowWerewolvesTargets: boolean = WITCH_GAME_OPTIONS_FIELDS_SPECS.doesKnowWerewolvesTargets.default; | ||
} | ||
|
||
export { CreateWitchGameOptionsDto }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
.../game-options/roles-game-options/witch-game-options/witch-game-options.schema.constant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { ApiPropertyOptions } from "@nestjs/swagger"; | ||
import type { ReadonlyDeep } from "type-fest"; | ||
|
||
import type { WitchGameOptions } from "@/modules/game/schemas/game-options/roles-game-options/witch-game-options/witch-game-options.schema"; | ||
import { DEFAULT_GAME_OPTIONS } from "@/modules/game/constants/game-options/game-options.constant"; | ||
|
||
import { convertMongoosePropOptionsToApiPropertyOptions } from "@/shared/api/helpers/api.helper"; | ||
import type { MongoosePropOptions } from "@/shared/mongoose/types/mongoose.types"; | ||
|
||
const WITCH_GAME_OPTIONS_FIELDS_SPECS = { | ||
doesKnowWerewolvesTargets: { | ||
required: true, | ||
default: DEFAULT_GAME_OPTIONS.roles.witch.doesKnowWerewolvesTargets, | ||
}, | ||
} as const satisfies Record<keyof WitchGameOptions, MongoosePropOptions>; | ||
|
||
const WITCH_GAME_OPTIONS_API_PROPERTIES: ReadonlyDeep<Record<keyof WitchGameOptions, ApiPropertyOptions>> = { | ||
doesKnowWerewolvesTargets: { | ||
description: "If set to `true`, the game master will point out the werewolves' targets to the witch to know which one she can save with her life potion.", | ||
...convertMongoosePropOptionsToApiPropertyOptions(WITCH_GAME_OPTIONS_FIELDS_SPECS.doesKnowWerewolvesTargets), | ||
}, | ||
}; | ||
|
||
export { | ||
WITCH_GAME_OPTIONS_API_PROPERTIES, | ||
WITCH_GAME_OPTIONS_FIELDS_SPECS, | ||
}; |
25 changes: 25 additions & 0 deletions
25
...e/schemas/game-options/roles-game-options/witch-game-options/witch-game-options.schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose"; | ||
import type { ApiPropertyOptions } from "@nestjs/swagger"; | ||
import { ApiProperty } from "@nestjs/swagger"; | ||
import { Expose } from "class-transformer"; | ||
|
||
import { WITCH_GAME_OPTIONS_API_PROPERTIES, WITCH_GAME_OPTIONS_FIELDS_SPECS } from "@/modules/game/schemas/game-options/roles-game-options/witch-game-options/witch-game-options.schema.constant"; | ||
|
||
@Schema({ | ||
versionKey: false, | ||
id: false, | ||
_id: false, | ||
}) | ||
class WitchGameOptions { | ||
@ApiProperty(WITCH_GAME_OPTIONS_API_PROPERTIES.doesKnowWerewolvesTargets as ApiPropertyOptions) | ||
@Prop(WITCH_GAME_OPTIONS_FIELDS_SPECS.doesKnowWerewolvesTargets) | ||
@Expose() | ||
public doesKnowWerewolvesTargets: boolean; | ||
} | ||
|
||
const WITCH_GAME_OPTIONS_SCHEMA = SchemaFactory.createForClass(WitchGameOptions); | ||
|
||
export { | ||
WitchGameOptions, | ||
WITCH_GAME_OPTIONS_SCHEMA, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.