wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run
ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic 1804 vars into 126 states, 64 into lets; 23498 edits in 460 files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5ffe50ed02
commit
19fcf60599
459 changed files with 17862 additions and 17603 deletions
|
|
@ -17,19 +17,21 @@ program GameplayFoundation {
|
|||
# a game-supplied policy: while "enraged" is set, halve incoming damage by
|
||||
# rewriting the pending amount (lever 6, the mutable hook), and hard-veto any
|
||||
# hit over 100 (lever 4, cancel). Both are just listeners — no engine fork.
|
||||
var enraged: int = 0
|
||||
@On(DamageAboutToApply) handler Ward {
|
||||
state GameplayFoundationState {
|
||||
enraged: int = 0
|
||||
deaths: int = 0
|
||||
}
|
||||
@On(DamageAboutToApply) handler Ward(gameplay_foundation_st: GameplayFoundationState) {
|
||||
if amount > 100 { cancel }
|
||||
if enraged == 1 { Combat.set_amount(amount / 2) }
|
||||
if gameplay_foundation_st.enraged == 1 { Combat.set_amount(amount / 2) }
|
||||
}
|
||||
|
||||
var deaths: int = 0
|
||||
@On(Died) handler Tally { deaths += 1 }
|
||||
@On(Died) handler Tally(gameplay_foundation_st: mut GameplayFoundationState) { gameplay_foundation_st.deaths += 1 }
|
||||
|
||||
function tick_n(n: int) -> void { var i = 0; while i < n { tick_fixed(); i += 1 } }
|
||||
function bi(b: bool) -> int { if b { return 1 }; return 0 }
|
||||
|
||||
entry {
|
||||
entry (gameplay_foundation_st: mut GameplayFoundationState) {
|
||||
let PS = World.prop_id("Stats")
|
||||
let fhp = World.field_id(PS, "hp")
|
||||
let fatk = World.field_id(PS, "atk")
|
||||
|
|
@ -65,9 +67,9 @@ program GameplayFoundation {
|
|||
print(World.get(t, PS, fhp)) # 85
|
||||
|
||||
# mutable hook: enrage halves the next hit ((20 - 5) -> 7)
|
||||
enraged = 1
|
||||
gameplay_foundation_st.enraged = 1
|
||||
print(Combat.damage(t, a, 20)) # 7
|
||||
enraged = 0
|
||||
gameplay_foundation_st.enraged = 0
|
||||
|
||||
# veto hook: an over-100 hit is cancelled (0 applied)
|
||||
print(bi(Combat.damage(t, a, 200) == 0)) # 1
|
||||
|
|
@ -75,7 +77,7 @@ program GameplayFoundation {
|
|||
# finish it off with sub-100 hits so the veto never blocks the kill
|
||||
var guard = 0
|
||||
while (World.get(t, PS, fhp) > 0) and (guard < 100) { Combat.damage(t, a, 90); guard += 1 }
|
||||
print(deaths) # 1
|
||||
print(gameplay_foundation_st.deaths) # 1
|
||||
|
||||
quit()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue