Ledger v3 · C# · Godot 4.7 Get started

Stances

States taken and given up.

✓ 2 plays, 35 steps, all passingFrom v2's cookbook

v2's cookbook, states taken and given up (G324-G325): two stances, each taking off the other, the one held reading as pressed; and a sprint that drains stamina, ends when its runner is winded, and can't be taken up again until the runner has caught its breath.

content/cookbook/stances.ledgerthe content
1# v2's cookbook, states taken and given up (G324-G325): two stances, each taking off the other, the one held reading
2# as pressed; and a sprint that drains stamina, ends when its runner is winded, and can't be taken up again until the
3# runner has caught its breath.
4
5rate 60
6stat MaxHealth
7stat Attack
8stat Armor
9stat MaxStamina
10stat StaminaRegen
11pool Health max MaxHealth
12pool Stamina max MaxStamina regen StaminaRegen
13damage Health
14tags Stance
16archetype Soldier
17 base MaxHealth 100
18 base Attack 100
19 base Armor 50
20 base MaxStamina 100
21 base StaminaRegen 10
22 full Health Stamina
23 grants TakeDefensive TakeAggressive Sprint
25# ---- G324 a defensive stance, 50 more armour and 30% less attack; an aggressive one, 30% more attack and 20 less
26# armour; taking one takes off the other, and the one held can't be taken again ----
28effect Defensive
29 tags Stance
30 exclusive Stance
31 stack ignore
32 Armor + 50
33 Attack - 30%
35effect Aggressive
36 tags Stance
37 exclusive Stance
38 stack ignore
39 Attack + 30%
40 Armor - 20
42ability TakeDefensive
43 requires not has(holder, Defensive) else "held"
44 apply Defensive to holder
46ability TakeAggressive
47 requires not has(holder, Aggressive) else "held"
48 apply Aggressive to holder
50# ---- G325 the sprint: 30 off the stamina's 10 a second, so it falls 20 a second; under 5% the runner is winded,
51# which ends the sprint and refuses another until stamina is back to 30%; pressed again, it stops ----
53effect Sprinting
54 StaminaRegen - 30
56effect Breathing
57 aura Winded on holder while Stamina < 0.05 * holder.MaxStamina until Stamina >= 0.3 * holder.MaxStamina
59effect Winded
60 start
61 remove Sprinting
63ability Sprint
64 requires not has(holder, Winded) else "winded"
65 if has(holder, Sprinting)
66 remove Sprinting
67 else
68 apply Sprinting to holder
content/cookbook/stances.playwhat it must do
1catalog stances.ledger
2row G324 Defensive Aggressive TakeDefensive TakeAggressive Soldier
3row G325 Sprinting Breathing Winded Sprint Soldier
4
5play G324 "Defensive, the soldier has 100 armour and 70 attack, and can't take it again; aggressive, 130 attack and 30 armour, the defensive stance gone"
6 make s Soldier
7 act s TakeDefensive
8 expect s.Armor = 100 from G324: s.Armor + "+50 armor"
9 expect s.Attack = 70 from G324: s.Attack * (1 - "30% attack")
10 expect s cannot TakeDefensive Requirement
11 apply Defensive to s
12 expect already
13 save
14 act s TakeAggressive
15 expect s lacks Defensive
16 expect s.Attack = 130 from G324: s.Attack * (1 + "+30% attack")
17 expect s.Armor = 30 from G324: s.Armor - "20 armor"
18 expect s can TakeDefensive
20play G325 "Sprinting, stamina falls 20 a second; just under 5 the runner is winded and stops, can't sprint until stamina is back to 30, 2.5 seconds later; pressed again a sprint stops"
21 make s Soldier
22 apply Breathing to s
23 act s Sprint
24 advance 1s
25 expect s.Stamina = 80 from G325: s.Stamina - "falls 20 per second" * "advance 1s"
26 advance 3.7s
27 expect s has Sprinting
28 advance 0.1s
29 expect s has Winded
30 expect s lacks Sprinting
31 act s Sprint
32 expect refused Requirement "winded"
33 save
34 advance 2.4s
35 expect s has Winded
36 advance 0.2s
37 expect s lacks Winded
38 act s Sprint
39 advance 0.5s
40 expect s has Sprinting
41 act s Sprint
42 expect s lacks Sprinting

Run it yourself

ledger check content/cookbook/stances.ledger content/cookbook/stances.play
ledger play content/cookbook/stances.play