ludic.base's Queue<T> carries a QueueTag (its name and pending count): queue_new(name), q_push(q, v), q_drain(q), q_clear(q) take no BaseState, and core_undrained(tags) names the given queues still holding facts. A reducer on a package's state can now call that package's verbs (wallet_earn(wallet_st, n)). ludic migrate state --prune (ludicc --migrate-prune) takes out each state parameter a function no longer uses, nor anything it calls, and the argument that fills it - including an argument for a parameter the callee has dropped, which is taken out before the call is checked, so a generic's T is told by the argument that says it. A reducer keeps its state. --dry-run now counts the edits it would make. Every package was moved with it: 608 base_st parameters and their arguments, 1889 edits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.6 KiB
Text
44 lines
1.6 KiB
Text
# system.ludic - the wildlife as a system: its save section is this player's record (the species
|
|
# seen and fed) and which ranges they have found; the animals themselves are respawned with the
|
|
# valley, so a reset forgets the record and nothing else
|
|
export function wildlife_reset(wildlife_st: mut WildlifeState) -> void {
|
|
wl_record_reset(wildlife_st)
|
|
wildlife_st.wl_found = null
|
|
let rs = wildlife_ranges(wildlife_st)
|
|
for i in 0 .. len(rs) { rs[i].found = false }
|
|
q_clear(wildlife_facts(wildlife_st))
|
|
}
|
|
|
|
export function wildlife_save(wildlife_st: mut WildlifeState) -> Val {
|
|
let v = Value.object()
|
|
sv_put_int(v, "seen", wildlife_st.wl_seen)
|
|
sv_put_int(v, "fed", wildlife_st.wl_fed)
|
|
sv_put_bool(v, "fed_any", wildlife_st.wl_fed_any)
|
|
let found = new []int
|
|
let rs = wildlife_ranges(wildlife_st)
|
|
for i in 0 .. len(rs) {
|
|
var f = 0
|
|
if rs[i].found { f = 1 }
|
|
push(found, f)
|
|
}
|
|
sv_put_ints(v, "found", found)
|
|
return v
|
|
}
|
|
|
|
export function wildlife_load(wildlife_st: mut WildlifeState, v: Val, version: int) -> void {
|
|
wildlife_reset(wildlife_st)
|
|
wildlife_st.wl_seen = sv_int(v, "seen", 0)
|
|
wildlife_st.wl_fed = sv_int(v, "fed", 0)
|
|
wildlife_st.wl_fed_any = sv_bool(v, "fed_any", false)
|
|
wildlife_st.wl_found = sv_ints(v, "found")
|
|
wl_found_apply(wildlife_st)
|
|
}
|
|
|
|
# PH_SIMULATE with no tick of its own: the game steps it (wildlife_tick) where the world is owned
|
|
export function wildlife_system() -> System {
|
|
let s = system_new("wildlife", PH_SIMULATE)
|
|
s.reset = fn wildlife_reset
|
|
s.save = fn wildlife_save
|
|
s.load = fn wildlife_load
|
|
return s
|
|
}
|