Git Product home page Git Product logo

antoinezanardi / werewolves-assistant-api Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 3.0 9.97 MB

Werewolves Assistant API provides over HTTP requests a way of manage Werewolves games in order to help the game master in his task.

Home Page: https://werewolves-assistant-api.antoinezanardi.fr/apidoc/

License: MIT License

JavaScript 99.75% Shell 0.25%
werewolf-game game api api-rest rest werewolves-assistant-api forthebadge game-master consistency

werewolves-assistant-api's Introduction

๐Ÿบ Werewolves Assistant API

GitHub release GitHub license Build Status Known Vulnerabilities Contributions are welcome

ForTheBadge open-source ForTheBadge built-with-love ForTheBadge uses-js

๐Ÿ“‹ Table of Contents

  1. ๐Ÿบ What is this API ?
  2. ๐Ÿ” Let's try !
  3. ๐Ÿƒ Roles available
  4. ๐Ÿ“š API Documentation
  5. ๐Ÿ“ˆ Versions & changelog
  6. โ˜‘๏ธ Code analysis and consistency
  7. ๐Ÿ”จ Installation
  8. ๐Ÿ”Œ Let's go
  9. โš™๏ธ Other useful commands
  10. ยฉ๏ธ License
  11. โค๏ธ Contributors

Werewolves Assistant API provides over HTTP requests a way of manage Werewolves games in order to help the game master in his task.

This is the project's API used by Werewolves Assistant Web, the main web VueJS client.

๐Ÿค” Want to know more about this awesome project ? Check out the dedicated about page.

Two versions are available for testing this API:

