An API for managing a player character's Hit Points (HP) within our game. The API will enable clients to perform various operations related to HP, including dealing damage of different types, considering character resistances and immunities, healing, and adding temporary Hit Points.
-
Deal Damage
- Implement the ability for clients to deal damage of different types (e.g., bludgeoning, fire) to a player character.
- Ensure that the API calculates damage while considering character resistances and immunities.
Suppose a player character is hit by an attack that deals Piercing damage, and the attacker rolls a 14 on the damage's Hit Die (with a Piercing damage type).
[Character Hit Points - damage: 25 - 14 = 11]
-
Heal
- Enable clients to heal a player character, increasing their HP.
-
Add Temporary Hit Points
- Implement the functionality to add temporary Hit Points to a player character.
- Ensure that temporary Hit Points follow the rules: they are not additive, always taking the higher value, and cannot be healed.
Imagine a player character named "Eldric" currently has 11 Hit Points (HP) and no temporary Hit Points. He finds a magical item that grants him an additional 10 HP during the next fight. When the attacker rolls a 19, Eldric will lose all 10 temporary Hit Points and 9 from his player HP.
- NodeJS
- Express
- SwaggerUI
- Mongoose
- Dotenv
- CORS
- Mocha
- Chai
- Download repo and open the project
- Navigate to root directory and install the dependencies:
npm install
- Create a new MongoDB Cluster
- Create a .env file in the project root directory to store the cluster username and password
MONGODB_USERNAME=<username> MONGODB_PASSWORD=<password>
- Install MongoDB on Your Machine
- Follow the installation guide for your operating system from the MongoDB documentation
- Start application
npm start
- Navigate to http://localhost:3000 in a web browser
- Swagger docs are available at http://localhost:3000/api-docs
- Routes:
/api/damage
/api/heal
/api/temp-hp
{
"characterId": "Briv",
"damageType": "slashing",
"damageAmount": 10
}
{
"characterId": "Briv",
"healAmount": 5
}
{
"characterId": "Briv",
"tempHPAmount": 15
}
npm test
Advice for common problems or issues.
npm run help
Tyler Pritchard
- 0.1
- Initial Release
- How should the resistance amount be determined in the damage function? How should Possible Damage Types be incorporated (as a data structure, a table)?
- Are damage resistances calculated before or after the temp-hp?
- Any specific tests that should be written?