Card Generator¶
The BDPD Card Generator converts the card data (cards_v03.json)
into print-ready PNG images using an SVG template pipeline.
What It Does¶
Reads each card definition from cards_v03.json, applies its data
(name, harvest value, effects, flavour text, faction colours) to a
pre-designed SVG template, and outputs one image file per card.
Pipeline¶
cards_v03.json → svg_builder.py → rasterizer.py → PNG
faction_config.json → ↑ ↑
card_template.svg → (lxml ETree) (cairosvg)
art/ (optional) →
svg_builder.py— Parses the SVG template, locates named elements by XMLid, sets text/colours/stat boxes from card data, optionally embeds artwork, and serialises back to SVG bytes.rasterizer.py— Converts SVG bytes to PNG at the requested DPI using cairosvg. Scale factor = target_dpi ÷ 96 (Inkscape default).
Template System¶
The SVG template (templates/card_template.svg) contains named
elements that svg_builder.py targets by XML id:
| SVG Element | Populated With |
|---|---|
text7 |
Card ID + version metadata |
text9 |
Card title |
text10 |
Deck badge label (e.g. "WARRIOR-KING") |
rect9 |
Deck badge border (stroke colour from faction config) |
rect15 |
Faction accent bar colour |
text15 |
Action type (e.g. "ACTION / HARVEST") |
text21 |
Rules text (wrapped tspan lines) |
text23 |
Flavour text (wrapped tspan lines) |
text24 |
Flavour source attribution |
text26 |
BDPD mapping description |
rect13 |
Artwork frame border |
text13 |
Artwork placeholder (removed when image is supplied) |
Stat boxes (rect16, text16, etc.) are dynamically rebuilt from
the card's effects — each effect that produces a numerical value
(HARVEST, HEALTH, CAPACITY, PATIENCE, RENEWAL) gets a styled box.
Output¶
| Option | Format | Use |
|---|---|---|
| Default | PNG at 150 DPI (~1172 × 1641 px) | Screen / quick preview |
--dpi 300 |
PNG at 300 DPI (~2344 × 3281 px) | Commercial print |
--svg-only |
SVG | Inkscape inspection / further editing |
Card dimensions: 750 × 1050 px at 96 DPI (Inkscape default).
Dual-Mode Cards¶
Stranger-King cards with type: "dual_mode" generate two output
files per card:
stranger_001_coop.png — Cooperative mode effects and colours
stranger_001_aggr.png — Aggressive mode effects and colours
Cooperative cards use the stranger faction accent (#B07FC7, purple);
aggressive cards use stranger_aggr (#E5A050, amber/orange).
Faction Configuration¶
templates/faction_config.json defines colours and badges per deck:
| Deck | Badge | Accent |
|---|---|---|
warrior |
WARRIOR-KING | #E05252 (red) |
temple |
TEMPLE | #8DD35F (green) |
merchant |
MERCHANT | #5B9BD5 (blue) |
stranger |
STRANGER-KING | #B07FC7 (purple) |
stranger_aggr |
STRANGER-KING | #E5A050 (amber) |
event |
EVENT | #E5C07B (gold) |
forest |
FOREST | #8DD35F (green) |
Stat box colours (label accent, background, border stroke) are also configurable per stat type (harvest, health, capacity, patience, renewal, stockpile, tithe).
Customisation¶
- Change colours: Edit
faction_config.jsonand regenerate. - Add artwork: Place images named
<card_id>.pngin anart/directory, then use--art-dir art/. - Single card:
--card-ids warrior_001generates one card only. - Filter by deck:
--decks warrior templegenerates those decks only.
See Usage for the full CLI reference and internals.