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>
64 lines
2.3 KiB
Text
64 lines
2.3 KiB
Text
# run.ludic - `dt` real seconds of a line in the water: the wait, the bite, and the fight
|
|
function fishing_run_wait(fishing_st: mut FishingState) -> void {
|
|
if fishing_st.fishing_t >= 0.0 { return }
|
|
fishing_st.fishing_st = FISHING_BITE_ON
|
|
fishing_st.fishing_t = 1.6
|
|
fishing_st.fishing_sp = fishing_pick(fishing_st)
|
|
fishing_say(fishing_st, FISHING_BITE)
|
|
}
|
|
|
|
# a fish that runs: the marker is all over the bar and nothing done with it helps
|
|
function fishing_run_runs(fishing_st: mut FishingState, dt: float) -> float {
|
|
let k = FishSpecies[fishing_st.fishing_sp]
|
|
if fishing_st.fishing_run_t > 0.0 {
|
|
fishing_st.fishing_run_t = fishing_st.fishing_run_t - dt
|
|
if fishing_st.fishing_run_t <= 0.0 {
|
|
fishing_st.fishing_run_t = 0.0
|
|
fishing_say(fishing_st, FISHING_TIRED)
|
|
}
|
|
return 4.2
|
|
}
|
|
if fishing_st.fishing_run_left > 0 {
|
|
fishing_st.fishing_run_next = fishing_st.fishing_run_next - dt
|
|
if fishing_st.fishing_run_next <= 0.0 {
|
|
fishing_st.fishing_run_left -= 1
|
|
fishing_st.fishing_run_t = 2.2
|
|
fishing_st.fishing_run_next = 4.0 + fishing_rand(fishing_st) * 4.0
|
|
fishing_say(fishing_st, FISHING_RUNS)
|
|
}
|
|
}
|
|
return k.speed + k.speed_per_hit * float(fishing_st.fishing_won)
|
|
}
|
|
|
|
function fishing_run_reel(fishing_st: mut FishingState, dt: float) -> void {
|
|
let sp = fishing_run_runs(fishing_st, dt)
|
|
if fishing_st.fishing_gentle_on {
|
|
fishing_st.fishing_ring_t = fishing_st.fishing_ring_t - dt
|
|
if fishing_st.fishing_ring_t <= 0.0 { fishing_lost(fishing_st, FISHING_LINE_SNAPPED) }
|
|
return
|
|
}
|
|
fishing_st.fishing_mark = fishing_st.fishing_mark + sp * fishing_st.fishing_dir * dt
|
|
if fishing_st.fishing_mark > 1.0 {
|
|
fishing_st.fishing_mark = 1.0
|
|
fishing_st.fishing_dir = -1.0
|
|
}
|
|
if fishing_st.fishing_mark < 0.0 {
|
|
fishing_st.fishing_mark = 0.0
|
|
fishing_st.fishing_dir = 1.0
|
|
}
|
|
if fishing_st.fishing_t < 0.0 { fishing_lost(fishing_st, FISHING_SLACK) }
|
|
}
|
|
|
|
export function fishing_run(fishing_st: mut FishingState, dt: float) -> void {
|
|
if fishing_st.fishing_st == FISHING_OFF { return }
|
|
fishing_st.fishing_t = fishing_st.fishing_t - dt
|
|
if fishing_st.fishing_st == FISHING_WAIT {
|
|
fishing_run_wait(fishing_st)
|
|
return
|
|
}
|
|
if fishing_st.fishing_st == FISHING_BITE_ON {
|
|
if fishing_st.fishing_t < 0.0 { fishing_lost(fishing_st, FISHING_MISSED) }
|
|
return
|
|
}
|
|
fishing_run_reel(fishing_st, dt)
|
|
}
|