Skip to content

Commit

Permalink
refactor(elder): rename ancient to elder according to official rulebo…
Browse files Browse the repository at this point in the history
…ok (#692)

Closes #679
  • Loading branch information
antoinezanardi committed Nov 29, 2023
1 parent 4fb6c8b commit 9ee3d99
Show file tree
Hide file tree
Showing 53 changed files with 19,777 additions and 20,306 deletions.
4 changes: 2 additions & 2 deletions .run/Ancient Role.run.xml → .run/Elder Role.run.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Ancient Role" type="js.build_tools.npm" folderName="Cucumber Tags">
<configuration default="false" name="Elder Role" type="js.build_tools.npm" folderName="Cucumber Tags">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="test:cucumber" />
</scripts>
<arguments value="-- --tags &quot;@ancient-role&quot;" />
<arguments value="-- --tags &quot;@elder-role&quot;" />
<node-interpreter value="project" />
<envs />
<method v="2" />
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ This is the **next** version of the current **[Werewolves Assistant API](https:/
|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/villager/villager-small.jpeg?raw=true" width="40"/><br/>**Villager** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/villager/villager-small.jpeg?raw=true" width="40"/><br/> **Villager-Villager** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/seer/seer-small.jpeg?raw=true" width="40"/><br/>**Seer** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/cupid/cupid-small.jpeg?raw=true" width="40"/><br/>**Cupid** |
| <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/witch/witch-small.jpeg?raw=true" width="40"/><br/>**Witch** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/hunter/hunter-small.jpeg?raw=true" width="40"/><br/>**Hunter** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/little-girl/little-girl-small.jpeg?raw=true" width="40"/><br/>**Little Girl** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/guard/guard-small.jpeg?raw=true" width="40"/><br/>**Guard** |
| <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/ancient/ancient-small.jpeg?raw=true" width="40"/><br/>**Ancient** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/scapegoat/scapegoat-small.jpeg?raw=true" width="40"/><br/>**Scapegoat** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/idiot/idiot-small.jpeg?raw=true" width="40"/><br/>**Idiot** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/two-sisters/two-sisters-small.jpeg?raw=true" width="40"/><br/>**Two Sisters** |
| <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/elder/elder-small.jpeg?raw=true" width="40"/><br/>**Elder** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/scapegoat/scapegoat-small.jpeg?raw=true" width="40"/><br/>**Scapegoat** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/idiot/idiot-small.jpeg?raw=true" width="40"/><br/>**Idiot** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/two-sisters/two-sisters-small.jpeg?raw=true" width="40"/><br/>**Two Sisters** |
| <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/three-brothers/three-brothers-small.jpeg?raw=true" width="40"/><br/>**Three Brothers** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/fox/fox-small.jpeg?raw=true" width="40"/><br/>**Fox** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/bear-tamer/bear-tamer-small.jpeg?raw=true" width="40"/><br/>**Bear Tamer** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/stuttering-judge/stuttering-judge-small.jpeg?raw=true" width="40"/><br/>**Stuttering Judge** |
| <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/rusty-sword-knight/rusty-sword-knight-small.jpeg?raw=true" width="40"/><br/>**Rusty Sword Knight** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/wild-child/wild-child-small.jpeg?raw=true" width="40"/><br/>**Wild Child** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/dog-wolf/dog-wolf-small.jpeg?raw=true" width="40"/><br/>**Dog-Wolf** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/thief/thief-small.jpeg?raw=true" width="40"/><br/>**Thief** |
| <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/angel/angel-small.jpeg?raw=true" width="40"/><br/>**Angel** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/pied-piper/pied-piper-small.jpeg?raw=true" width="40"/><br/>**Pied Piper** | <img src="https://github.com/antoinezanardi/werewolves-assistant-api-next/blob/main/public/assets/images/roles/raven/raven-small.jpeg?raw=true" width="40"/><br/>**Raven** |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ const DEFAULT_GAME_OPTIONS: ReadonlyDeep<GameOptions> = {
},
littleGirl: { isProtectedByGuard: false },
guard: { canProtectTwice: false },
ancient: {
elder: {
livesCountAgainstWerewolves: 2,
doesTakeHisRevenge: true,
},
idiot: { doesDieOnAncientDeath: true },
idiot: { doesDieOnElderDeath: true },
twoSisters: { wakingUpInterval: 2 },
threeBrothers: { wakingUpInterval: 2 },
fox: { isPowerlessIfMissesWerewolf: true },
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { ApiPropertyOptions } from "@nestjs/swagger";
import { ApiProperty } from "@nestjs/swagger";
import { IsBoolean, IsInt, IsOptional, Max, Min } from "class-validator";

import { ELDER_GAME_OPTIONS_API_PROPERTIES, ELDER_GAME_OPTIONS_FIELDS_SPECS } from "@/modules/game/schemas/game-options/roles-game-options/elder-game-options/elder-game-options.schema.constant";

class CreateElderGameOptionsDto {
@ApiProperty({
...ELDER_GAME_OPTIONS_API_PROPERTIES.livesCountAgainstWerewolves,
required: false,
} as ApiPropertyOptions)
@IsOptional()
@IsInt()
@Min(ELDER_GAME_OPTIONS_FIELDS_SPECS.livesCountAgainstWerewolves.min)
@Max(ELDER_GAME_OPTIONS_FIELDS_SPECS.livesCountAgainstWerewolves.max)
public livesCountAgainstWerewolves: number = ELDER_GAME_OPTIONS_FIELDS_SPECS.livesCountAgainstWerewolves.default;

@ApiProperty({
...ELDER_GAME_OPTIONS_API_PROPERTIES.doesTakeHisRevenge,
required: false,
} as ApiPropertyOptions)
@IsOptional()
@IsBoolean()
public doesTakeHisRevenge: boolean = ELDER_GAME_OPTIONS_FIELDS_SPECS.doesTakeHisRevenge.default;
}

export { CreateElderGameOptionsDto };
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { IDIOT_GAME_OPTIONS_API_PROPERTIES, IDIOT_GAME_OPTIONS_FIELDS_SPECS } fr

class CreateIdiotGameOptionsDto {
@ApiProperty({
...IDIOT_GAME_OPTIONS_API_PROPERTIES.doesDieOnAncientDeath,
...IDIOT_GAME_OPTIONS_API_PROPERTIES.doesDieOnElderDeath,
required: false,
} as ApiPropertyOptions)
@IsOptional()
@IsBoolean()
public doesDieOnAncientDeath: boolean = IDIOT_GAME_OPTIONS_FIELDS_SPECS.doesDieOnAncientDeath.default;
public doesDieOnElderDeath: boolean = IDIOT_GAME_OPTIONS_FIELDS_SPECS.doesDieOnElderDeath.default;
}

export { CreateIdiotGameOptionsDto };
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IsBoolean, IsOptional, ValidateNested } from "class-validator";

import { CreateWitchGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-witch-game-options.dto";
import { ROLES_GAME_OPTIONS_API_PROPERTIES, ROLES_GAME_OPTIONS_FIELDS_SPECS } from "@/modules/game/schemas/game-options/roles-game-options/roles-game-options.schema.constant";
import { CreateAncientGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-ancient-game-options.dto";
import { CreateElderGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-elder-game-options.dto";
import { CreateBearTamerGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-bear-tamer-game-options.dto";
import { CreateBigBadWolfGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-big-bad-wolf-game-options.dto";
import { CreateDogWolfGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-dog-wolf-game-options.dto";
Expand Down Expand Up @@ -96,13 +96,13 @@ class CreateRolesGameOptionsDto {
public guard: CreateGuardGameOptionsDto = new CreateGuardGameOptionsDto();

@ApiProperty({
...ROLES_GAME_OPTIONS_API_PROPERTIES.ancient,
...ROLES_GAME_OPTIONS_API_PROPERTIES.elder,
required: false,
} as ApiPropertyOptions)
@IsOptional()
@Type(() => CreateAncientGameOptionsDto)
@Type(() => CreateElderGameOptionsDto)
@ValidateNested()
public ancient: CreateAncientGameOptionsDto = new CreateAncientGameOptionsDto();
public elder: CreateElderGameOptionsDto = new CreateElderGameOptionsDto();

@ApiProperty({
...ROLES_GAME_OPTIONS_API_PROPERTIES.idiot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ function createPowerlessByFoxPlayerAttribute(playerAttribute: Partial<PlayerAttr
});
}

function createPowerlessByAncientPlayerAttribute(playerAttribute: Partial<PlayerAttribute> = {}): PlayerAttribute {
function createPowerlessByElderPlayerAttribute(playerAttribute: Partial<PlayerAttribute> = {}): PlayerAttribute {
return createPlayerAttribute({
name: PlayerAttributeNames.POWERLESS,
source: RoleNames.ANCIENT,
source: RoleNames.ELDER,
doesRemainAfterDeath: true,
...playerAttribute,
});
Expand Down Expand Up @@ -191,7 +191,7 @@ export {
createCantVoteBySurvivorsPlayerAttribute,
createCantVoteByScapegoatPlayerAttribute,
createPowerlessByFoxPlayerAttribute,
createPowerlessByAncientPlayerAttribute,
createPowerlessByElderPlayerAttribute,
createWorshipedByWildChildPlayerAttribute,
createInLoveByCupidPlayerAttribute,
createRavenMarkByRavenPlayerAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,30 @@ export class GameHistoryRecordRepository {
return this.gameHistoryRecordModel.find(filter);
}

public async getGameHistoryWerewolvesEatAncientRecords(gameId: Types.ObjectId): Promise<GameHistoryRecord[]> {
public async getGameHistoryWerewolvesEatElderRecords(gameId: Types.ObjectId): Promise<GameHistoryRecord[]> {
const filter: FilterQuery<GameHistoryRecord> = {
gameId,
"play.action": GamePlayActions.EAT,
"play.targets.player.role.current": RoleNames.ANCIENT,
"play.targets.player.role.current": RoleNames.ELDER,
};
return this.gameHistoryRecordModel.find(filter);
}

public async getGameHistoryAncientProtectedFromWerewolvesRecords(gameId: Types.ObjectId): Promise<GameHistoryRecord[]> {
public async getGameHistoryElderProtectedFromWerewolvesRecords(gameId: Types.ObjectId): Promise<GameHistoryRecord[]> {
const filter: FilterQuery<GameHistoryRecord> = {
gameId,
$or: [
{
"play.source.name": RoleNames.GUARD,
"play.action": GamePlayActions.PROTECT,
"play.targets.player.role.current": RoleNames.ANCIENT,
"play.targets.player.role.current": RoleNames.ELDER,
},
{
"play.source.name": RoleNames.WITCH,
"play.action": GamePlayActions.USE_POTIONS,
"play.targets": {
$elemMatch: {
"player.role.current": RoleNames.ANCIENT,
"player.role.current": RoleNames.ELDER,
"drankPotion": WitchPotions.LIFE,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ export class GameHistoryRecordService {
return records.length > 0;
}

public async getGameHistoryWerewolvesEatAncientRecords(gameId: Types.ObjectId): Promise<GameHistoryRecord[]> {
return this.gameHistoryRecordRepository.getGameHistoryWerewolvesEatAncientRecords(gameId);
public async getGameHistoryWerewolvesEatElderRecords(gameId: Types.ObjectId): Promise<GameHistoryRecord[]> {
return this.gameHistoryRecordRepository.getGameHistoryWerewolvesEatElderRecords(gameId);
}

public async getGameHistoryAncientProtectedFromWerewolvesRecords(gameId: Types.ObjectId): Promise<GameHistoryRecord[]> {
return this.gameHistoryRecordRepository.getGameHistoryAncientProtectedFromWerewolvesRecords(gameId);
public async getGameHistoryElderProtectedFromWerewolvesRecords(gameId: Types.ObjectId): Promise<GameHistoryRecord[]> {
return this.gameHistoryRecordRepository.getGameHistoryElderProtectedFromWerewolvesRecords(gameId);
}

public async getGameHistoryPhaseRecords(gameId: Types.ObjectId, turn: number, phase: GamePhases): Promise<GameHistoryRecord[]> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ export class GamePlayMakerService {
}
const { player: targetedPlayer, isInfected: isTargetInfected } = targets[0];
const eatenByWerewolvesPlayerAttribute = createEatenByWerewolvesPlayerAttribute();
const ancientLivesCount = await this.playerKillerService.getAncientLivesCountAgainstWerewolves(clonedGame, targetedPlayer);
if (isTargetInfected === true && (targetedPlayer.role.current !== RoleNames.ANCIENT || ancientLivesCount <= 1)) {
const elderLivesCount = await this.playerKillerService.getElderLivesCountAgainstWerewolves(clonedGame, targetedPlayer);
if (isTargetInfected === true && (targetedPlayer.role.current !== RoleNames.ELDER || elderLivesCount <= 1)) {
const playerDataToUpdate: Partial<Player> = { side: { ...targetedPlayer.side, current: RoleSides.WEREWOLVES } };
return updatePlayerInGame(targetedPlayer._id, playerDataToUpdate, clonedGame);
}
Expand Down

0 comments on commit 9ee3d99

Please sign in to comment.