Azure Function Web API for Dungeon Game
This is a serverless API that runs in Azure. I created this function to handle generating the monsters in my game. This is a fairly basic repository. It creates an initial monster for the game and then has a function to generate more monsters, based on the player's level. The idea is to move the logic out of the front-end. I also wanted to create simple API calls that have a single purpose. A game can quickly become complex.
The monster inherits several properties from the Character Class. The Monster has the following properties:
- Name: string
- HitChance: integer
- Block: integer
- MaxLife: integer
- Life: integer
- HasStrongNose: bool
- Description: string
The first monster any player will face in the game is Larry the Wimp. The API returns a JSON object for Larry, which looks like this:
{
"maxDamage": 10,
"description": "Hairy thing with fangs.",
"hasPowerfulNose": true,
"minDamage": 5,
"name": "Larry the Wimp",
"hitChance": 55,
"block": 45,
"maxLife": 50,
"life": 25
}
Retrieving the first monster is done via the GetMonster() function. This is called using the following URL: http://{baseUrl}/getmonster
Each additional monster is called using the NextMonster() function. This endpoint is a POST endpoint and accepts the playerLevel variable as a URL parameter. http://{baseUrl}/nextmonster/{playerLevel}
Contributions and improvements are always welcome, within reason. The simplicity of this API makes for limited opportunities for changes to the code. However, I will consider any clever or funny monster descriptions or monster name options.
Create a branch, add your code, and submit a pull request. I'll do my best to respond quickly.