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>
105 lines
4 KiB
Text
105 lines
4 KiB
Text
# verbs.ludic - casting, the one button (reel in, strike, reel), landing and putting the rod away
|
|
export const FISHING_CAST_OK: int = 0
|
|
export const FISHING_NOT_WATER: int = 1
|
|
export const FISHING_BUSY: int = 2
|
|
|
|
# a line into (x, z): bait halves the wait (and is a fact, for the game to take from the pack)
|
|
export function fishing_cast(fishing_st: mut FishingState, x: float, z: float) -> int {
|
|
if fishing_st.fishing_st != FISHING_OFF { return FISHING_BUSY }
|
|
fishing_st.fishing_bx = x
|
|
fishing_st.fishing_bz = z
|
|
if not fishing_water_at(fishing_st, x, z) { return FISHING_NOT_WATER }
|
|
fishing_st.fishing_st = FISHING_WAIT
|
|
fishing_st.fishing_sp = -1
|
|
fishing_st.fishing_len = 0
|
|
fishing_st.fishing_lure_on = FishingWorld.has_lure()
|
|
fishing_st.fishing_bait_on = FishingWorld.has_bait()
|
|
var wait = 6.0 + fishing_rand(fishing_st) * 14.0
|
|
if fishing_st.fishing_bait_on { wait = wait * 0.5 }
|
|
fishing_st.fishing_t = wait * FishingWorld.bite_mult()
|
|
if fishing_st.fishing_bait_on { fishing_say(fishing_st, FISHING_BAIT_USED) }
|
|
fishing_say(fishing_st, FISHING_CAST)
|
|
return FISHING_CAST_OK
|
|
}
|
|
|
|
# the bite comes exactly `secs` after now (staging, footage)
|
|
export function fishing_set_wait(fishing_st: mut FishingState, secs: float) -> void {
|
|
if fishing_st.fishing_st == FISHING_WAIT { fishing_st.fishing_t = secs }
|
|
}
|
|
|
|
export function fishing_stop(fishing_st: mut FishingState) -> void {
|
|
fishing_st.fishing_st = FISHING_OFF
|
|
fishing_st.fishing_run_t = 0.0
|
|
}
|
|
|
|
function fishing_strike(fishing_st: mut FishingState) -> void {
|
|
let k = FishSpecies[fishing_st.fishing_sp]
|
|
fishing_st.fishing_st = FISHING_REEL
|
|
fishing_st.fishing_won = 0
|
|
fishing_st.fishing_mark = 0.0
|
|
fishing_st.fishing_dir = 1.0
|
|
fishing_st.fishing_t = k.fight
|
|
fishing_st.fishing_need_n = k.need
|
|
fishing_st.fishing_run_t = 0.0
|
|
fishing_st.fishing_run_left = k.runs
|
|
fishing_st.fishing_run_next = 3.0 + fishing_rand(fishing_st) * 3.0
|
|
fishing_st.fishing_len = fishing_size(fishing_st, fishing_st.fishing_sp)
|
|
fishing_st.fishing_gentle_on = FishingWorld.level() == FISHING_GENTLE and not k.legend
|
|
fishing_st.fishing_ring_t = 0.0
|
|
if fishing_st.fishing_gentle_on {
|
|
fishing_st.fishing_need_n = 1
|
|
fishing_st.fishing_ring_t = 2.0
|
|
}
|
|
fishing_new_window(fishing_st)
|
|
fishing_say(fishing_st, FISHING_HOOKED)
|
|
}
|
|
|
|
function fishing_land(fishing_st: mut FishingState) -> void {
|
|
fishing_st.fishing_n += 1
|
|
if fishing_st.fishing_len > fishing_st.fishing_big { fishing_st.fishing_big = fishing_st.fishing_len }
|
|
if FishSpecies[fishing_st.fishing_sp].legend { fishing_st.fishing_leg = true }
|
|
fishing_say(fishing_st, FISHING_CAUGHT)
|
|
fishing_stop(fishing_st)
|
|
}
|
|
|
|
function fishing_lost(fishing_st: mut FishingState, what: int) -> void {
|
|
fishing_say(fishing_st, what)
|
|
fishing_stop(fishing_st)
|
|
}
|
|
|
|
function fishing_reel_press(fishing_st: mut FishingState) -> void {
|
|
if fishing_st.fishing_gentle_on {
|
|
if fishing_st.fishing_ring_t > 0.0 { fishing_land(fishing_st) } else { fishing_lost(fishing_st, FISHING_LINE_SNAPPED) }
|
|
return
|
|
}
|
|
if fishing_st.fishing_run_t > 0.0 {
|
|
fishing_st.fishing_won = Math.max(fishing_st.fishing_won - 1, 0)
|
|
fishing_say(fishing_st, FISHING_CHECKED)
|
|
return
|
|
}
|
|
if fishing_in_window(fishing_st) {
|
|
fishing_st.fishing_won += 1
|
|
fishing_new_window(fishing_st)
|
|
if fishing_st.fishing_won >= fishing_st.fishing_need_n { fishing_land(fishing_st) } else { fishing_say(fishing_st, FISHING_GOOD) }
|
|
return
|
|
}
|
|
if FishSpecies[fishing_st.fishing_sp].legend and fishing_st.fishing_won > 0 {
|
|
fishing_st.fishing_won -= 1
|
|
fishing_say(fishing_st, FISHING_TURNED)
|
|
return
|
|
}
|
|
fishing_lost(fishing_st, FISHING_LINE_SNAPPED)
|
|
}
|
|
|
|
# the button: waiting it reels in, on a bite it strikes, on a fish it reels
|
|
export function fishing_press(fishing_st: mut FishingState) -> void {
|
|
if fishing_st.fishing_st == FISHING_WAIT {
|
|
fishing_lost(fishing_st, FISHING_REELED_IN)
|
|
return
|
|
}
|
|
if fishing_st.fishing_st == FISHING_BITE_ON {
|
|
fishing_strike(fishing_st)
|
|
return
|
|
}
|
|
if fishing_st.fishing_st == FISHING_REEL { fishing_reel_press(fishing_st) }
|
|
}
|