card-game
gamedev-skills/awesome-gamedev-agent-skills
Build card games with zones, draw mechanics, turn structure, and effect resolution.
What is card-game?
A compositional framework for card games covering deck/hand/discard zones, draw and shuffle logic, turn phases, resource costs, and effect resolution. Use this when building deckbuilders, TCGs, CCGs, solitaire, or roguelike deckbuilders where cards move between zones.
- Model cards as data with costs, types, and effect specs interpreted by a single engine
- Manage zones (deck, hand, play, discard, exile) with automatic reshuffle when deck empties
- Implement turn structure as a phase machine (untap, draw, main, combat, end) with trigger windows
- Handle resource systems (mana/energy/actions) that gate card play
- Resolve card effects in a defined order with target validation and atomic commits
- Prevent common bugs: cards in multiple zones, unseeded shuffles, ambiguous trigger order
How to install card-game
npx skills add https://github.com/gamedev-skills/awesome-gamedev-agent-skills --skill card-game- A game engine (Godot, Unity, or custom) with basic scene/object management
- Card data defined as assets (use godot-resources or unity-scriptableobjects)
- UI framework for hand layout and drag/drop (use godot-ui-control or game-ui-ux)
How to use card-game
- 1.Define card data as a schema: id, name, cost, type, text, and effects array
- 2.Implement zones as collections (deck, hand, play, discard) and enforce exactly-one-zone invariant
- 3.Code a draw function that reshuffles discard into deck when deck is empty
- 4.Build a turn phase machine that fires triggers at phase entry and enforces timing windows
- 5.Create an effect interpreter that reads card effect data and applies operations (damage, heal, draw, etc.)
- 6.Add resource tracking (mana/energy) and validate cost before committing a play
- 7.Implement a win/loss condition (life total, deck-out, objective) and check it each turn
Use cases
- Building a deckbuilder or roguelike deckbuilder with run-based card collection
- Creating a TCG/CCG with hand management, resource costs, and effect resolution
- Designing a solitaire card game with draw/reshuffle and win conditions
- Implementing a turn-based card battler with phases and priority windows
- Balancing a card game by tuning draw rate, hand limits, deck size, and resource curves
- Game designers building card-driven mechanics
- Developers implementing deckbuilders or roguelike card games
- Engineers designing turn-based card battle systems
- Game programmers who need a reusable card engine pattern
card-game FAQ
Use data-driven effects: define a small set of operations (damage, heal, draw, etc.) and interpret a card's effects array. One function per card becomes unmaintainable and untestable as the card pool grows.
Reshuffle the discard pile into the deck and shuffle it (using a seeded RNG for replays). If discard is also empty, trigger deck-out (lose, take fatigue, or end the game).
Enforce an invariant: moving a card is remove-from-old-zone then add-to-new-zone. Assert no card appears in multiple zones. Make play atomic: validate cost and targets first, then commit all changes.
Resolve effects in a defined order using a queue or stack. Document whether triggers are LIFO (stack) or FIFO (queue). Avoid nondeterministic outcomes by always resolving in the same sequence.
Starting hand size, draw-per-turn, hand size limit, minimum deck size, resource curve (mana costs), card rarity, and reshuffle rules. Smaller decks = more consistent combos; higher draw = less variance; higher costs = slower tempo.
Full instructions (SKILL.md)
Source of truth, from gamedev-skills/awesome-gamedev-agent-skills.
name: card-game description: > Build a card game: card data, deck/hand/discard zones, draw/shuffle/reshuffle, a turn structure, costs, and effect resolution. Use for a deckbuilder, TCG/CCG, or roguelike deckbuilder.
Card Game
A playbook for card games — card data, the deck/hand/discard zones, the turn structure, and how card effects resolve. This is a compositional skill: it models cards as data and wires them to UI. It does not re-teach data assets or UI nodes; it defines the zone model, the draw machinery, and the effect-resolution rules that keep a card game correct and bug-free.
When to use
- Use when building any game where the core objects are cards moving between zones (deck → hand → play → discard): deckbuilder, TCG/CCG, solitaire, roguelike deckbuilder.
- Use when designing draw/shuffle/reshuffle, turn structure, card costs, or how effects resolve.
When not to use: board/tile state with matching rules → puzzle. RPG with an
incidental card battler → start from rpg. For defining cards as assets, use godot-resources
/ unity-scriptableobjects; for the hand/drag UI, use godot-ui-control.
Core loop
Draw to your hand → spend resources to play cards → effects resolve and change the board → end the turn (cleanup/discard) → opponent/next phase → repeat until a win condition. Depth comes from the combinations a hand allows; the engine's job is to resolve them unambiguously.
Must-have systems
- Card data — id, name, cost, type, text, and an effect spec (data, not code).
- Zones — deck (draw pile), hand, play/board, discard, exile/removed; cards live in exactly one.
- Draw + shuffle + reshuffle — draw from deck to hand; reshuffle discard into deck when empty.
- Turn structure — phases (untap/draw/main/combat/end) as a state machine.
- Resource system — mana/energy/actions that gate how much you do per turn.
- Effect resolution — apply a card's effects in a defined order; handle targets and triggers.
- Win/loss condition — life total, deck-out, objective.
- UI — hand layout, drag/drop or tap-to-play, zone counts, targeting affordances.
Design knobs
| Knob | Effect | Notes |
|---|---|---|
| Starting hand / draw-per-turn | tempo, consistency | More draw = less variance. |
| Hand size limit | hoarding vs. use | Discard down at end of turn. |
| Deck size (min) | consistency | Smaller = more reliable combos. |
| Resource curve | what's playable when | "Mana curve" paces power. |
| Card rarity / power budget | balance | Stronger cards cost more / are rarer. |
| Determinism vs. randomness | skill vs. swing | Shuffle + random effects add variance. |
| Reshuffle rules | deck-out, fatigue | Reshuffle discard, or punish empty deck. |
| Removal / answers | counterplay | Every threat needs an answer in the pool. |
Patterns
1. Zones + draw with automatic reshuffle
# Pseudocode. A card is in exactly one zone at a time; moving = remove here, add there.
def draw(n):
for _ in range(n):
if not deck:
if not discard: # truly empty: deck-out (lose, or take fatigue)
on_deck_out(); return
deck.extend(discard) # reshuffle discard into deck
discard.clear()
shuffle(deck, rng) # use a seeded RNG (see save-systems for replays)
hand.append(deck.pop())
2. Card as data + effect resolution
# Pseudocode. Effects are a data list interpreted by the engine — not bespoke code per card.
card = {
"id": "fireball", "cost": 3, "type": "spell",
"effects": [ {"op": "damage", "amount": 6, "target": "chosen_enemy"} ],
}
def play(card, caster):
if resources[caster] < card.cost: return False # can't afford
resources[caster] -= card.cost
move(card, from_zone=hand, to_zone=play_or_discard(card))
for fx in card.effects:
resolve_effect(fx, caster) # one interpreter handles every card
return True
3. Turn structure as a phase machine
# Pseudocode. Fixed phases keep timing windows (triggers, priority) unambiguous.
PHASES = ["untap", "draw", "main", "combat", "end"]
def take_turn(player):
for phase in PHASES:
enter_phase(player, phase) # fire "on_phase" triggers here
if phase == "draw": draw(1)
if phase == "main": await player_plays_cards()
if phase == "combat": resolve_combat()
if phase == "end": discard_to_hand_limit(player); clear_temporary_effects()
Pitfalls / failure modes
- A card existing in two zones at once → duplication/loss bugs. Enforce "exactly one zone"; move = remove-then-add, and assert no card appears twice.
- Forgetting to reshuffle → draws silently fail or crash on empty deck. Reshuffle discard, or define deck-out/fatigue explicitly (Pattern 1).
- One function per card → unmaintainable and untestable. Make effects data interpreted by a small set of operations (Pattern 2).
- Ambiguous effect order / simultaneous triggers → nondeterministic outcomes. Resolve in a defined order (a queue or stack); document LIFO vs. FIFO (refs).
- Unseeded shuffle in a game that needs replays/undo → can't reproduce. Use a seeded RNG.
- No hand limit / no answers → degenerate hoarding or unbeatable threats. Add a hand cap and ensure removal exists for every threat archetype.
- Targeting state leaks → a cancelled play leaves the board mid-targeting. Make play atomic: validate cost + targets first, then commit.
Composition (build it from these skills)
- Card content:
godot-resources/unity-scriptableobjects— define each card as a data asset. - UI:
game-ui-uxfor layout, scaling, and focus navigation;godot-ui-controlfor hand layout, drag/drop, zone counts, and targeting prompts. - Persistence/replays:
save-systemsfor collection, run state (roguelike deckbuilder), and seeded replays. - Opponent AI:
game-aifor an AI that evaluates playable cards and picks targets. - Animation/feedback: the engine animation skill for card movement;
audio-designfor cues. - Scripting:
godot-gdscript/unity-csharp-scriptingfor the effect interpreter.
References
- For the effect queue/stack, keywords/triggers, targeting, deckbuilder vs. constructed
archetypes, and shuffle fairness, read
references/effect-resolution.md.
Related skills
More from gamedev-skills/awesome-gamedev-agent-skills and the wider catalog.

create-game-assets
Plan, generate, source, normalize, and validate cohesive visual game assets for any engine or art style.

dialogue-systems
Build branching dialogue trees with Ink, Yarn Spinner, or a custom JSON runner.

fps-shooter
Build first-person shooter mechanics: controller, hitscan/projectile combat, weapons, health, and enemy AI.

game-ai
Design NPC and enemy decision-making with FSMs, behavior trees, steering, and A* pathfinding.

game-feel
Add punchy, satisfying feedback—screen shake, hit-stop, easing, squash & stretch—to make game actions feel responsive.

game-jam
Plan and ship a game under a jam deadline: lock scope, schedule hours, cut features, submit on time.