-
-
Notifications
You must be signed in to change notification settings - Fork 13
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): skip votes options (#370)
- Loading branch information
1 parent
20a1e74
commit 9859940
Showing
22 changed files
with
36,124 additions
and
34,134 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
17 changes: 17 additions & 0 deletions
17
src/modules/game/constants/game-options/votes-game-options.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,17 @@ | ||
import type { ApiPropertyOptions } from "@nestjs/swagger"; | ||
import type { VotesGameOptions } from "../../schemas/game-options/votes-game-options.schema"; | ||
import { defaultGameOptions } from "./game-options.constant"; | ||
|
||
const votesGameOptionsFieldsSpecs = Object.freeze({ canBeSkipped: { default: defaultGameOptions.votes.canBeSkipped } }); | ||
|
||
const votesGameOptionsApiProperties: Record<keyof VotesGameOptions, ApiPropertyOptions> = Object.freeze({ | ||
canBeSkipped: { | ||
description: "If set to `true`, players are not obliged to vote. There won't be any death if votes are skipped. Sheriff election nor votes because of the angel presence can't be skipped", | ||
...votesGameOptionsFieldsSpecs.canBeSkipped, | ||
}, | ||
}); | ||
|
||
export { | ||
votesGameOptionsApiProperties, | ||
votesGameOptionsFieldsSpecs, | ||
}; |
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-votes-game-options/create-votes-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 { ApiProperty } from "@nestjs/swagger"; | ||
import { Type } from "class-transformer"; | ||
import { IsBoolean, IsOptional } from "class-validator"; | ||
import { votesGameOptionsApiProperties, votesGameOptionsFieldsSpecs } from "../../../../constants/game-options/votes-game-options.constant"; | ||
|
||
class CreateVotesGameOptionsDto { | ||
@ApiProperty({ | ||
...votesGameOptionsApiProperties.canBeSkipped, | ||
required: false, | ||
}) | ||
@Type(() => Boolean) | ||
@IsOptional() | ||
@IsBoolean() | ||
public canBeSkipped: boolean = votesGameOptionsFieldsSpecs.canBeSkipped.default; | ||
} | ||
|
||
export { CreateVotesGameOptionsDto }; |
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
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
23 changes: 23 additions & 0 deletions
23
src/modules/game/schemas/game-options/votes-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,23 @@ | ||
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose"; | ||
import { ApiProperty } from "@nestjs/swagger"; | ||
import { Expose } from "class-transformer"; | ||
import { votesGameOptionsApiProperties, votesGameOptionsFieldsSpecs } from "../../constants/game-options/votes-game-options.constant"; | ||
|
||
@Schema({ | ||
versionKey: false, | ||
id: false, | ||
_id: false, | ||
}) | ||
class VotesGameOptions { | ||
@ApiProperty(votesGameOptionsApiProperties.canBeSkipped) | ||
@Prop({ default: votesGameOptionsFieldsSpecs.canBeSkipped.default }) | ||
@Expose() | ||
public canBeSkipped: boolean; | ||
} | ||
|
||
const VotesGameOptionsSchema = SchemaFactory.createForClass(VotesGameOptions); | ||
|
||
export { | ||
VotesGameOptions, | ||
VotesGameOptionsSchema, | ||
}; |
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
Empty file.
This file was deleted.
Oops, something went wrong.
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
16 changes: 16 additions & 0 deletions
16
...me-options/create-composition-game-options/create-composition-game-options.dto.factory.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,16 @@ | ||
import { faker } from "@faker-js/faker"; | ||
import { plainToInstance } from "class-transformer"; | ||
import { CreateCompositionGameOptionsDto } from "../../../../../../../src/modules/game/dto/create-game/create-game-options/create-composition-game-options/create-composition-game-options.dto"; | ||
import { plainToInstanceDefaultOptions } from "../../../../../../../src/shared/validation/constants/validation.constant"; | ||
|
||
function createFakeCompositionGameOptionsDto( | ||
createCompositionGameOptionsDto: Partial<CreateCompositionGameOptionsDto> = {}, | ||
override: object = {}, | ||
): CreateCompositionGameOptionsDto { | ||
return plainToInstance(CreateCompositionGameOptionsDto, { | ||
isHidden: createCompositionGameOptionsDto.isHidden ?? faker.datatype.boolean(), | ||
...override, | ||
}, plainToInstanceDefaultOptions); | ||
} | ||
|
||
export { createFakeCompositionGameOptionsDto }; |
6 changes: 4 additions & 2 deletions
6
tests/factories/game/dto/create-game/create-game-options/create-game-options.dto.factory.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
13 changes: 13 additions & 0 deletions
13
...me/create-game-options/create-votes-game-options/create-votes-game-options.dto.factory.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,13 @@ | ||
import { faker } from "@faker-js/faker"; | ||
import { plainToInstance } from "class-transformer"; | ||
import { CreateVotesGameOptionsDto } from "../../../../../../../src/modules/game/dto/create-game/create-game-options/create-votes-game-options/create-votes-game-options.dto"; | ||
import { plainToInstanceDefaultOptions } from "../../../../../../../src/shared/validation/constants/validation.constant"; | ||
|
||
function createFakeVotesGameOptionsDto(createVotesGameOptionsDto: Partial<CreateVotesGameOptionsDto> = {}, override: object = {}): CreateVotesGameOptionsDto { | ||
return plainToInstance(CreateVotesGameOptionsDto, { | ||
canBeSkipped: createVotesGameOptionsDto.canBeSkipped ?? faker.datatype.boolean(), | ||
...override, | ||
}, plainToInstanceDefaultOptions); | ||
} | ||
|
||
export { createFakeVotesGameOptionsDto }; |
13 changes: 13 additions & 0 deletions
13
tests/factories/game/schemas/game-options/composition-game-options.schema.factory.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,13 @@ | ||
import { faker } from "@faker-js/faker"; | ||
import { plainToInstance } from "class-transformer"; | ||
import { CompositionGameOptions } from "../../../../../src/modules/game/schemas/game-options/composition-game-options.schema"; | ||
import { plainToInstanceDefaultOptions } from "../../../../../src/shared/validation/constants/validation.constant"; | ||
|
||
function createFakeCompositionGameOptions(compositionGameOptions: Partial<CompositionGameOptions> = {}, override: object = {}): CompositionGameOptions { | ||
return plainToInstance(CompositionGameOptions, { | ||
isHidden: compositionGameOptions.isHidden ?? faker.datatype.boolean(), | ||
...override, | ||
}, plainToInstanceDefaultOptions); | ||
} | ||
|
||
export { createFakeCompositionGameOptions }; |
6 changes: 4 additions & 2 deletions
6
tests/factories/game/schemas/game-options/game-options.schema.factory.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
13 changes: 13 additions & 0 deletions
13
tests/factories/game/schemas/game-options/votes-game-options.schema.factory.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,13 @@ | ||
import { faker } from "@faker-js/faker"; | ||
import { plainToInstance } from "class-transformer"; | ||
import { VotesGameOptions } from "../../../../../src/modules/game/schemas/game-options/votes-game-options.schema"; | ||
import { plainToInstanceDefaultOptions } from "../../../../../src/shared/validation/constants/validation.constant"; | ||
|
||
function createFakeVotesGameOptions(createVotesGameOptions: Partial<VotesGameOptions> = {}, override: object = {}): VotesGameOptions { | ||
return plainToInstance(VotesGameOptions, { | ||
canBeSkipped: createVotesGameOptions.canBeSkipped ?? faker.datatype.boolean(), | ||
...override, | ||
}, plainToInstanceDefaultOptions); | ||
} | ||
|
||
export { createFakeVotesGameOptions }; |
Oops, something went wrong.