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>
38 lines
1.4 KiB
Text
38 lines
1.4 KiB
Text
# system.ludic - vehicles as a system: a reset, and this player's own saved by kind (hired or not,
|
|
# and the horse's hay); where they lie is not saved - they are called again. The idle boats' bob is
|
|
# vehicles_tick, which the game calls where the world is run
|
|
export function vehicles_reset(vehicles_st: mut VehiclesState) -> void {
|
|
vehicles_st.ve_list = new []Vehicle
|
|
vehicles_st.ve_cur = null
|
|
vehicles_st.ve_have_dock = false
|
|
vehicles_st.ve_swell_said = 0.0
|
|
vehicles_st.ve_kept_horse = false
|
|
vehicles_st.ve_kept_boat = false
|
|
vehicles_st.ve_kept_food = 40.0
|
|
q_clear(vehicle_facts(vehicles_st))
|
|
}
|
|
|
|
export function vehicles_save(vehicles_st: mut VehiclesState) -> Val {
|
|
let v = Value.object()
|
|
let h = vehicle_find(vehicles_st, VEHICLE_HORSE)
|
|
let b = vehicle_find(vehicles_st, VEHICLE_BOAT)
|
|
if h != null {
|
|
sv_put_bool(v, "horse_own", h.owned)
|
|
sv_put_float(v, "horse_food", h.food)
|
|
}
|
|
if b != null { sv_put_bool(v, "boat_own", b.owned) }
|
|
return v
|
|
}
|
|
|
|
export function vehicles_load(vehicles_st: mut VehiclesState, v: Val, version: int) -> void {
|
|
vehicle_drop(vehicles_st)
|
|
vehicle_restore(vehicles_st, VEHICLE_HORSE, sv_bool(v, "horse_own", false), sv_float(v, "horse_food", 40.0))
|
|
vehicle_restore(vehicles_st, VEHICLE_BOAT, sv_bool(v, "boat_own", false), 0.0)
|
|
}
|
|
|
|
export function vehicles_system() -> System {
|
|
let s = system_new("vehicles", PH_SIMULATE)
|
|
s.save = fn vehicles_save
|
|
s.load = fn vehicles_load
|
|
return s
|
|
}
|