Skip to main content

dominion-setup

PyPI Supported Python Versions CI Test Documentation Status OpenSSF Best Practices

dominion-setup is a Python library and CLI tool to set up a game of Dominion, the classic deck-building game.

Features

  • Complete card database — ships with JSON data for every Dominion set released to date: Base, Intrigue, Seaside, Alchemy, Prosperity, Cornucopia & Guilds, Hinterlands, Dark Ages, Adventures, Empires, Nocturne, Renaissance, Menagerie, Allies, Plunder, Rising Sun, and Promo cards.
  • Edition-aware — correctly handles 1st and 2nd edition differences for Base, Intrigue, Seaside, Prosperity, Cornucopia & Guilds, and Hinterlands.
  • Rules-accurate generation — automatically applies all official setup rules, including:
    • Selecting 10 random Kingdom piles from the chosen set(s).
    • Drawing up to a configurable number of Landscape cards (Events, Landmarks, Projects, Ways, Traits).
    • Adding extra piles required by specific cards (Bane for Young Witch, Ferryman pile, Way of the Mouse pile, Riverboat pile, Approaching Army pile, Traveller chains for Page and Peasant, Prizes for Tournament, Rewards for Joust, Spirit/Zombie/Imp/Ghost piles for Nocturne cards, Artifacts for Flag Bearer / Border Guard / Treasurer / Swashbuckler, Loot, Horse pile, and more).
    • Choosing an Ally when any Liaison card is in the Kingdom.
    • Choosing a Prophecy when any Omen card is in the Kingdom.
    • Dealing a Black Market deck (15 unused Kingdom cards by default) when Black Market is in use, with the setup its cards need.
    • Assigning Traits to random Action/Treasure Kingdom piles.
    • Randomly determining Colony/Platinum and Shelters based on Prosperity/Dark Ages representation, or allowing you to force them on or off.
    • Deriving the correct Potion, Ruins, and Heirloom basic piles.
    • Collecting all required materials (mats, tokens, cubes) and per-card setup instructions.
    • Working out how many cards go in each pile for 2 to 6 players.
  • Swaps — swap any Kingdom card, extra pile or Landscape of a game for a random one or one you pick, keeping everything that doesn't depend on it.
  • Flexible sorting — kingdom piles can be sorted by cost, name, or set.
  • Rich terminal output — the CLI renders colour-coded tables with Rich.
  • Fully typed — ships with a py.typed marker and complete type annotations.

Design

Architecture

The package is structured around four modules:

Module Responsibility
models Dataclasses and enums (Card, CardCost, CardSet, CardDatabase, Game, Board, Pile, …)
loader Reads the bundled JSON data files and populates a CardDatabase
generator generate_game(), which turns a CardDatabase into a Game, and all setup rules
cli Click/Rich-Click command group (generate, list-cards, list-sets)

Card data

Every card in every set is stored in a small JSON file under dominion_setup/data/cards/. Each entry records the card's name, types, purpose (Basic, Kingdom Pile, Landscape, Mixed Pile Card, Non-Supply, Status), cost (coins, Potion, debt), set, supported edition(s), supply quantity, and the full instruction text used to derive materials and setup notes.

{
  "name": "Artisan",
  "types": ["Action"],
  "purpose": "Kingdom Pile",
  "cost": {"coins": 6},
  "set": "Base",
  "editions": [2],
  "quantity": 10,
  "image": "Artisan.jpg",
  "instructions": "Gain a card to your hand costing up to $5.\nPut a card from your hand onto your deck."
}

Generation algorithm

generate_game() performs the following steps in order. Each step has its own section in the generator module, holding the rules it applies.

  1. Kingdom — start from the included cards (from any set), shuffle the other Kingdom and Landscape cards of the selected sets and editions (minus the excluded ones), and draw until there are 10 Kingdom piles, keeping up to max_landscapes Landscapes in total. If requirements are given (e.g. +Buy(s), an Attack, Trashing), the last free Kingdom slots are kept for cards that meet a requirement no drawn card meets yet.
  2. Extra Kingdom piles, Prophecy & Black Market deck — add the piles required by cards in use (Bane for Young Witch, Ferryman, Way of the Mouse, Riverboat, Approaching Army), a Prophecy if any Omen is in use, and a Black Market deck of up to black_market_size unused Kingdom cards if Black Market is in use. Repeat until nothing new is required, as an extra pile or a Black Market card can itself require one.
  3. Cards dealt out for specific cards — Druid Boons, the Ally for Liaisons, and the Kingdom pile each Trait applies to.
  4. Non-Supply piles — Prizes, Rewards, Traveller chains, Spirits, Zombies, Artifacts, Loot, Horses, etc.
  5. Basic Supply — standard basics plus conditional Colony/Platinum, Potion, Ruins, Shelters, and Heirlooms.
  6. Obelisk — the Action Supply pile Obelisk applies to.
  7. Materials — scan instruction text and card types to determine which mats and tokens are needed.
  8. Setup instructions — extract Setup: sentences from card instructions and describe the starting decks when Shelters or Heirlooms change them.
  9. Pile sizes — if players is given, how many cards go in each pile (e.g. 8 Provinces for two players, 10 Curses per player after the first).

