Ledger v3 · C# · Godot 4.7 Get started

Bank

A cost from a team's bank, and a supply cap

✓ 2 plays, 26 steps, all passingFrom RTS, content\economy.ledger
cost POOL N on holder.teamgain ... on holder.teamkind.STAT

A cost from a team's bank, and a supply cap, lifted from the RTS slice's content\economy.ledger (the Side's bank, the Train template and the base) and death from content\rules.ledger (Mortal). A side holds the ore and the supply that its every building trains from: a price is a cost on the side's bank, on holder.team, refused CannotAfford with the bank's need and have; a unit's supply is held as it is ordered and given back at its death. The slice queues each unit's training in its building's pile; that queue reads round an open language row, so here a unit is made at once.

content/cookbook/mechanics/bank.ledgerthe content
1# A cost from a team's bank, and a supply cap, lifted from the RTS slice's content\economy.ledger (the Side's bank,
2# the Train template and the base) and death from content\rules.ledger (Mortal). A side holds the ore and the supply
3# that its every building trains from: a price is a cost on the side's bank, `on holder.team`, refused CannotAfford with
4# the bank's need and have; a unit's supply is held as it is ordered and given back at its death. The slice queues
5# each unit's training in its building's pile; that queue reads round an open language row, so here a unit is made
6# at once.
7
8rate 20
9stat MaxHealth
10stat SupplyCap
11stat Food
12pool Health max MaxHealth
13pool Ore whole
14pool Supply whole
15damage Health
16link team base
17allegiance team
18tags Unit Building Base Worker
19event Died
21archetype Side
22 base SupplyCap 30
23 pools Ore Supply
24 with Ore = 50
26effect Mortal
27 dies at no Health raising Died
28 after Died of holder
29 if holder.Food > 0
30 lose Supply holder.Food on holder.team
32template ability Train(kind, price)
33 requires holder.team.Supply + kind.Food <= holder.team.SupplyCap else "not enough supply"
34 cost Ore price on holder.team
35 gain Supply kind.Food on holder.team
36 create kind with team = holder.team, base = holder
38ability TrainWorker from Train(Worker, 50)
40archetype Base
41 tags Building Base
42 base MaxHealth 1500
43 full Health
44 has Mortal
45 grants TrainWorker
47archetype Worker
48 tags Unit Worker
49 base MaxHealth 40
50 base Food 1
51 full Health
52 has Mortal
content/cookbook/mechanics/bank.playwhat it must do
1catalog bank.ledger
2
3# The bank's numbers, from the Side (50 ore, a supply cap of 30), Train and the Worker (50 ore, 1 supply).
4
5play "a worker costs its side 50 ore and holds 1 supply; a second is refused CannotAfford with the bank's need and have"
6 make s Side
7 make b Base with team = s
8 act b TrainWorker
9 expect done
10 expect s.Ore = 0 from content: the side's 50 less the worker's 50
11 expect s.Supply = 1 from content: the worker's Food 1
12 find w Worker
13 expect w.team = s
14 expect w.base = b
15 act b TrainWorker
16 expect refused CannotAfford need 50 have 0 from content: the worker's 50 against the bank's 0
17 save
18 deal 40 to w
19 expect w gone
20 expect s.Supply = 0 from content: 1 less the worker's 1, given back at its death
22play "two bases of one side train from one bank; at the cap, a train is refused in words"
23 make s Side
24 make b1 Base with team = s
25 make b2 Base with team = s
26 set s.Ore = 100
27 set s.Supply = 29
28 act b1 TrainWorker
29 expect done
30 expect s.Ore = 50 from content: 100 less 50
31 act b2 TrainWorker
32 expect refused Requirement "not enough supply"
33 expect s.Ore = 50 from content: nothing paid

Run it yourself

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