โœจ Main API (Base URL: https://werewolves-assistant-api.antoinezanardi.fr)

๐Ÿ”ง Sandbox API (Base URL: https://sandbox.werewolves-assistant-api.antoinezanardi.fr)

Sandbox API may contain some bugs and unexpected behaviors as its purpose is to test new features before deploying on main API.

Both APIs are running on a server with the following configuration:

  • OS: Debian GNU/Linux 10 (buster)
  • NodeJS: v14.16.1
  • NPM: v6.14.12
  • MongoDB shell version: v4.4.5

The MongoDB database is protected under username and password authentication.

๐Ÿš€๐Ÿง‘โ€๐Ÿš€ Fan of Postman ? Try out the official public collection for your tests !

On this current version GitHub release, 27 different roles are available to play:

  • The Werewolf
  • The Big Bad Wolf
  • The Vile Father Of Wolves
  • The White Werewolf
  • The Villager
  • The Villager-Villager
  • The Seer
  • The Cupid
  • The Witch
  • The Hunter
  • The Little Girl
  • The Guard
  • The Ancient
  • The Scapegoat
  • The Idiot
  • The Two Sisters
  • The Three Brothers
  • The Fox
  • The Bear Tamer
  • The Stuttering Judge
  • The Rusty Sword Knight
  • The Wild Child
  • The Dog-Wolf
  • The Thief
  • The Angel
  • The Pied Piper
  • The Raven

Please check the Player role section on API documentation or the Available Roles section on the official website for more details about each role.

Documentation is available for both versions:

Note that contributors try their best to maintain documentations up to date. If you find any typos or oversights, please open an issue, or a pull request.

Each change when a new version comes up is listed in the CHANGELOG.md file placed at project's root.

Also, you can keep up with changes by watching releases with the Watch GitHub button at the top of this page.

Current release on main API is GitHub release.

โœจ Main API is updated when commits are merged into the master branch.

๐Ÿ”ง Sandbox API is updated when commits are merged into the staging branch.

Travis helps the project to be automatically updated by deploying new versions for both Sandbox and Main APIs. Please refer to the .travis.yml file for more details.

In order to keep the code clean, consistent and free of bad JS practises, ESLint is installed with more than 220 rules activated !

Complete list of all enabled rules is available in the .eslintrc.js file.

  1. Install dependencies with npm install (add --production to omit dev dependencies).
  2. Copy .env.example and paste it as .env.
  3. Replace environment values in the fresh new .env file if necessary (When โš ๏ธ๏ธ Required is specified):
    • DB_USER: User for authenticating into the MongoDB database.
      • โš ๏ธ Required if MongoDB auth is enabled
    • DB_PASSWORD: Password for authenticating into the MongoDB database.
      • โš ๏ธ Required if MongoDB auth is enabled
    • DB_NAME: Name of the MongoDB database.
      • Not required - Default value: werewolves-assistant
    • BASIC_USERNAME: Username for basic authentication.
      • Not required - Default value: root
    • BASIC_PASSWORD: Password for basic authentication.
      • Not required - Default value: secret
    • PORT: Which port the API must run.
      • Not required - Default value: 4202
    • JWT_SECRET: Encryption key used for JSON Web Token.
      • Not required - Default value: somethingsecret
    • SENTRY_ENABLED: Enable if errors are caught and sent to Sentry.
      • Not required
    • SENTRY_PROJECT_ID: Sentry project's ID.
      • Not required
    • SENTRY_KEY: Sentry secret key.
      • Not required
    • FACEBOOK_APP_ID: Facebook application ID if you want to enable Facebook authentication.
      • Not Required
    • GOOGLE_CLIENT_ID: Google client ID if you want to enable Google authentication.
      • Not Required

To start the API on development mode, simply run npm start.

To start the API on production mode, run npm run start_sandbox or npm run start_production.

  • Tests: npm run test runs various tests to check API endpoints.
  • Lint: npm run lint checks for code style. Based on AirBnB configuration with many more rules.
  • Doc: npm run doc generates doc for API.

This project is licensed under the MIT License.

If you want to contribute to this project, please read the contribution guide.

Thank you to all the contributors:


Thomas Deschamps

werewolves-assistant-api's People

Contributors

antoinezanardi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

werewolves-assistant-api's Issues

Implement Cupid Role

Implement Cupid Role with:

  • First night turn in which he chooses the lovers.
  • Game won by lovers.
  • When a lover dies, the other one dies too.

Add mongoDB auth

Add mongoDB authentication for security and credentials in mongoose.

Limit game history length

In general, limit the game history for games of 3 entries maximum for speed purposes.

For full history, set query string ?full-history=true.

Change game options structure

In order to be more readable, change game.options for an object:

{
  "options": {
     "roles": { 
        "sheriff": {...}, 
        "seer": {...},
        "twoSisters": {...},
        "threeBrothers": {...},
     }
}

Game options

Before creating a game, options can be set.

First parameters are:

  • sistersWakingUpInterval (Number >= 0 - Default is 2): The two sisters waking up interval at night after the first night.
  • brothersWakingUpInterval (Number >= 0 - Default is 2): The three brothers waking up interval at night after the first night.
  • isSheriffVoteDoubled (Boolean - Default is true): The sheriff vote is doubled. When disabled, it's a regular vote.
  • isSeerTalkative(Boolean - Default is true): When the seer is talkative and looks a role, the game master must alert the sleeping villagers about the seen role.

Change roles icon in documentation

Change role icon for:

  • Witch => ๐Ÿช„
  • Raven => ๐Ÿชถ

In documentation, tests.

Additionally, little girl and villager-villager are not in the README.md.

Change some game rules

Some game rules must be changed to match the official rules:

  1. Guard protects only against werewolves and play before the werewolves.
  2. If hunter dies, it needs to play before ending the game.
  3. [Wrinting in progress...]

Implement Two Sisters Role

Implement the Two Sisters Role with:

  • First night turn in which they are meeting each other.
  • Every other night, if both are alive, they wake up to speak with each other.

In random composition repartition, little sisters are set when there are minimum 12 players.
Game can't start if there is only one sister in game repartition.

Game review

When a game is canceled or done, the game master can post its review.

The review is structured like this:

  • A note (integer from 0 to 5).
  • An optional comment (limited to 500 characters).
  • A boolean for specifying if there was a bug during the game.

This review is optional.

Implement the Idiot Role

  • If he dies from the vote, he doesn't die, his role is revealed and he can't vote for the rest of the game (cant-vote attribute).
  • If he dies and he was the sheriff, the sheriff attribute is not delegated. There is no sheriff in the game anymore.

Game option for no sheriff

Implement game option for no sheriff in the game.

  • Option is options.roles.sheriff.enabled, Boolean.
  • No elect-sheriff, delegates or settle-votes actions.
  • If equality in vote, second vote in which you can only vote for the tied players from the previous vote.
  • If equality again, there is no death from the votes.

Request limit on routes

API routes must be protected with a request limit.

Each route has a custom limit.

Must not be active for e2e tests except for request limit tests.

Add server configuration in README.md

In README.md file, add server configuration on which the APIs (Sandbox and Live) are running with:

  • Linux distribution
  • NodeJS version
  • NPM version
  • MongoDB version

Implement Scapegoat Role

  • If there is a tie in the votes, he is the chosen one to be killed.
  • Before getting killed, he chooses who doesn't vote for the next day. The attribute is cant-vote and remainingPhases is 3 (for next day).
  • If no one can vote, there is no vote for the next day.

Player name limitations

When creating a game, player's name needs to be:

  • Limited to 30 characters.
  • Filtered with xss module in order to prevent XSS attacks.

Fix Travis warnings

Travis displays several warnings that needs to be fixed:

  • root: deprecated key sudo (The key sudo has no effect anymore.)
  • deploy: deprecated key skip_cleanup (not supported in dpl v2, use cleanup)
  • deploy: deprecated key skip_cleanup (not supported in dpl v2, use cleanup)
  • root: missing dist, using the default xenial
  • root: missing os, using the default linux

Implement Big Bad Wolf Role

Implement Big Bad Wolf Role with:

  • Until no player on the werewolf side is dead, he eats another victim after the other werewolves.

In random composition repartition, big bad wolf is set when there are minimum 12 players.

Implement the Ancient Role

Implement the Ancient Role:

  • If he is eaten, he will survive from the werewolves and from the vile father of wolves infection. The second time, he will die.
  • The life potion from the witch protects him only once.
  • If the source of death is not a werewolf (except if he dies from love), all villagers will loose their powers. All villagers will have the attribute powerless for the rest of the game.

Improve APIDoc classes

Improve APIDoc classes by adding โฎ‘ instead of tabs for better display on smaller screens for nested properties.

Fill waiting queue with night actions

Instead of predicting each night actions one by one, fill the waiting queue before the night starts with all actions based on available roles and night actions order.

Enhancements on README file

  • The two live demos on README file need to open a new tab when clicking on one of them. Add Postman collection public link.

  • Link for CHANGELOG.

  • ESLint Section with number of rules and link to file.

  • Better installation instructions for contributing.

  • Contributors section.

Sheriff has a double vote

When the player as the sheriff votes, his vote is twice.

He can't vote against 2 different players.

Handle the case if there is no winners

For example, there's a game with 3 players left: the hunter, the witch and a werewolf.

During the night, the werewolf eats the witch and the witch poisoned the hunter.

When sun rises, hunter must shoot but only werewolf is alive.

The case of a game with no winners must be handled.

Decrease `remainingPhases` for attributes

When an attribute is attached to a player, it has a life time represented by the remainingPhases field.

If the attribute is endless, then the remainingPhases attribute won't be set.

If remainingPhases is set, the counter attached to it will decrease each time a phase passes. When set to 0, the attribute will disappear from the player.

Implement Wild Child Role

Implement Wild Child Role with:

  • First night turn in which he chooses his model.
  • When his model dies, he becomes a werewolf and wakes up with other werewolves.

User info limitations

When creating an account, users have to specify email and password. Those values need to be limited to 30 characters for better database storage.

Implement Vile Father of Wolves

Implement the Vile Father of Wolves Role:

  • Once in the game, the player eaten from werewolves is in the werewolves side.
  • Add isInfected in the targets structure.
  • The infected player keeps his powers and must win with the werewolves. side.current is set to werewolves

Fix documentation error

Fix documentation error on game.won variable.

won.players can be optional and won.by can be null.

Implement the Pied Piper Role

  • Charms two players each night, they have consequently the attribute charmed. He can't charm himself.
  • If all alive players (except himself) are charmed, he wins the game.
  • If he becomes a werewolf because of the infected attribute, he also have the attribute powerless.

Implement Dog-Wolf Role

Implement Dog-Wolf Role with:

  • First night turn in which he chooses his side (villagers or werewolves).

Delegate sheriff both times

The sheriff delegated his role twice in a row. First the dying sheriff, and after his successor.

Happened in game 5f2eadb2643dd80aa50edd19, the dying sheriff was targeted by the werewolves and the death potion.

Implement Three Brothers

Implement the Three Brothers Role with:

  • First night turn in which they are meeting each other.
  • Every other night, if at least two are alive, they wake up to speak with each other.

In random composition repartition, three brothers are set when there are minimum 15 players.
Game can't start if there is only one or two brothers in game repartition.

Add players source to Game History Play

Game History Plays only records for the moment the source of the play, but not the actual players involved in the action.

Change the source field from a String to an object with:

  • name: Source's name (Role, group or attribute).
  • players: Array of players involved in the play.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.