Skip to content

Commit

Permalink
refactor(scandalmonger): rename raven to scandalmonger according to o…
Browse files Browse the repository at this point in the history
…fficial rulebook (#694)

Closes #682
  • Loading branch information
antoinezanardi committed Nov 29, 2023
1 parent 244e260 commit 2db7f6f
Show file tree
Hide file tree
Showing 50 changed files with 30,605 additions and 30,707 deletions.
4 changes: 2 additions & 2 deletions .run/Raven Role.run.xml → .run/Scandalmonger Role.run.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Raven Role" type="js.build_tools.npm" folderName="Cucumber Tags">
<configuration default="false" name="Scandalmonger 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;@raven-role&quot;" />
<arguments value="-- --tags &quot;@scandalmonger-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 @@ -58,7 +58,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/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** |
| <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/scandalmonger/scandalmonger-small.jpeg?raw=true" width="40"/><br/>**Scandalmonger** |


## <a name="installation">🔨 Installation</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const DEFAULT_GAME_OPTIONS: ReadonlyDeep<GameOptions> = {
charmedPeopleCountPerNight: 2,
isPowerlessIfInfected: true,
},
raven: { markPenalty: 2 },
scandalmonger: { markPenalty: 2 },
witch: { doesKnowWerewolvesTargets: true },
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/modules/game/constants/game-play/game-play.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const GAME_PLAY_SOURCE_NAMES = [
RoleNames.DEFENDER,
RoleNames.HUNTER,
RoleNames.PIED_PIPER,
RoleNames.RAVEN,
RoleNames.SCANDALMONGER,
RoleNames.SCAPEGOAT,
RoleNames.SEER,
RoleNames.STUTTERING_JUDGE,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/game/constants/game.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const GAME_PLAYS_PRIORITY_LIST: ReadonlyDeep<GamePlay[]> = [
occurrence: GamePlayOccurrences.FIRST_NIGHT_ONLY,
},
{
source: { name: RoleNames.RAVEN },
source: { name: RoleNames.SCANDALMONGER },
action: GamePlayActions.MARK,
occurrence: GamePlayOccurrences.ON_NIGHTS,
},
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { CreateDefenderGameOptionsDto } from "@/modules/game/dto/create-game/cre
import { CreateIdiotGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-idiot-game-options.dto";
import { CreateLittleGirlGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-little-girl-game-options.dto";
import { CreatePiedPiperGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-pied-piper-game-options.dto";
import { CreateRavenGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-raven-game-options.dto";
import { CreateScandalmongerGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-scandalmonger-game-options.dto";
import { CreateSeerGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-seer-game-options.dto";
import { CreateSheriffGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-sheriff-game-options/create-sheriff-game-options.dto";
import { CreateStutteringJudgeGameOptionsDto } from "@/modules/game/dto/create-game/create-game-options/create-roles-game-options/create-stuttering-judge-game-options.dto";
Expand Down Expand Up @@ -195,13 +195,13 @@ class CreateRolesGameOptionsDto {
public piedPiper: CreatePiedPiperGameOptionsDto = new CreatePiedPiperGameOptionsDto();

@ApiProperty({
...ROLES_GAME_OPTIONS_API_PROPERTIES.raven,
...ROLES_GAME_OPTIONS_API_PROPERTIES.scandalmonger,
required: false,
} as ApiPropertyOptions)
@IsOptional()
@Type(() => CreateRavenGameOptionsDto)
@Type(() => CreateScandalmongerGameOptionsDto)
@ValidateNested()
public raven: CreateRavenGameOptionsDto = new CreateRavenGameOptionsDto();
public scandalmonger: CreateScandalmongerGameOptionsDto = new CreateScandalmongerGameOptionsDto();

@ApiProperty({
...ROLES_GAME_OPTIONS_API_PROPERTIES.witch,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { ApiPropertyOptions } from "@nestjs/swagger";
import { ApiProperty } from "@nestjs/swagger";
import { IsInt, IsOptional, Max, Min } from "class-validator";

import { SCANDALMONGER_GAME_OPTIONS_API_PROPERTIES, SCANDALMONGER_GAME_OPTIONS_FIELDS_SPECS } from "@/modules/game/schemas/game-options/roles-game-options/scandalmonger-game-options/scandalmonger-game-options.schema.constant";

class CreateScandalmongerGameOptionsDto {
@ApiProperty({
...SCANDALMONGER_GAME_OPTIONS_API_PROPERTIES.markPenalty,
required: false,
} as ApiPropertyOptions)
@IsOptional()
@IsInt()
@Min(SCANDALMONGER_GAME_OPTIONS_FIELDS_SPECS.markPenalty.min)
@Max(SCANDALMONGER_GAME_OPTIONS_FIELDS_SPECS.markPenalty.max)
public markPenalty: number = SCANDALMONGER_GAME_OPTIONS_FIELDS_SPECS.markPenalty.default;
}

export { CreateScandalmongerGameOptionsDto };
2 changes: 1 addition & 1 deletion src/modules/game/enums/player.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum PlayerAttributeNames {
DRANK_LIFE_POTION = "drank-life-potion",
DRANK_DEATH_POTION = "drank-death-potion",
PROTECTED = "protected",
RAVEN_MARKED = "raven-marked",
SCANDALMONGER_MARKED = "scandalmonger-marked",
IN_LOVE = "in-love",
WORSHIPED = "worshiped",
POWERLESS = "powerless",
Expand Down
6 changes: 3 additions & 3 deletions src/modules/game/helpers/game-play/game-play.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ function createGamePlayTwoSistersMeetEachOther(gamePlay: Partial<GamePlay> = {})
});
}

function createGamePlayRavenMarks(gamePlay: Partial<GamePlay> = {}): GamePlay {
function createGamePlayScandalmongerMarks(gamePlay: Partial<GamePlay> = {}): GamePlay {
return createGamePlay({
source: createGamePlaySource({ name: RoleNames.RAVEN }),
source: createGamePlaySource({ name: RoleNames.SCANDALMONGER }),
action: GamePlayActions.MARK,
occurrence: GamePlayOccurrences.ON_NIGHTS,
...gamePlay,
Expand Down Expand Up @@ -263,7 +263,7 @@ export {
createGamePlayLoversMeetEachOther,
createGamePlayThreeBrothersMeetEachOther,
createGamePlayTwoSistersMeetEachOther,
createGamePlayRavenMarks,
createGamePlayScandalmongerMarks,
createGamePlayDefenderProtects,
createGamePlayHunterShoots,
createGamePlayWitchUsesPotions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ function createInLoveByCupidPlayerAttribute(playerAttribute: Partial<PlayerAttri
});
}

function createRavenMarkByRavenPlayerAttribute(playerAttribute: Partial<PlayerAttribute> = {}): PlayerAttribute {
function createScandalmongerMarkByScandalmongerPlayerAttribute(playerAttribute: Partial<PlayerAttribute> = {}): PlayerAttribute {
return createPlayerAttribute({
name: PlayerAttributeNames.RAVEN_MARKED,
source: RoleNames.RAVEN,
name: PlayerAttributeNames.SCANDALMONGER_MARKED,
source: RoleNames.SCANDALMONGER,
remainingPhases: 2,
...playerAttribute,
});
Expand Down Expand Up @@ -194,7 +194,7 @@ export {
createPowerlessByElderPlayerAttribute,
createWorshipedByWildChildPlayerAttribute,
createInLoveByCupidPlayerAttribute,
createRavenMarkByRavenPlayerAttribute,
createScandalmongerMarkByScandalmongerPlayerAttribute,
createProtectedByDefenderPlayerAttribute,
createDrankDeathPotionByWitchPlayerAttribute,
createDrankLifePotionByWitchPlayerAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class GamePlayAugmenterService {
[RoleNames.DEFENDER]: async game => this.getDefenderGamePlayEligibleTargets(game),
[RoleNames.HUNTER]: game => this.getHunterGamePlayEligibleTargets(game),
[RoleNames.PIED_PIPER]: game => this.getPiedPiperGamePlayEligibleTargets(game),
[RoleNames.RAVEN]: game => this.getRavenGamePlayEligibleTargets(game),
[RoleNames.SCANDALMONGER]: game => this.getScandalmongerGamePlayEligibleTargets(game),
[RoleNames.SCAPEGOAT]: game => this.getScapegoatGamePlayEligibleTargets(game),
[RoleNames.SEER]: game => this.getSeerGamePlayEligibleTargets(game),
[RoleNames.WHITE_WEREWOLF]: game => this.getWhiteWerewolfGamePlayEligibleTargets(game),
Expand All @@ -52,7 +52,7 @@ export class GamePlayAugmenterService {
[PlayerGroups.SURVIVORS]: (game, gamePlay) => this.canSurvivorsSkipGamePlay(game, gamePlay),
[RoleNames.BIG_BAD_WOLF]: game => this.canBigBadWolfSkipGamePlay(game),
[RoleNames.FOX]: () => true,
[RoleNames.RAVEN]: () => true,
[RoleNames.SCANDALMONGER]: () => true,
[RoleNames.SCAPEGOAT]: () => true,
[RoleNames.THIEF]: game => this.canThiefSkipGamePlay(game),
[RoleNames.TWO_SISTERS]: () => true,
Expand Down Expand Up @@ -221,9 +221,9 @@ export class GamePlayAugmenterService {
return createGamePlayEligibleTargets({ interactablePlayers, boundaries });
}

private getRavenGamePlayEligibleTargets(game: Game): GamePlayEligibleTargets {
private getScandalmongerGamePlayEligibleTargets(game: Game): GamePlayEligibleTargets {
const alivePlayers = getAlivePlayers(game);
const interactions: PlayerInteraction[] = [{ type: PlayerInteractionTypes.MARK, source: RoleNames.RAVEN }];
const interactions: PlayerInteraction[] = [{ type: PlayerInteractionTypes.MARK, source: RoleNames.SCANDALMONGER }];
const interactablePlayers: InteractablePlayer[] = alivePlayers.map(player => ({ player, interactions }));
const boundaries: GamePlayEligibleTargetsBoundaries = { min: 0, max: 1 };
return createGamePlayEligibleTargets({ interactablePlayers, boundaries });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createGamePlaySurvivorsVote, createGamePlaySheriffSettlesVotes, createG
import { createGame } from "@/modules/game/helpers/game.factory";
import { getFoxSniffedPlayers, getPlayerWithActiveAttributeName, getPlayerWithCurrentRole } from "@/modules/game/helpers/game.helper";
import { addPlayerAttributeInGame, addPlayersAttributeInGame, appendUpcomingPlayInGame, prependUpcomingPlayInGame, removePlayerAttributeByNameInGame, updatePlayerInGame } from "@/modules/game/helpers/game.mutator";
import { createCantVoteByScapegoatPlayerAttribute, createCharmedByPiedPiperPlayerAttribute, createDrankDeathPotionByWitchPlayerAttribute, createDrankLifePotionByWitchPlayerAttribute, createEatenByBigBadWolfPlayerAttribute, createEatenByWerewolvesPlayerAttribute, createEatenByWhiteWerewolfPlayerAttribute, createInLoveByCupidPlayerAttribute, createPowerlessByFoxPlayerAttribute, createProtectedByDefenderPlayerAttribute, createRavenMarkByRavenPlayerAttribute, createSeenBySeerPlayerAttribute, createSheriffBySurvivorsPlayerAttribute, createSheriffBySheriffPlayerAttribute, createWorshipedByWildChildPlayerAttribute } from "@/modules/game/helpers/player/player-attribute/player-attribute.factory";
import { createCantVoteByScapegoatPlayerAttribute, createCharmedByPiedPiperPlayerAttribute, createDrankDeathPotionByWitchPlayerAttribute, createDrankLifePotionByWitchPlayerAttribute, createEatenByBigBadWolfPlayerAttribute, createEatenByWerewolvesPlayerAttribute, createEatenByWhiteWerewolfPlayerAttribute, createInLoveByCupidPlayerAttribute, createPowerlessByFoxPlayerAttribute, createProtectedByDefenderPlayerAttribute, createScandalmongerMarkByScandalmongerPlayerAttribute, createSeenBySeerPlayerAttribute, createSheriffBySurvivorsPlayerAttribute, createSheriffBySheriffPlayerAttribute, createWorshipedByWildChildPlayerAttribute } from "@/modules/game/helpers/player/player-attribute/player-attribute.factory";
import { createPlayerShotByHunterDeath, createPlayerVoteBySurvivorsDeath, createPlayerVoteBySheriffDeath, createPlayerVoteScapegoatedBySurvivorsDeath } from "@/modules/game/helpers/player/player-death/player-death.factory";
import { isPlayerAliveAndPowerful } from "@/modules/game/helpers/player/player.helper";
import { GamePlayVoteService } from "@/modules/game/providers/services/game-play/game-play-vote/game-play-vote.service";
Expand Down Expand Up @@ -43,7 +43,7 @@ export class GamePlayMakerService {
[RoleNames.DOG_WOLF]: (play, game) => this.dogWolfChoosesSide(play, game),
[RoleNames.SCAPEGOAT]: (play, game) => this.scapegoatBansVoting(play, game),
[RoleNames.THIEF]: (play, game) => this.thiefChoosesCard(play, game),
[RoleNames.RAVEN]: (play, game) => this.ravenMarks(play, game),
[RoleNames.SCANDALMONGER]: (play, game) => this.scandalmongerMarks(play, game),
};

public constructor(
Expand Down Expand Up @@ -241,15 +241,15 @@ export class GamePlayMakerService {
return clonedGame;
}

private ravenMarks({ targets }: MakeGamePlayWithRelationsDto, game: GameWithCurrentPlay): Game {
private scandalmongerMarks({ targets }: MakeGamePlayWithRelationsDto, game: GameWithCurrentPlay): Game {
const clonedGame = createGame(game);
const expectedTargetCount = 1;
if (targets?.length !== expectedTargetCount) {
return clonedGame;
}
const { player: targetedPlayer } = targets[0];
const ravenMarkByRavenPlayerAttribute = createRavenMarkByRavenPlayerAttribute();
return addPlayerAttributeInGame(targetedPlayer._id, clonedGame, ravenMarkByRavenPlayerAttribute);
const scandalmongerMarkByScandalmongerPlayerAttribute = createScandalmongerMarkByScandalmongerPlayerAttribute();
return addPlayerAttributeInGame(targetedPlayer._id, clonedGame, scandalmongerMarkByScandalmongerPlayerAttribute);
}

private defenderProtects({ targets }: MakeGamePlayWithRelationsDto, game: GameWithCurrentPlay): Game {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ export class GamePlayValidatorService {
}
}

private validateGamePlayRavenTargets(playTargets: MakeGamePlayTargetWithRelationsDto[], game: GameWithCurrentPlay): void {
private validateGamePlayScandalmongerTargets(playTargets: MakeGamePlayTargetWithRelationsDto[], game: GameWithCurrentPlay): void {
if (!playTargets.length) {
return;
}
const targetedPlayer = playTargets[0].player;
const canTargetedPlayerBeMarked = isPlayerInteractableWithInteractionType(targetedPlayer._id, PlayerInteractionTypes.MARK, game);
if (!canTargetedPlayerBeMarked) {
throw new BadGamePlayPayloadException(BadGamePlayPayloadReasons.BAD_RAVEN_TARGET);
throw new BadGamePlayPayloadException(BadGamePlayPayloadReasons.BAD_SCANDALMONGER_TARGET);
}
}

Expand Down Expand Up @@ -220,7 +220,7 @@ export class GamePlayValidatorService {
[RoleNames.DEFENDER]: () => this.validateGamePlayDefenderTargets(playTargets, game),
[RoleNames.PIED_PIPER]: () => this.validateGamePlayPiedPiperTargets(playTargets, game),
[RoleNames.WILD_CHILD]: () => this.validateGamePlayWildChildTargets(playTargets, game),
[RoleNames.RAVEN]: () => this.validateGamePlayRavenTargets(playTargets, game),
[RoleNames.SCANDALMONGER]: () => this.validateGamePlayScandalmongerTargets(playTargets, game),
[RoleNames.SEER]: () => this.validateGamePlaySeerTargets(playTargets, game),
[RoleNames.FOX]: () => this.validateGamePlayFoxTargets(playTargets, game),
[RoleNames.CUPID]: () => this.validateGamePlayCupidTargets(playTargets, game),
Expand Down

0 comments on commit 2db7f6f

Please sign in to comment.