---
# System prepended metadata

title: GH Backend Technical Test

---

# GH Backend Technical Test

The company starts developing a new game and needs the backend team to develop the backend to make sure players can not cheat when performing the actions.

## Requirements

We need to design an API for a game that has the following endpoints.

### Game Start

This endpoint will create and initialise a new game for the player $PLAYER_ID.

A empty response will be returned if the game was correctly initialised.

When calling this endpoint for a existing player, the progress will be removed and the player will start over again.

> **Request**
> `curl -X POST -H "Player-Id: $PLAYER_ID" -H "Content-Type: application/json" http://$HOST:$PORT/game/start`

> **Response**
> Return a success or a error code.

### Spin Roulette

This endpoint will give the player a random number of **Coins** ( between 0 and 2 ). This currency will be a requirement to start a level. 

Player will be able to spin the roulette only a number times in a row, this number is defined under `roulette.max-spin-strike` key in [Game Configuration](#Game-Configuration). A successful [Level Play](#Level-Play) will reset this counter.

> **Request**
> `curl -X POST -H "Player-Id: $PLAYER_ID" -H "Content-Type: application/json" http://$HOST:$PORT/coins/add`

> **Response**
> Return the new amount of coins in the wallet. ( Also a success or error response code. If error return the reason). Format decided by the candidate.

### Level Play

This endpoint will be used to play a level for the player. Level configuration can be found under `levels` key in [Game Configuration](#Game-Configuration) section.

To successfully complete a level the **player needs to have all the levels under key `level-ids-required` completed** and to **have at least the value of `coins-price` for that level**.

If the player matches the conditions the Level Play will be successful. A successfully played level **will give the rewards** of that level to the player (found under `coins-reward` key in [Game Configuration](#Game-Configuration) section) and **reset the roulette spin strike counter**. **The amount of coins** found under `coins-price` key in [Game Configuration](#Game-Configuration) section **will be subtracted**.

[**EDGE CASE**: FINISHING THE GAME] If player successfully plays the last level of the configuration return a message in the response with the payload **"YOU WON"**.

> **Request**
> `curl -X POST -H "Player-Id: $PLAYER_ID" -H "Content-Type: application/json" http://$HOST:$PORT/level/play -d '{"level_id":"<level-id>"}'`

> **Response**
> Return the output of completing a level ( success or error. If error return the reason). Format decided by the candidate.

## Game Configuration

This is the Json that configures the game.

```json=
{
    "roulette":[
        "max-spin-strike": 3
    ]
    "levels": [
        {
            "id": "level-0A",
            "coins-price": 2,
            "coins-reward": 5
        },
        {
            "id": "level-0B",
            "coins-price": 2,
            "coins-reward": 7
        },
        {
            "id": "level-1",
            "level-ids-required":[
                "level-0A",
                "level-0B"
            ],
            "coins-price": 4,
            "coins-reward": 10
        },
        {
            "id": "level-2",
            "level-ids-required":[
                "level-1"
            ],
            "coins-price": 7,
            "coins-reward": 10
        },
        {
            "id": "level-3",
            "level-ids-required":[
                "level-2"
            ],
            "coins-needed": 10,
            "coins-reward": 20
        }
    ]
}
```

## Technical requirements

We require all our backend games to be written in .NET Core since the logic of the game could be shared with client at some point.

Since we're starting the game and the backend will run in local, we will store the players information in files ( but maybe this changes in the future, who knows? ).

## What do we evaluate in the technical test?

- Arquitecture
    - Design Patterns applied
    - SOLID principles
    - Layer separation
    - Code coupling
    - Code Observability
- Testing
- CI/CD
- Git skills