wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3eda72e8c2
commit
5ffe50ed02
463 changed files with 72045 additions and 67421 deletions
|
|
@ -17,21 +17,19 @@ 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.
|
||||
state GameplayfoundationState {
|
||||
enraged: int = 0
|
||||
deaths: int = 0
|
||||
}
|
||||
@On(DamageAboutToApply) handler Ward(gameplayfoundation_st: GameplayfoundationState) {
|
||||
var enraged: int = 0
|
||||
@On(DamageAboutToApply) handler Ward {
|
||||
if amount > 100 { cancel }
|
||||
if gameplayfoundation_st.enraged == 1 { Combat.set_amount(amount / 2) }
|
||||
if enraged == 1 { Combat.set_amount(amount / 2) }
|
||||
}
|
||||
|
||||
@On(Died) handler Tally(gameplayfoundation_st: mut GameplayfoundationState) { gameplayfoundation_st.deaths += 1 }
|
||||
var deaths: int = 0
|
||||
@On(Died) handler Tally { 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 (gameplayfoundation_st: mut GameplayfoundationState) {
|
||||
entry {
|
||||
let PS = World.prop_id("Stats")
|
||||
let fhp = World.field_id(PS, "hp")
|
||||
let fatk = World.field_id(PS, "atk")
|
||||
|
|
@ -67,9 +65,9 @@ program GameplayFoundation {
|
|||
print(World.get(t, PS, fhp)) # 85
|
||||
|
||||
# mutable hook: enrage halves the next hit ((20 - 5) -> 7)
|
||||
gameplayfoundation_st.enraged = 1
|
||||
enraged = 1
|
||||
print(Combat.damage(t, a, 20)) # 7
|
||||
gameplayfoundation_st.enraged = 0
|
||||
enraged = 0
|
||||
|
||||
# veto hook: an over-100 hit is cancelled (0 applied)
|
||||
print(bi(Combat.damage(t, a, 200) == 0)) # 1
|
||||
|
|
@ -77,7 +75,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(gameplayfoundation_st.deaths) # 1
|
||||
print(deaths) # 1
|
||||
|
||||
quit()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue