Contract types and abstract interfaces for the Game Framework ecosystem.
This repository provides the shared Python package used to coordinate game state, client/server messaging, and game-specific implementations across the Game Framework projects. It does not contain an app or runner implementation; it defines the interfaces and data models that the other repositories build against.
src/game_contracts/: public contract modulessrc/game_contracts/message.py: message envelope models used for client/server exchangesrc/game_contracts/game_ui_abc.py: base UI contractsrc/game_contracts/logic_core_abc.py: game state and command contractssrc/game_contracts/metadata_handler_abc.py: metadata/storage contractsrc/game_contracts/runner_client_abc.py: client-side runner contractsrc/game_contracts/runner_server_abc.py: server-side runner contractdocs/: supporting documentation and the architecture diagram image
- Python 3.12 or newer
pip- Optional:
makefor the convenience targets in the bundled Makefile
- Create and activate a virtual environment.
- Install the package in editable mode with its direct runtime dependency.
- Install test/build tooling if you plan to run the Makefile targets.
Example:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e .
python -m pip install build pytestThe Makefile includes make venv, make package, and make test targets. The make install target currently assumes a .[dev] extra, but pyproject.toml does not declare one, so the direct editable install above is the reliable path.
This package is intended to be imported by sibling Game Framework repositories. Typical imports look like this:
from game_contracts.message import ServerMessage
from game_contracts.runner_client_abc import RunnerClientABC
from game_contracts.logic_core_abc import GameState, CommandThe main data model is ServerMessage, which wraps server-originated payloads and computes a deterministic message_id. The abstract base classes define the contracts that runner, UI, metadata, and game logic implementations must satisfy.
