Ledger v3 · C# · Godot 4.7 Get started

Deck

A deck shuffled and drawn, a turn's mana, a spell card played from the hand, fatigue

✓ 3 plays, 42 steps, all passingFrom Cards, content\rules.ledger, content\firebolt.ledger
pile ... grantsstreamshuffledraw ... tomove source tousing

A card drawn and played, and a turn's start, lifted from the card slice's content\rules.ledger (the piles, Starting, Turns, Drawing, the Card template and the Hero) and its spell from content\firebolt.ledger. A card is an item in one of its hero's piles; in the hand it grants its hero the ability that plays it. The start shuffles the deck and draws three; each turn gives a crystal, up to 10, fills the mana to the crystals and draws one: from the deck's top, into the discard where the hand holds 10, and from an empty deck fatigue, one more each time. Played, a firebolt costs 2 mana, goes to the discard and deals 3. The game makes each deck's cards into its hero's Deck and raises the events.

content/cookbook/mechanics/deck.ledgerthe content
1# A card drawn and played, and a turn's start, lifted from the card slice's content\rules.ledger (the piles, Starting,
2# Turns, Drawing, the Card template and the Hero) and its spell from content\firebolt.ledger. A card is an item in one
3# of its hero's piles; in the hand it grants its hero the ability that plays it. The start shuffles the deck and draws
4# three; each turn gives a crystal, up to 10, fills the mana to the crystals and draws one: from the deck's top, into
5# the discard where the hand holds 10, and from an empty deck fatigue, one more each time. Played, a firebolt costs 2
6# mana, goes to the discard and deals 3. The game makes each deck's cards into its hero's Deck and raises the events.
7
8rate 10
9link team owner
10allegiance team
12stream Shuffle
13pile Deck Discard
14pile Hand grants
16stat MaxHealth
17pool Health max MaxHealth whole
18pool Crystals max 10 whole
19pool Mana max 10 whole
20pool Fatigue whole
21damage Health
23tags Body Card Play Hero
24event GameStarted TurnStarted DrawCard
25turn TurnStarted
27effect Starting
28 after GameStarted of holder
29 shuffle holder.Deck using Shuffle
30 repeat 3
31 raise DrawCard of holder
33effect Turns
34 after TurnStarted of holder
35 gain Crystals 1
36 set Mana holder.Crystals
37 raise DrawCard of holder
39effect Drawing
40 after DrawCard of holder
41 if holder.Deck == 0
42 gain Fatigue 1
43 deal holder.Fatigue to holder sourceless
44 else
45 if holder.Hand >= 10
46 draw 1 from holder.Deck to holder.Discard
47 else
48 draw 1 from holder.Deck to holder.Hand
50template archetype Card(power)
51 tags Card
52 grants power
54ability PlayFirebolt
55 tags Play
56 target one having Body
57 cost Mana 2
58 move source to holder.Discard
59 deal 3 to target
61archetype FireboltCard from Card(PlayFirebolt)
63archetype Side
65archetype Hero
66 tags Body Hero
67 base MaxHealth 30
68 full Health
69 pools Crystals Mana Fatigue
70 has Starting
71 has Turns
72 has Drawing
content/cookbook/mechanics/deck.playwhat it must do
1catalog deck.ledger
2
3# The deck's numbers, from Starting (three draws), Turns (a crystal, the mana filled, a draw), Drawing and
4# PlayFirebolt (2 mana, 3 damage); a hero's 30 Health.
5
6play "the start shuffles a deck of 5 and draws 3; a turn gives a crystal, fills the mana to it and draws 1"
7 seed 1
8 make a Side
9 make h Hero with team = a
10 make c1 FireboltCard
11 make c2 FireboltCard
12 make c3 FireboltCard
13 make c4 FireboltCard
14 make c5 FireboltCard
15 move c1 to h.Deck
16 move c2 to h.Deck
17 move c3 to h.Deck
18 move c4 to h.Deck
19 move c5 to h.Deck
20 raise GameStarted of h
21 expect h.Hand = 3 from content: Starting's three draws
22 expect h.Deck = 2 from content: 5 less the three
23 save
24 raise TurnStarted of h
25 expect h.Crystals = 1 from content: one a turn
26 expect h.Mana = 1 from content: filled to the crystals
27 expect h.Hand = 4 from content: 3 and the turn's draw
28 expect h.Deck = 1 from content: 2 less the turn's draw
30play "a firebolt in the hand is played for 2 at the other hero, 3 off its 30, and goes to the discard; with too little mana it is refused"
31 make a Side
32 make b Side
33 make h Hero with team = a
34 make e Hero with team = b
35 make c1 FireboltCard
36 move c1 to h.Hand
37 raise TurnStarted of h
38 act h PlayFirebolt at e using c1
39 expect refused CannotAfford
40 raise TurnStarted of h
41 act h PlayFirebolt at e using c1
42 expect done
43 expect e.Health = 27 from content: 30 less 3
44 expect c1 in h.Discard
45 expect h.Mana = 0 from content: two crystals' 2 less the bolt's 2
47play "an empty deck draws fatigue, 1 and then 2"
48 make a Side
49 make h Hero with team = a
50 raise DrawCard of h
51 expect h.Health = 29 from content: 30 less the first fatigue, 1
52 raise DrawCard of h
53 expect h.Health = 27 from content: 29 less the second, 2

Run it yourself

ledger check content/cookbook/mechanics/deck.ledger content/cookbook/mechanics/deck.play
ledger play content/cookbook/mechanics/deck.play