Finally, the piles are sorted and returned in a Game object, along with its Board: the choices it was set up with.

If a board is given, its Kingdom cards and Landscapes are included like the included cards, and its other choices (extra piles, Black Market deck, Prophecy, Ally, Druid Boons, Traits, Obelisk pile, Colony and Shelters) are used where they apply instead of being drawn. A Board that leaves nothing out gives the same game for any seed.

If swaps are given, each one then opens up the place of a Kingdom card, extra pile or Landscape (or puts its replacement there) and sets the game up again. The game's other choices (its Kingdom, Landscapes, extra piles, Black Market deck, Prophecy, Ally, Druid Boons, Traits, Obelisk pile, Colony and Shelters) are kept where they still apply, and the rest is drawn again. The swapped card is not drawn again (nor are the game's extra piles and Black Market cards), and the game keeps its number of Landscapes. A replacement is included like the included cards: it must not be excluded, and the Kingdom must still meet the requirements.

Installation

dominion-setup is available on PyPI. Install with uv or your package manager of choice:

uv add dominion-setup

You can also install the command-line interface of dominion-setup as a tool that is available on the PATH (i.e., globally):

uv tool install dominion-setup

Documentation

Check out the dominion-setup documentation for the User's Guide, API Reference and CLI Reference.

Usage

As a Library

Quick start — generate a random setup

from dominion_setup import load_card_database, generate_game

# Load the bundled card database (all sets, all editions)
db = load_card_database()

# Generate a random game — by default draws from ALL sets and editions
game = generate_game(db)

# Inspect the result
for pile in game.kingdom_piles:
    marks = f" [{', '.join(str(m) for m in pile.marks)}]" if pile.marks else ""
    print(f"  {pile.card.name} ({pile.card.cost}){marks}")

Choosing specific sets and editions

from dominion_setup import load_card_database, generate_game
from dominion_setup.models import (
    CardSet,
    CardSetEdition,
    KingdomRequirement,
    KingdomSortOrder,
)

db = load_card_database()

game = generate_game(
    db,
    sets_editions={
        (CardSet.BASE, CardSetEdition.SECOND_EDITION),
        (CardSet.INTRIGUE, CardSetEdition.SECOND_EDITION),
        (CardSet.PROSPERITY, CardSetEdition.SECOND_EDITION),
    },
    sort_order=KingdomSortOrder.NAME,  # sort kingdom by name
    use_colony=True,  # always include Colony/Platinum
    use_shelters=False,  # never use Shelters
    max_landscapes=1,  # at most 1 landscape card
    requirements=[KingdomRequirement.BUYS],  # at least 1 kingdom card with +Buy(s)
    include=["Witch"],  # always use Witch
    exclude=["Chapel"],  # never use Chapel
)

To swap cards of a game, generate it again with the same seed and swaps. Everything that doesn't depend on the swapped cards stays the same:

import random

game = generate_game(db, rng=random.Random(42))
game = generate_game(
    db,
    swaps=[("Smithy", None), ("Moat", "Village")],  # redraw Smithy, Moat → Village
    rng=random.Random(42),
)

Every game has its board: the choices it was set up with (the Kingdom cards, Landscapes, Bane, Black Market deck, Ally, …). Set up a Board to get its game again, for any seed. Choices a Board leaves out (e.g. a Kingdom of fewer than 10 cards) are drawn:

from dominion_setup import Board

assert generate_game(db, board=game.board) == game

board = Board(kingdom_cards=(db.get_card_by_name("Witch"),))
game = generate_game(db, board=board)  # Witch and 9 random Kingdom cards

