Skip to main content

Dominion object model

PyPI PyPI

This package contains two abstract base classes for implementing players and client libraries for the dominion project.

You can implement a GUI client for humans to play the game or an AI computer player.

Usage

A dominion player must implement the Player interface. The dominion game engine will keep a reference to the player object and call its methods at the right time.

class Player(metaclass=ABCMeta):
    @abstractmethod
    def play(self):
        pass

    @abstractmethod
    def respond(self, action, *args):
        pass

    @abstractmethod
    def on_game_event(self, event):
        pass

    @abstractmethod
    def on_state_change(self, state):
        pass

A client library will implement the GameClient interface and a reference to it will be passed to concrete player implementations. When the concrete player who implements the Player interface receives the play() command from the game engine it will invoke various GameClient methods until it finally calls done() and their turn ends.

class GameClient(metaclass=ABCMeta):
    @abstractmethod
    def play_action_card(self, card_type: str):
        pass

    @abstractmethod
    def buy(self, card_type: str):
        pass

    @abstractmethod
    def done(self):
        pass

Examples

The dominion project itself contains several computer players.

The dominion-pygame project is an implementation of a GUI client that lets humans play against each other and or bots.

Build and publish

This section is for the Dominion developers. If you just want to implement a player or a client library you can stop reading.

Pre-requisites

Create a Python 3.8.2 environment

$ pyenv install 3.8.2
$ pyenv local
$ poetry init
$ poetry env use 3.8.2
$ poetry install

Building the package

Here is the command to build the package:

(🐙)/dominion-object-model
$ poetry run python setup.py bdist_wheel

The result is tar-gzipped file in the dist subdirectory:

(🐙)/dominion-object-model
$ ls dist
dominion_object_model-1.0.1-py3-none-any.whl

Save the following to ~/.pypirc

[distutils]
index-servers=
    pypi
    pypitest

[pypitest]
repository = https://test.pypi.org/legacy/
username = <your user name>

[pypi]
repository = https://pypi.org/legacy/
username = <your user name>

Next, we can upload the package using twine to PyPI.

(🐙)/dominion-object-model
$ poetry run twine upload -p <redacted> dist/*.whl

Uploading distributions to https://upload.pypi.org/legacy/
Uploading dominion_object_model-1.0.2-py3-none-any.whl
100%|██████████████████████████████| 10.2k/10.2k [00:01<00:00, 7.20kB/s]

View at:
https://pypi.org/project/dominion-object-model/1.0.2

Metadata

Release files for dominion-object-model 1.1.0

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

Built distribution (wheel)

Table of built distributions (wheels) for dominion-object-model 1.1.0
File Interpreter ABI Platform Actions
dominion_object_model-1.1.0-py3-none-any.whl Python 3 none any Details for dominion_object_model-1.1.0-py3-none-any.whl

Release files / dominion_object_model-1.1.0-py3-none-any.whl

Download URL dominion_object_model-1.1.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee0a81a58fe28c29f4fad688e426d0a63bac356cd3d4835ade630a9731afad46
BLAKE2b-256 checksum
How to use checksums
c63149dfd791c360bd7df6e4bd197e045f9d6a514a94e83c66b0304d2358100b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2

Security for dominion-object-model 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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