An API for the zombie-nomnom pypi package exposing functionality via a graphql api.
Project description
Zombie Nom Nom API
This is a game engine that is modeled after the popular board game zombie dice. This is meant for practice to be able to be messed with and explored.
Table of Contents
Useful Links
Links to result of code coverage and pytest of latest builds.
Installation
pip install zombie-nomnom-api
We require at least python 3.10 to be able to run properly.
Usage
To launch the app you will just need to run the package directly.
> zombie-nomnom-api
DEBUG:zombie_nomnom_api.graphql_app.schema:Registered schemas: ['Query', 'Mutation', 'Game', 'Round', 'Player', 'DieBag', 'Die', 'Move', 'DieColor', 'DieFace']
DEBUG:asyncio:Using proactor: IocpProactor
INFO: Started server process [16240]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://localhost:5000 (Press CTRL+C to quit)
CLI Support the following params
--host/-hhostname you want to server your api from. defaults to"localhost"--port/-pport you want to listen on. defaults to5000--worker-count/-wamount of worker tasks to run concurrently. defaults to1
> zombie-nomnom-api -p 5000 -h 0.0.0.0 -w 10
Configurations
Cross Origin Resource Sharing (CORS)
| Environment Variables | Description |
|---|---|
CORS_ORIGINS |
Comma separated list of origins to allow. Default: ["*"] |
CORS_ALLOW_CREDENTIALS |
Whether or not to allow credentials. Default: True |
CORS_METHODS |
Comma separated list of methods to allow. Default: ["*"] |
CORS_HEADERS |
Comma separated list of headers to allow. Default: ["*"] |
Logging
| Environment Variables | Description |
|---|---|
LOG_LEVEL |
The log level to use. Default: "DEBUG" |
Running locally
To run the service locally you simply need to run the module directly with python like:
> python -m zombie_nomnom_api
GraphQL Usage
For playing around with graphql queries please refer to our hosted playground
Queries
Query All Games
GQL Query
query GetAllGames {
games {
id
moves {
name
player {
id
name
}
}
players {
id
name
score
hand {
color
currentFace
}
}
round {
player {
id
}
bag {
dice {
color
currentFace
sides
}
drawnDice {
color
currentFace
}
}
points
ended
}
gameOver
winner {
id
name
}
}
}
Example JSON
{
"data": {
"games": [
{
"id": "b7ca3741-a850-4c11-83d5-15901b1b371b",
"moves": [
{
"name": "Score",
"player": {
"id": "61da55d0-0fee-48da-a613-0cb767d8eab2",
"name": "player"
}
}
],
"players": [
{
"id": "61da55d0-0fee-48da-a613-0cb767d8eab2",
"name": "player",
"score": 0,
"hand": []
}
],
"round": {
"player": {
"id": "61da55d0-0fee-48da-a613-0cb767d8eab2"
},
"bag": {
"dice": [
{
"color": "GREEN",
"currentFace": null,
"sides": [
"BRAIN",
"BRAIN",
"BRAIN",
"FOOT",
"FOOT",
"SHOTGUN"
]
},
{
"color": "GREEN",
"currentFace": null,
"sides": [
"BRAIN",
"BRAIN",
"BRAIN",
"FOOT",
"FOOT",
"SHOTGUN"
]
},
{
"color": "GREEN",
"currentFace": null,
"sides": [
"BRAIN",
"BRAIN",
"BRAIN",
"FOOT",
"FOOT",
"SHOTGUN"
]
},
{
"color": "GREEN",
"currentFace": null,
"sides": [
"BRAIN",
"BRAIN",
"BRAIN",
"FOOT",
"FOOT",
"SHOTGUN"
]
},
{
"color": "GREEN",
"currentFace": null,
"sides": [
"BRAIN",
"BRAIN",
"BRAIN",
"FOOT",
"FOOT",
"SHOTGUN"
]
},
{
"color": "GREEN",
"currentFace": null,
"sides": [
"BRAIN",
"BRAIN",
"BRAIN",
"FOOT",
"FOOT",
"SHOTGUN"
]
},
{
"color": "YELLOW",
"currentFace": null,
"sides": [
"BRAIN",
"BRAIN",
"FOOT",
"FOOT",
"SHOTGUN",
"SHOTGUN"
]
},
{
"color": "YELLOW",
"currentFace": null,
"sides": [
"BRAIN",
"BRAIN",
"FOOT",
"FOOT",
"SHOTGUN",
"SHOTGUN"
]
},
{
"color": "YELLOW",
"currentFace": null,
"sides": [
"BRAIN",
"BRAIN",
"FOOT",
"FOOT",
"SHOTGUN",
"SHOTGUN"
]
},
{
"color": "YELLOW",
"currentFace": null,
"sides": [
"BRAIN",
"BRAIN",
"FOOT",
"FOOT",
"SHOTGUN",
"SHOTGUN"
]
},
{
"color": "RED",
"currentFace": null,
"sides": [
"BRAIN",
"FOOT",
"FOOT",
"SHOTGUN",
"SHOTGUN",
"SHOTGUN"
]
},
{
"color": "RED",
"currentFace": null,
"sides": [
"BRAIN",
"FOOT",
"FOOT",
"SHOTGUN",
"SHOTGUN",
"SHOTGUN"
]
},
{
"color": "RED",
"currentFace": null,
"sides": [
"BRAIN",
"FOOT",
"FOOT",
"SHOTGUN",
"SHOTGUN",
"SHOTGUN"
]
}
],
"drawnDice": []
},
"points": 0,
"ended": false
},
"gameOver": false,
"winner": null
}
]
}
}
Mutations
Play Zombie nom nom through mutations
Creates a Game
GQL Query
mutation MakeAGame($players: [String!]!){
createGame(players: $players) {
errors
game {
id
moves {
name
player {
id
name
}
}
players {
id
name
}
}
}
}
Example JSON
{
"data": {
"createGame": {
"errors": [],
"game": {
"id": "88041563-5774-4d4a-bcee-5bde15fd2b38",
"moves": [],
"players": [
{
"id": "069d9123-4dea-4d33-8bbf-8fe3cff6fd32",
"name": "player"
}
]
}
}
}
}
Draw dice
GQL Query
```graphql mutation DrawDice($gameId: ID!) { drawDice(gameId: $gameId) { errors round { player { hand { currentFace } } } } } ```Example JSON
{
"data": {
"drawDice": {
"errors": [],
"round": {
"player": {
"hand": [
{
"currentFace": "BRAIN"
},
{
"currentFace": "BRAIN"
},
{
"currentFace": "FOOT"
}
]
}
}
}
}
}
End your turn
GQL Query
```graphql mutation EndRound($gameId: ID!){ endRound(gameId: $gameId){ errors round{ player{ score } ended } } } ```Example JSON
{
"data": {
"endRound": {
"errors": [],
"round": {
"player": {
"score": 0
},
"ended": true
}
}
}
}
Contribution
For details of conduct and expactations please refer to CONTRIBUTION.md
Pull requests will be pending review of at least one maintainer.
Pull requests are required to have finished the template checklist before they will be reviewed by a maintainer.
All code is formatted with the black formatter and we expect types and may run mypy to check that your code is properly typed as expected.
Names should make sense and be self descriptive of the proposed changes.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zombie_nomnom_api-1.0.0.tar.gz.
File metadata
- Download URL: zombie_nomnom_api-1.0.0.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7be60d26186edc00126de8b456a423e70e3bf8ae7201291eff0a815a633c193
|
|
| MD5 |
295fde6e5e80310f2c5d38eea4584c17
|
|
| BLAKE2b-256 |
5d4426a0b86176fd0e104956abdd0386988b7f3560e17c79844e15b8ddb89b52
|
File details
Details for the file zombie_nomnom_api-1.0.0-py3-none-any.whl.
File metadata
- Download URL: zombie_nomnom_api-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
899f9291bf2eff811e066b00b51ad23ff9e08fe68e9ff08aed8841238d865ea6
|
|
| MD5 |
f9f668d8f0940be6bb7aaa07b938e51d
|
|
| BLAKE2b-256 |
3ce041999f03154a6f4a88fe305c4cd54701b44d747cdc0a4ad3eb9013e4f959
|