feat(packages): ludic.gear - kinds of kit with tiers bought flat through a purse port once the standing is there, the kind's item following, per-tier values and mults, stack limits, the hand and charges that burn by the game hour, facts for a tier bought and a charge run out, a save section by key
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
79ed7a335b
commit
cc930a114f
11 changed files with 569 additions and 0 deletions
25
packages/ludic.gear/buy.ludic
Normal file
25
packages/ludic.gear/buy.ludic
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# buy.ludic - a tier bought with money once the standing is there; the kind's item follows
|
||||
export function gear_can_buy(k: int) -> bool {
|
||||
if not gear_ok(k) or gear_best(k) or GearWorld.hidden(k) { return false }
|
||||
return GearPurse.rep() >= gear_next_rep(k) and GearPurse.money() >= gear_next_cost(k)
|
||||
}
|
||||
|
||||
export function gear_buy(k: int) -> bool {
|
||||
if not gear_can_buy(k) { return false }
|
||||
let cost = gear_next_cost(k)
|
||||
if not GearPurse.spend(cost) { return false }
|
||||
gear__lv[k] += 1
|
||||
let it = GearKinds[k].item
|
||||
if it >= 0 and GearPack.count(it) == 0 { GearPack.add(it, 1) }
|
||||
gear__fact(GEAR_BOUGHT, k, -1, cost)
|
||||
return true
|
||||
}
|
||||
|
||||
# a kind whose item is already carried counts as its first tier
|
||||
export function gear_sync() -> void {
|
||||
gear__ensure()
|
||||
for k in 0 .. GEAR_COUNT {
|
||||
let it = GearKinds[k].item
|
||||
if it >= 0 and gear__lv[k] == 0 and GearPack.count(it) > 0 { gear__lv[k] = 1 }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue