Bank
A cost from a team's bank, and a supply cap
cost POOL N on holder.teamgain ... on holder.teamkind.STATA 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.
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 supply3
# that its every building trains from: a price is a cost on the side's bank, `on holder.team`, refused CannotAfford with4
# the bank's need and have; a unit's supply is held as it is ordered and given back at its death. The slice queues5
# each unit's training in its building's pile; that queue reads round an open language row, so here a unit is made6
# at once.8
rate 209
stat MaxHealth10
stat SupplyCap11
stat Food12
pool Health max MaxHealth13
pool Ore whole14
pool Supply whole15
damage Health16
link team base17
allegiance team18
tags Unit Building Base Worker19
event Died21
archetype Side22
base SupplyCap 3023
pools Ore Supply24
with Ore = 5026
effect Mortal27
dies at no Health raising Died28
after Died of holder29
if holder.Food > 030
lose Supply holder.Food on holder.team32
template ability Train(kind, price)33
requires holder.team.Supply + kind.Food <= holder.team.SupplyCap else "not enough supply"34
cost Ore price on holder.team35
gain Supply kind.Food on holder.team36
create kind with team = holder.team, base = holder38
ability TrainWorker from Train(Worker, 50)40
archetype Base41
tags Building Base42
base MaxHealth 150043
full Health44
has Mortal45
grants TrainWorker47
archetype Worker48
tags Unit Worker49
base MaxHealth 4050
base Food 151
full Health52
has Mortal1
catalog bank.ledger3
# The bank's numbers, from the Side (50 ore, a supply cap of 30), Train and the Worker (50 ore, 1 supply).5
play "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 Side7
make b Base with team = s8
act b TrainWorker9
expect done10
expect s.Ore = 0 from content: the side's 50 less the worker's 5011
expect s.Supply = 1 from content: the worker's Food 112
find w Worker13
expect w.team = s14
expect w.base = b15
act b TrainWorker16
expect refused CannotAfford need 50 have 0 from content: the worker's 50 against the bank's 017
save18
deal 40 to w19
expect w gone20
expect s.Supply = 0 from content: 1 less the worker's 1, given back at its death22
play "two bases of one side train from one bank; at the cap, a train is refused in words"23
make s Side24
make b1 Base with team = s25
make b2 Base with team = s26
set s.Ore = 10027
set s.Supply = 2928
act b1 TrainWorker29
expect done30
expect s.Ore = 50 from content: 100 less 5031
act b2 TrainWorker32
expect refused Requirement "not enough supply"33
expect s.Ore = 50 from content: nothing paidRun it yourself
ledger check content/cookbook/mechanics/bank.ledger content/cookbook/mechanics/bank.play
ledger play content/cookbook/mechanics/bank.play