Skip to content

Commit

Permalink
feat(Role): Fox role. Closes #157
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinezanardi committed Apr 22, 2021
1 parent 1dba3c5 commit ae8cf10
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* [#154](https://github.com/antoinezanardi/werewolves-assistant-web/issues/154) - Facebook auth.
* [#155](https://github.com/antoinezanardi/werewolves-assistant-web/issues/155) - Google auth.
* [#157](https://github.com/antoinezanardi/werewolves-assistant-web/issues/157) - Fox role.
* [#158](https://github.com/antoinezanardi/werewolves-assistant-web/issues/158) - Game players position panel in game options.
* [#183](https://github.com/antoinezanardi/werewolves-assistant-web/issues/183) - Audio options in parameters modal.
* [#188](https://github.com/antoinezanardi/werewolves-assistant-web/issues/188) - Modal for helping players with roles.
Expand Down
8 changes: 8 additions & 0 deletions src/classes/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ class Player {
canVote(game) {
return !this.hasActiveAttribute("cant-vote", game);
}

get isInWerewolvesSide() {
return this.side.current === "werewolves";
}

get isInVillagersSide() {
return this.side.current === "villagers";
}
}

export default Player;
4 changes: 2 additions & 2 deletions src/classes/Role.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class Role {
return !roleCount || this.minInGame <= roleCount;
}

get isInWerewolfSide() {
get isInWerewolvesSide() {
return this.side === "werewolves";
}

get isInVillagerSide() {
get isInVillagersSide() {
return this.side === "villagers";
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Game/GameEventMonitor/GameEvent/GameEvent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export default {
...insertIf(!this.hasGameEventTargets, i18n.t("GameEvent.messages.foxSkipsHisTurn")),
...insertIf(this.hasGameEventTargets, i18n.t("GameEvent.messages.foxSniffs")),
...insertIf(this.hasGameEventTargets && this.doTargetsIncludeWerewolf, i18n.t("GameEvent.messages.foxFoundWerewolf")),
...insertIf(this.hasGameEventTargets && !this.doTargetsIncludeWerewolf, i18n.t("GameEvent.messages.foxDidntFoundWerewolf")),
...insertIf(this.hasGameEventTargets && !this.doTargetsIncludeWerewolf, i18n.t("GameEvent.messages.foxDidntFindWerewolf")),
],
soundEffect: "fox-plays",
},
Expand All @@ -318,7 +318,7 @@ export default {
return !!this.event.targets.length;
},
doTargetsIncludeWerewolf() {
return this.event.targets.find(({ player }) => player.side.current === "werewolves");
return this.event.targets.find(({ player }) => player.isInWerewolvesSide);
},
gameEventMessages() {
return this.gameEventMetadata[this.event.type] ? this.gameEventMetadata[this.event.type].messages : [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default {
involvedRoles() {
const involvedRoles = {
"recommended-min-players": this.roles.filter(({ recommendedMinPlayers }) => recommendedMinPlayers),
"powerful-werewolves": this.roles.filter(({ isInWerewolfSide, name }) => isInWerewolfSide && name !== "werewolf"),
"powerful-villagers": this.roles.filter(({ isInVillagerSide, name }) => isInVillagerSide && name !== "villager"),
"powerful-werewolves": this.roles.filter(({ isInWerewolvesSide, name }) => isInWerewolvesSide && name !== "werewolf"),
"powerful-villagers": this.roles.filter(({ isInVillagersSide, name }) => isInVillagersSide && name !== "villager"),
};
return involvedRoles[this.rolesType] ? involvedRoles[this.rolesType] : this.roles;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import cantVoteSVG from "@/assets/svg/attributes/cant-vote.svg";
import thiefSVG from "@/assets/svg/roles/thief.svg";
import stutteringJudgeSVG from "@/assets/svg/roles/stuttering-judge.svg";
import whiteWerewolfSVG from "@/assets/svg/roles/white-werewolf.svg";
import foxSVG from "@/assets/svg/roles/fox.svg";
import RoleImage from "@/components/shared/Game/Role/RoleImage";
import RoleText from "@/components/shared/Game/Role/RoleText";
import { insertIf } from "@/helpers/functions/Array";
Expand Down Expand Up @@ -119,6 +120,7 @@ export default {
"thief": { "choose-card": thiefSVG },
"stuttering-judge": { "choose-sign": stutteringJudgeSVG },
"white-werewolf": { eat: whiteWerewolfSVG },
"fox": { sniff: foxSVG },
};
return actionImageSource[play.source.name] ? actionImageSource[play.source.name][play.action] : undefined;
},
Expand Down Expand Up @@ -176,6 +178,10 @@ export default {
this.$t(`${consequencesText}.ravenMarked`, { markPenalty: options.roles.raven.markPenalty })),
...insertIf(action === "choose-card" && areAllAdditionalCardsWerewolves(thiefAdditionalCards),
this.$t(`${consequencesText}.thiefMustChooseCard`)),
...insertIf(action === "sniff" && targets.length && targets.some(({ player }) => player.isInWerewolvesSide),
this.$t(`${consequencesText}.foxFoundWerewolf`)),
...insertIf(action === "sniff" && targets.length && targets.every(({ player }) => player.isInVillagersSide),
this.$t(`${consequencesText}.foxDidntFindWerewolfAndBecamePowerless`)),
];
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<i class="fa fa-trophy text-warning mr-2"/>
<span v-html="$t('GameSummaryModal.gameResults')"/>
</h4>
<hr class="bg-dark"/>
<hr class="bg-dark my-1"/>
<div class="row">
<div class="col-12 text-center">
<GameResult/>
Expand Down Expand Up @@ -88,7 +88,7 @@
<Loading :text="$t('GameSummaryModal.loadingGameHistory')"/>
</div>
<div v-else-if="gameHistory" id="game-summary-history" key="game-summary-history" class="h-100">
<h4 class="text-center mt-2 mb-3">
<h4 class="text-center my-2">
<i class="fa fa-clock mr-2"/>
<span v-html="$t('GameSummaryModal.gameHistory')"/>
</h4>
Expand Down
4 changes: 3 additions & 1 deletion src/components/shared/Game/PlayField/CancelActionButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export default {
return "";
},
noTargetSelectedText() {
if (this.game.isFirstWaitingSkippableAction) {
if (this.game.isFirstWaitingChooseSideAction) {
return this.$t("CancelActionButton.pleaseChooseSide");
} else if (this.game.isFirstWaitingSkippableAction) {
return this.$t("CancelActionButton.chooseTargetIfNot");
}
return this.$t("CancelActionButton.pleaseChooseTarget");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ export default {
},
"powerless": {
ancient: {
tooltip: this.$t("PlayerAttribute.attributes.powerless"),
tooltip: this.$t("PlayerAttribute.attributes.powerlessByAncient"),
SVG: powerlessSVG,
},
fox: {
tooltip: this.$t("PlayerAttribute.attributes.powerlessByFox"),
SVG: powerlessSVG,
},
},
Expand Down
13 changes: 10 additions & 3 deletions src/plugins/vue-i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,8 @@
"charmed": "Ce joueur a été charmé par le Joueur de Flûte",
"cantVoteByScapegoat": "Ce joueur est interdit de vote par le Bouc-Émissaire",
"cantVoteByAll": "Ce joueur est interdit de vote par le village",
"powerless": "Ce joueur n'a plus de pouvoir à cause de la vengeance de l'Ancien"
"powerlessByAncient": "Ce joueur n'a plus de pouvoir à cause de la vengeance de l'Ancien",
"powerlessByFox": "Le Renard a perdu son pouvoir car il a flairé un groupe composé entièrement de Villageois"
},
"remainingPhases": "Plus qu'une phase (jour ou nuit) pour que l'effet disparaisse | Il reste {remainingPhases} phases (jour ou nuit) avant que l'effet ne disparaisse",
"endlessAttribute": "Cet effet restera jusqu'à la fin de la partie ou la mort du joueur",
Expand Down Expand Up @@ -1151,6 +1152,9 @@
},
"white-werewolf": {
"eat": "a décidé de manger"
},
"fox": {
"sniff": "a flairé le groupe"
}
},
"consequences": {
Expand All @@ -1160,7 +1164,9 @@
"stutteringJudgeRequestedVote": "Le Juge Bègue a demandé un nouveau vote après l'annonce des résultats de celui-ci.",
"votesNoDeath": "Aucun joueur n'est mort de cette pendaison.",
"ravenMarked": "Le joueur aura {markPenalty} voix d'office contre lui au prochain vote. (Ceci peut être modifié dans les options de la partie)",
"votesNeedSettlement": "Dû à l'égalité des votes, les ex æquo doivent être départagés."
"votesNeedSettlement": "Dû à l'égalité des votes, les ex æquo doivent être départagés.",
"foxFoundWerewolf": "Le Renard a flairé un ou plusieurs Loups-Garous dans ce groupe de joueurs.",
"foxDidntFindWerewolfAndBecamePowerless": "Le Renard n'a trouvé aucun Loup-Garou dans ce groupe de joueurs et a donc perdu son pouvoir."
},
"skipTurn": "a passé son tour",
"remarksOnPlay": "Remarques sur cette action"
Expand Down Expand Up @@ -1279,7 +1285,8 @@
"cancelTarget": "Annuler cette cible",
"cancelSide": "Annuler le choix du camp",
"chooseTargetIfNot": "Choisissez une cible dans le cas contraire",
"pleaseChooseTarget": "Veuillez choisir une cible"
"pleaseChooseTarget": "Veuillez choisir une cible",
"pleaseChooseSide": "Veuillez choisir un camp"
},
"SelectAllTargetsButton": {
"selectAll": "Tout sélectionner",
Expand Down

0 comments on commit ae8cf10

Please sign in to comment.