wip(0.S3): packages and examples migrated in one run - ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 15:02:45 +03:00
parent d490d4f9f1
commit 3eda72e8c2
172 changed files with 3094 additions and 2966 deletions

View file

@ -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(gameplayfoundation_st: GameplayfoundationState) {
if amount > 100 { cancel }
if enraged == 1 { Combat.set_amount(amount / 2) }
if gameplayfoundation_st.enraged == 1 { Combat.set_amount(amount / 2) }
}
var deaths: int = 0
@On(Died) handler Tally { deaths += 1 }
@On(Died) handler Tally(gameplayfoundation_st: mut GameplayfoundationState) { gameplayfoundation_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 (gameplayfoundation_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
gameplayfoundation_st.enraged = 1
print(Combat.damage(t, a, 20)) # 7
enraged = 0
gameplayfoundation_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(gameplayfoundation_st.deaths) # 1
quit()
}