A Board (and the number of players) can be written as a code, the query string of a link with the cards as slugs, and read back. Like a Board, a code with gaps is filled up:

from dominion_setup import read_board_code

code = game.code  # also game.to_dict()["code"]
# e.g. "players=4&kingdom=bridge,clerk,…&landscapes=baths,way-of-the-mouse&bane=moat&way-of-the-mouse=village&colony=on"

board, players = read_board_code(db, code)  # or a whole link, or full card names
game = generate_game(db, board=board, players=players)

Exploring the Game object

from dominion_setup import load_card_database, generate_game

db = load_card_database()
game = generate_game(db)

# Sets used in this game
print("Sets:", ", ".join(str(s) for s in game.sets_used))

# Kingdom piles (always 10, plus any special extras such as Bane)
for pile in game.kingdom_piles:
    print(
        f"  {pile.card.name:25s} {str(pile.card.cost):>5}  {', '.join(pile.card.types)}"
    )

# Landscape cards (Events, Landmarks, Projects, Ways, Traits)
if game.landscapes:
    print("Landscapes:")
    for card in game.landscapes:
        print(f"  {card.name}")

# Ally (present when any Liaison card is in the Kingdom)
if game.ally:
    print("Ally:", game.ally.name)

# Prophecy (present when any Omen card is in the Kingdom)
if game.prophecy:
    print("Prophecy:", game.prophecy.name)

# Druid Boons (present when Druid is in the Kingdom)
if game.druid_boons:
    print("Druid Boons:", ", ".join(b.name for b in game.druid_boons))

# Non-supply piles (Prizes, Rewards, Traveller chains, Spirits, …)
if game.non_supply_piles:
    print("Non-Supply:")
    for pile in game.non_supply_piles:
        print(f"  {pile.card.name}")

# Black Market deck (present when Black Market is in use)
if game.black_market_deck:
    print("Black Market:", ", ".join(c.name for c in game.black_market_deck))

# Basic supply (Copper, Silver, Gold, Estate, Duchy, Province, Curse,
#               + conditional Colony/Platinum, Potion, Ruins, Shelters, Heirlooms)
for pile in game.basic_piles:
    print(f"  {pile.card.name}")

# Required mats and tokens
if game.materials:
    print("Materials:", ", ".join(str(m) for m in game.materials))

# Per-card setup instructions
for instruction in game.setup_instructions:
    print(f"  • {instruction}")

Querying the card database

from dominion_setup import load_card_database
from dominion_setup.models import CardSet, CardSetEdition, CardType, CardCost

db = load_card_database()

# All kingdom cards in Nocturne
nocturne_cards = db.get_cards_by_set_edition(
    CardSet.NOCTURNE, CardSetEdition.FIRST_EDITION
)
print(f"Nocturne has {len(nocturne_cards)} kingdom cards")

# All Action–Attack cards
attack_actions = [
    card
    for card in db.kingdom_cards.values()
    if CardType.ACTION in card.types and CardType.ATTACK in card.types
]

# All kingdom cards that cost $5
five_cost = db.get_cards_by_cost(CardCost(coins=5))

# Look up a card by name
village = db.get_card_by_name("Village")
print(village.name, village.cost, village.instructions)

As a CLI Tool

The dominion-setup command groups four sub-commands. Running it with no arguments is equivalent to dominion-setup generate.

dominion-setup generate — generate a random setup

Generate a random game from the Base 2nd edition (the default):

dominion-setup generate

Mix Intrigue 2e and Seaside 2e, sorted by name:

dominion-setup generate --set intrigue_2e --set seaside_2e --sort name

Use all cards from Dark Ages (always include Shelters, never Colony):

dominion-setup generate --set dark_ages --shelters --no-colony

Allow up to three landscape cards, mix Base 2e with Adventures:

dominion-setup generate --set base_2e --set adventures --max-landscapes 3

Require a Kingdom card with +Buy(s) and one that trashes cards:

dominion-setup generate --set base_2e --set intrigue_2e --require-buys --require-trashing

Always use Witch (and the Alms Event), never Chapel. Cards can be named in any case, as slugs (e.g. young-witch), or by an old name (e.g. Harem for Farm):

dominion-setup generate --set base_2e --include Witch --include Alms --exclude Chapel

Replay a game with its seed (printed with every setup, next to its Board code), and swap Smithy for a random card and Moat for Village:

dominion-setup generate --seed 42
dominion-setup generate --seed 42 --swap Smithy --swap Moat=Village

Print the setup as JSON, or as one line of card names to paste elsewhere:

dominion-setup generate --format json
dominion-setup generate --format names

Force Colony/Platinum on when playing with a Prosperity mix:

dominion-setup generate --set base_2e --set prosperity_2e --colony

Draw from the Promos you own, not the whole Promo set:

dominion-setup generate --set base_2e --promo Stash --promo "Walled Village"

Options default to the values in ~/.config/dominion-setup/config.toml (or $XDG_CONFIG_HOME/dominion-setup/config.toml), if it exists, or in the file given with --config-file FILE. Its keys are the options' long names, so it can store your collection, bans and default requirements. Options given on the command line replace the config's values:

set = ["base_2e", "intrigue_2e", "seaside_2e"]
promo = ["Stash", "Walled Village"]
exclude = ["Masquerade"]
require-buys = true
players = 4

dominion-setup setup — set up the game of a code

Set up the game of a Board code, as printed with every setup (quoted, as it holds &s), or of a whole web app link:

dominion-setup setup "players=4&kingdom=bridge,clerk,…&landscapes=baths,way-of-the-mouse&bane=moat&way-of-the-mouse=village&colony=on"
dominion-setup setup "https://…/?players=4&kingdom=bridge,clerk,…"

Anything the code leaves out is drawn, from the sets given with --set and --promo, without the --excluded cards (which only keep cards from being drawn, not the code's own cards out of the game). Colony and Shelters are not drawn: they are off unless the code turns them on (colony=on, shelters=on). Use Witch, Moat and 8 random cards from Base 2e and Intrigue 2e:

dominion-setup setup "kingdom=witch,moat" --set base_2e --set intrigue_2e

Set up a code for 3 players instead of the code's number, and swap Smithy for a random card:

dominion-setup setup "players=4&kingdom=…" --players 3 --swap Smithy

It also takes --sort and --format, and reads the same config file as generate (ignoring the options only generate has, such as require-buys). The code's number of players comes before the config file's.

dominion-setup list-cards — browse the card database

List all kingdom cards sorted by cost (default):

dominion-setup list-cards

List only Base 2e cards:

dominion-setup list-cards --set base_2e

List all Attack cards across Base 2e and Intrigue 2e:

dominion-setup list-cards --set base_2e --set intrigue_2e --type attack

List all Action–Duration cards that cost exactly $4:

dominion-setup list-cards --type action --type duration --cost 4

List all Nocturne Night cards, sorted by name:

dominion-setup list-cards --set nocturne --type night --sort name

dominion-setup list-sets — list available sets

dominion-setup list-sets

This prints a table of every supported set (and edition, where applicable) together with its kingdom card count:

              Sets
 ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
 ┃ Set                            ┃ Kingdom Cards ┃
 ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
 │ Base, 1E                       │            26 │
 │ Base, 2E                       │            26 │
 │ Intrigue, 1E                   │            26 │
 │ ...                            │           ... │
 └────────────────────────────────┴───────────────┘

Metadata

Release files for dominion-setup 2026.5.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 dominion-setup 2026.5.0
File Size Uploaded Provenance Actions
dominion_setup-2026.5.0.tar.gz 90.8 kB Without provenance Details for dominion_setup-2026.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dominion-setup 2026.5.0
File Interpreter ABI Platform Actions
dominion_setup-2026.5.0-py3-none-any.whl Python 3 none any Details for dominion_setup-2026.5.0-py3-none-any.whl

Total release size: 188.2 kB

Release files / dominion_setup-2026.5.0.tar.gz

Download URL dominion_setup-2026.5.0.tar.gz
Size 90.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a9aba61bfe1a933d6d70e65821bc5f8d1dd1916ec100234f3e08140949e2c137
BLAKE2b-256 checksum
How to use checksums
240bb05cf3053e7c652a35c9362af5537cc61f1cc7a2f140b3a22ff1fc8e8c1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / dominion_setup-2026.5.0-py3-none-any.whl

Download URL dominion_setup-2026.5.0-py3-none-any.whl
Size 97.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e38546b9d14a365b8123345f490428d02f6a74ca636f37eca98da8156a4ac1d
BLAKE2b-256 checksum
How to use checksums
b2853745e1a739a189951929ce3355c6431f2a7de3785f0893672258b38716ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for dominion-setup 2026.5.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