Skip to content

Commit

Permalink
feat(Game): Little girl role implemented. Closes #58
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinezanardi committed Nov 14, 2020
1 parent 2e7fefc commit c2e548a
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 43 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 0.7.0 (2020-11-??)

### 🚀 New features

* [#58](https://github.com/antoinezanardi/werewolves-assistant-web/issues/58) - Little girl role implemented.

### 📚 Documentation

* [#57](https://github.com/antoinezanardi/werewolves-assistant-web/issues/57) - Fix doc for `game.won`.
Expand Down
22 changes: 12 additions & 10 deletions config/apidoc/footer.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@

## <a id="player-roles"></a>🃏 Player Roles

| Role | Card | [Group](#player-groups) | Description |
|:------------------:|:------------------------------------------------------------------------------------------------------------:|:-----------------------:|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 🐺<br/>werewolf | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/werewolf.png" width="50"/> | werewolves | Each night, his group eats a villager chosen by the majority. |
| 🧑‍🌾<br/>villager | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/villager.png" width="50"/> | villagers | Has no powers, can only count on his speech skills. |
| 🧙‍♀<br/>️‍witch | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/witch.png" width="50"/> | villagers | She has one life potion which prevents from being eaten by werewolves and a death potion which instantly kills. She can only use each one once in the game. |
| 🔮<br/>seer | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/seer.png" width="50"/> | villagers | Each night, she sees the role of the player she wants. |
| 🛡️<br/>guard | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/guard.png" width="50"/> | villagers | Each night, he protects the player he wants (including himself). He can't protect the same player twice in a row. |
| 🔫<br/>hunter | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/hunter.png" width="50"/> | villagers | If he dies, he shoots a victim to take his revenge. He can't kill himself. |
| 🐦<br/>raven | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/raven.png" width="50"/> | villagers | Each night, he can mark someone (including himself). The next phase (during the day), the marked player will have two votes against himself. |
| Role | Card | [Group](#player-groups) | Description |
|:-----------------------------:|:------------------------------------------------------------------------------------------------------------:|:-----------------------:|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 🐺<br/>werewolf | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/werewolf.png" width="50"/> | werewolves | Each night, his group eats a villager chosen by the majority. |
| 🧑‍🌾<br/>villager | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/villager.png" width="50"/> | villagers | Has no powers, can only count on his speech skills. |
| 🧑‍🌾<br/>villager-villager | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/villager.png" width="50"/> | villagers | Like the normal villager, has no power but on the two faces of his role card, there is the illustration of a simple villager. So, everybody knows that it's a simple villager.|
| 🧙‍♀<br/>️‍witch | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/witch.png" width="50"/> | villagers | She has one life potion which prevents from being eaten by werewolves and a death potion which instantly kills. She can only use each one once in the game. |
| 👧<br/>little-girl | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/little-girl.png" width="50"/> | villagers | She can slightly open her eyes during werewolves turn to spot some of them. Even if the guard protects her, she will die by the werewolves if she is chosen by them. |
| 🔮<br/>seer | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/seer.png" width="50"/> | villagers | Each night, she sees the role of the player she wants. |
| 🛡️<br/>guard | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/guard.png" width="50"/> | villagers | Each night, he protects the player he wants (including himself). He can't protect the same player twice in a row. |
| 🔫<br/>hunter | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/hunter.png" width="50"/> | villagers | If he dies, he shoots a victim to take his revenge. He can't kill himself. |
| 🐦<br/>raven | <img src="https://werewolves-assistant-api.antoinezanardi.fr/img/roles/raven.png" width="50"/> | villagers | Each night, he can mark someone (including himself). The next phase (during the day), the marked player will have two votes against himself. |

## <a id="player-actions"></a>🔪 Player Actions

Expand Down Expand Up @@ -89,7 +91,7 @@ Description for each case below:
| 25 | BAD_TARGET_STRUCTURE | 400 | One of play's target has a bad structure. (_See: [Classes - Play](#play-class)_ |
| 26 | NOT_TARGETABLE | 400 | Player can't be a target. |
| 27 | CANT_LOOK_AT_HERSELF | 400 | Seer can't look at herself. |
| 28 | CANT_EAT_EACH_OTHER | 400 | Werewolves's target can't be a player with group "werewolves". |
| 28 | CANT_EAT_EACH_OTHER | 400 | Werewolves target can't be a player with group "werewolves". |
| 29 | BAD_LIFE_POTION_USE | 400 | Witch can only use life potion on a target eaten by werewolves. |
| 30 | ONLY_ONE_LIFE_POTION | 400 | Witch can only use one life potion per game. |
| 31 | ONLY_ONE_DEATH_POTION | 400 | Witch can only use one death potion per game. |
Expand Down
8 changes: 4 additions & 4 deletions config/apidoc/header.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

| Field | Type | Description |
|----------------------|:--------:|---------------------------------------------------------------------|
| _id | ObjectId | User's ID. |
| email | String | User's email. |
| createdAt | Date | When the user created his account. |
| updatedAt | Date | When the user updated his account. |
| _id | ObjectId | User's ID. |
| email | String | User's email. |
| createdAt | Date | When the user created his account. |
| updatedAt | Date | When the user updated his account. |

## <a id="game-class"></a>🎲 Game

Expand Down
6 changes: 4 additions & 2 deletions src/helpers/constants/Role.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
exports.roleNames = ["villager", "werewolf", "seer", "guard", "witch", "hunter", "raven"];
exports.roleNames = ["villager", "werewolf", "seer", "guard", "witch", "hunter", "raven", "little-girl", "villager-villager"];

exports.groupNames = ["villagers", "werewolves"];

exports.roles = [
{ name: "villager", group: "villagers", maxInGame: 19 },
{ name: "villager", group: "villagers", maxInGame: 9 },
{ name: "villager-villager", group: "villagers", maxInGame: 1 },
{ name: "seer", group: "villagers", maxInGame: 1, powers: [{ name: "look" }] },
{ name: "guard", group: "villagers", maxInGame: 1, powers: [{ name: "protect" }] },
{ name: "witch", group: "villagers", maxInGame: 1, powers: [{ name: "use-potion" }] },
{ name: "hunter", group: "villagers", maxInGame: 1, powers: [{ name: "shoot" }] },
{ name: "raven", group: "villagers", maxInGame: 1, powers: [{ name: "mark" }] },
{ name: "little-girl", group: "villagers", maxInGame: 1 },
{ name: "werewolf", group: "werewolves", maxInGame: 4, powers: [{ name: "eat" }] },
];
3 changes: 2 additions & 1 deletion src/helpers/functions/Player.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { playerAttributes, murderedPossibilities, playerActions } = require("../constants/Player");

exports.canBeEaten = player => !this.hasAttribute(player, "protected") && !this.hasAttribute(player, "drank-life-potion");
exports.canBeEaten = player => !this.hasAttribute(player, "drank-life-potion") && (!this.hasAttribute(player, "protected") ||
player.role.current === "little-girl");

exports.hasAttribute = ({ attributes }, attributeName) => attributes && attributes.findIndex(({ attribute }) => attribute === attributeName) !== -1;

Expand Down
Loading

0 comments on commit c2e548a

Please sign in to comment.