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
|
|
@ -1,26 +1,26 @@
|
|||
# verbs.ludic - the only way the ring changes. The same kind from the same label replaces
|
||||
# itself; a bonus past the cap pushes out the oldest bonus; a full ring drops the nearest end.
|
||||
function ef_end(i: int, why: int) -> void {
|
||||
let all = ef_all()
|
||||
function ef_end(base_st: mut BaseState, effects_st: mut EffectsState, i: int, why: int) -> void {
|
||||
let all = ef_all(effects_st)
|
||||
let e = new EffectEnded
|
||||
e.kind = all[i].kind
|
||||
e.label = all[i].label
|
||||
e.why = why
|
||||
e.bonus = all[i].bonus
|
||||
q_push(effects_ended(), e)
|
||||
ef_drop(i)
|
||||
q_push(base_st, effects_ended(base_st, effects_st), e)
|
||||
ef_drop(effects_st, i)
|
||||
}
|
||||
|
||||
function ef_drop(i: int) -> void {
|
||||
let all = ef_all()
|
||||
function ef_drop(effects_st: mut EffectsState, i: int) -> void {
|
||||
let all = ef_all(effects_st)
|
||||
let rest = new []Effect
|
||||
for k in 0 .. len(all) { if k != i { push(rest, all[k]) } }
|
||||
ef_list = rest
|
||||
effects_st.ef_list = rest
|
||||
}
|
||||
|
||||
# the one with the least time left (of the bonuses only, when asked); -1 when there is none
|
||||
function ef_nearest_end(bonus_only: bool) -> int {
|
||||
let all = ef_all()
|
||||
function ef_nearest_end(effects_st: mut EffectsState, bonus_only: bool) -> int {
|
||||
let all = ef_all(effects_st)
|
||||
var at = -1
|
||||
for i in 0 .. len(all) {
|
||||
if bonus_only and not all[i].bonus { continue }
|
||||
|
|
@ -29,16 +29,16 @@ function ef_nearest_end(bonus_only: bool) -> int {
|
|||
return at
|
||||
}
|
||||
|
||||
function ef_make_room(bonus: bool) -> void {
|
||||
function ef_make_room(base_st: mut BaseState, effects_st: mut EffectsState, bonus: bool) -> void {
|
||||
if bonus {
|
||||
while effects_bonus_count() >= ef_bonus_max and ef_nearest_end(true) >= 0 { ef_end(ef_nearest_end(true), EFFECT_PUSHED_OUT) }
|
||||
while effects_bonus_count(effects_st) >= effects_st.ef_bonus_max and ef_nearest_end(effects_st, true) >= 0 { ef_end(base_st, effects_st, ef_nearest_end(effects_st, true), EFFECT_PUSHED_OUT) }
|
||||
}
|
||||
if len(ef_all()) >= ef_max and ef_nearest_end(false) >= 0 { ef_end(ef_nearest_end(false), EFFECT_CROWDED_OUT) }
|
||||
if len(ef_all(effects_st)) >= effects_st.ef_max and ef_nearest_end(effects_st, false) >= 0 { ef_end(base_st, effects_st, ef_nearest_end(effects_st, false), EFFECT_CROWDED_OUT) }
|
||||
}
|
||||
|
||||
# begin one `after` game minutes from now, lasting `minutes` once it has begun
|
||||
export function effects_add_after(after: float, kind: int, mag: float, minutes: float, bonus: bool, label: string) -> void {
|
||||
let all = ef_all()
|
||||
export function effects_add_after(base_st: mut BaseState, effects_st: mut EffectsState, after: float, kind: int, mag: float, minutes: float, bonus: bool, label: string) -> void {
|
||||
let all = ef_all(effects_st)
|
||||
for i in 0 .. len(all) {
|
||||
if all[i].kind == kind and all[i].label == label {
|
||||
all[i].mag = mag
|
||||
|
|
@ -46,7 +46,7 @@ export function effects_add_after(after: float, kind: int, mag: float, minutes:
|
|||
return
|
||||
}
|
||||
}
|
||||
ef_make_room(bonus)
|
||||
ef_make_room(base_st, effects_st, bonus)
|
||||
let e = new Effect
|
||||
e.kind = kind
|
||||
e.mag = mag
|
||||
|
|
@ -54,27 +54,27 @@ export function effects_add_after(after: float, kind: int, mag: float, minutes:
|
|||
e.delay = after
|
||||
e.bonus = bonus
|
||||
e.label = label
|
||||
push(ef_all(), e)
|
||||
push(ef_all(effects_st), e)
|
||||
}
|
||||
|
||||
export function effects_add(kind: int, mag: float, minutes: float, bonus: bool, label: string) -> void {
|
||||
effects_add_after(0.0, kind, mag, minutes, bonus, label)
|
||||
export function effects_add(base_st: mut BaseState, effects_st: mut EffectsState, kind: int, mag: float, minutes: float, bonus: bool, label: string) -> void {
|
||||
effects_add_after(base_st, effects_st, 0.0, kind, mag, minutes, bonus, label)
|
||||
}
|
||||
|
||||
# everything stops at once, and says nothing: a new trip or a night's sleep
|
||||
export function effects_clear() -> void { ef_list = new []Effect }
|
||||
export function effects_clear(effects_st: mut EffectsState) -> void { effects_st.ef_list = new []Effect }
|
||||
|
||||
# run them down by `minutes` of game time; a delayed one waits first
|
||||
export function effects_run(minutes: float) -> void {
|
||||
export function effects_run(base_st: mut BaseState, effects_st: mut EffectsState, minutes: float) -> void {
|
||||
var i = 0
|
||||
while i < len(ef_all()) {
|
||||
let e = ef_all()[i]
|
||||
while i < len(ef_all(effects_st)) {
|
||||
let e = ef_all(effects_st)[i]
|
||||
if e.delay > 0.0 {
|
||||
e.delay = e.delay - minutes
|
||||
i += 1
|
||||
continue
|
||||
}
|
||||
e.left = e.left - minutes
|
||||
if e.left < 0.0 { ef_end(i, EFFECT_RAN_OUT) } else { i += 1 }
|
||||
if e.left < 0.0 { ef_end(base_st, effects_st, i, EFFECT_RAN_OUT) } else { i += 1 }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue