Skip to main content

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.

Test and Deploy Docs

Table of Contents

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/-h hostname you want to server your api from. defaults to "localhost"
  • --port/-p port you want to listen on. defaults to 5000
  • --worker-count/-w amount of worker tasks to run concurrently. defaults to 1
    > 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.

Metadata

Release files for zombie-nomnom-api 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zombie-nomnom-api 1.0.0
File Size Uploaded
zombie_nomnom_api-1.0.0.tar.gz 14.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zombie-nomnom-api 1.0.0
File Interpreter ABI Platform
zombie_nomnom_api-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.5 kB

Release files / zombie_nomnom_api-1.0.0.tar.gz

Download URL zombie_nomnom_api-1.0.0.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b7be60d26186edc00126de8b456a423e70e3bf8ae7201291eff0a815a633c193
BLAKE2b-256 checksum
How to use checksums
5d4426a0b86176fd0e104956abdd0386988b7f3560e17c79844e15b8ddb89b52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / zombie_nomnom_api-1.0.0-py3-none-any.whl

Download URL zombie_nomnom_api-1.0.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
899f9291bf2eff811e066b00b51ad23ff9e08fe68e9ff08aed8841238d865ea6
BLAKE2b-256 checksum
How to use checksums
3ce041999f03154a6f4a88fe305c4cd54701b44d747cdc0a4ad3eb9013e4f959
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page