Ledger v3 · C# · Godot 4.7 Get started

Guard

A guard the other side must attack first; an attack each way at once

✓ 2 plays, 31 steps, all passingFrom Cards, content\guard.ledger, content\rules.ledger
count(enemies having TAG)lettemplate archetype

A guard the other side must attack first, lifted from the card slice's content\guard.ledger (Guarding) and the board's attack from content\rules.ledger (Ready, Attack, Mortal and the Body template). A unit attacks once a turn, from the turn after it is played, each of the two dealing its attack to the other at once; while the other side has a guard, only a guard may be attacked. A spell isn't held by it. The guard's tag is held by an effect, not the card, so the hero keeping the card in its hand is no guard; here the units stand on the board.

content/cookbook/mechanics/guard.ledgerthe content
1# A guard the other side must attack first, lifted from the card slice's content\guard.ledger (Guarding) and the
2# board's attack from content\rules.ledger (Ready, Attack, Mortal and the Body template). A unit attacks once a turn,
3# from the turn after it is played, each of the two dealing its attack to the other at once; while the other side has
4# a guard, only a guard may be attacked. A spell isn't held by it. The guard's tag is held by an effect, not the card,
5# so the hero keeping the card in its hand is no guard; here the units stand on the board.
6
7rate 10
8link team owner
9allegiance team
11stat MaxHealth
12stat Attack
13pool Health max MaxHealth whole
14pool Attacks max 1 whole
15damage Health
17tags Body Unit Hero Guard
18event TurnStarted Attacking Died
19turn TurnStarted
21effect Mortal
22 dies at no Health raising Died
24effect Ready
25 after TurnStarted of holder
26 set Attacks 1
28ability Attack
29 target one enemy having Body
30 requires has(target, Guard) or count(enemies having Guard) == 0 else "a guard is in the way"
31 cost Attacks 1
32 raise Attacking of target by holder
33 if holder.Health > 0
34 let mine = holder.Attack
35 let theirs = target.Attack
36 deal mine to target from holder
37 deal theirs to holder from target
39template archetype Body(attack, health)
40 tags Body Unit
41 base MaxHealth health
42 base Attack attack
43 full Health
44 pools Attacks
45 has Mortal
46 has Ready
47 grants Attack
49effect Guarding
50 tags Guard
52archetype Side
54archetype Hero
55 tags Body Hero
56 base MaxHealth 30
57 base Attack 0
58 full Health
60archetype Recruit from Body(1, 2)
62archetype Shieldbearer from Body(1, 4)
63 has Guarding
content/cookbook/mechanics/guard.playwhat it must do
1catalog guard.ledger
2
3# The guard's numbers, from Attack and the bodies: a recruit 1/2, a shieldbearer 1/4 that guards, a hero of 30.
4
5play "a unit attacks from its first turn on; a guard must be attacked first: the hero and the recruit behind it are refused; the guard takes 1 and gives 1"
6 make a Side
7 make b Side
8 make e Hero with team = b
9 make u Recruit with team = a
10 make g Shieldbearer with team = b
11 make r Recruit with team = b
12 act u Attack at g
13 expect refused CannotAfford
14 raise TurnStarted of u
15 act u Attack at e
16 expect refused Requirement "a guard is in the way"
17 act u Attack at r
18 expect refused Requirement "a guard is in the way"
19 act u Attack at g
20 expect done
21 expect g.Health = 3 from content: 4 less the recruit's 1
22 expect u.Health = 1 from content: 2 less the guard's 1
23 act u Attack at g
24 expect refused CannotAfford
26play "with the guard gone, the hero may be attacked"
27 make a Side
28 make b Side
29 make e Hero with team = b
30 make u Recruit with team = a
31 make g Shieldbearer with team = b
32 deal 4 to g
33 expect g gone
34 raise TurnStarted of u
35 act u Attack at e
36 expect done
37 expect e.Health = 29 from content: 30 less the recruit's 1
38 expect u.Health = 2 from content: the hero's Attack 0 back

Run it yourself

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