Popularity
1.5
Declining
Activity
0.0
Stable
2
2
0

Monthly Downloads: 12
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Game     T3    
Add another 't3' Package

README

t3

Build Status

API

Register

Request: POST /register

{
    "name": "<user-name>"
}

Response: 200

{
    "creds": {
        "userId": "<user-id>",
        "token": "<user-token>"
    }
}

Random bot (Not stored)

Request: POST /practice-lobby

{
    "creds": {
        "userId": "<user-id>",
        "token": "<user-token>"
    }
}

Response: 200

{
    "start": {
        "gameId": "<game-id>",
        "o": "<user-id>",
        "x": "<user-id>"
    },
    "step": {
        "final": null,
        "board": [
            [" "," "," "],
            [" "," "," "],
            [" "," "," "]
        ]
    }
}

Start

Request: POST /lobby

{
    "creds": {
        "userId": "<user-id>",
        "token": "<user-token>"
    }
}

Response: 200

{
    "start": {
        "gameId": "<game-id>",
        "o": "<user-id-1>",
        "x": "<user-id-2>"
    },
    "step": {
        "final": null,
        "board": [
            [" "," "," "],
            [" "," "," "],
            [" "," "," "]
        ]
    }
}

Play

Request: POST /play

{
    "creds": {
        "userId": "<user-id>",
        "token": "<user-token>"
    },
    "gameId": "<game-id>",
    "loc": {
        "x": 1,
        "y": 1
    }
}

Response (Unfinished): 200

{
    "step": {
       "final": null,
       "board": [
           [" "," "," "],
           [" ","X"," "],
           [" "," "," "]
      ],
    }
}

Response (Finished): 200

{
    "step": {
        "final":"Won",
        "board": [
            ["X","O"," "],
            ["X","X","O"],
            ["O"," ","X"]
        ]
    }
}

Game result(s)

Request: POST /result

{
    "gameId": "<game-id>"
}

Response: 200

{
    "result": {
        "start": {
            "gameId": "<game-id>",
            "o": "<user-id-1>",
            "x": "<user-id-2>"
        },
        "board": [
            ["X"," "," "],
            ["O","X"," "],
            [" ","O","X"]
        ],
        "loser": "O",
        "winner": "X"
    }
}