feat(packages): ludic.fishing - cast, bite, the reel's fight and the landing, species as an open registry, the record in its own save section, facts for bait, catch and a lost fish
A line is cast at a point the FishingWorld port says is water (depth, or afloat), bait (asked, then said as FISHING_BAIT_USED for the game to take) halves the wait, the bite picks a species - a legend only on a lure, likelier in deep water and with skill, else an everyday one by weight - and the fight is a marker, a green band that moves above Relaxed and closes on Hard or for a fish whose data says so, a Gentle ring of one press, and a legend's runs and the line it takes back. Length and weight come from FishSpecies data. The package never draws, speaks or touches a pack; every step is a FishingFact (CAUGHT, BAIT_USED, LINE_SNAPPED, SLACK, MISSED, ...). Its dice are its own Rng. A legend on Gentle fights as a legend (the old ring lost him at once). Uses ludic.base only; thirteen tests over a fake lake. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
12cfcb10ac
commit
80f3468ff8
11 changed files with 787 additions and 0 deletions
64
packages/ludic.fishing/run.ludic
Normal file
64
packages/ludic.fishing/run.ludic
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
# run.ludic - `dt` real seconds of a line in the water: the wait, the bite, and the fight
|
||||
function fishing_run_wait() -> void {
|
||||
if fishing_t >= 0.0 { return }
|
||||
fishing_st = FISHING_BITE_ON
|
||||
fishing_t = 1.6
|
||||
fishing_sp = fishing_pick()
|
||||
fishing_say(FISHING_BITE)
|
||||
}
|
||||
|
||||
# a fish that runs: the marker is all over the bar and nothing done with it helps
|
||||
function fishing_run_runs(dt: float) -> float {
|
||||
let k = FishSpecies[fishing_sp]
|
||||
if fishing_run_t > 0.0 {
|
||||
fishing_run_t = fishing_run_t - dt
|
||||
if fishing_run_t <= 0.0 {
|
||||
fishing_run_t = 0.0
|
||||
fishing_say(FISHING_TIRED)
|
||||
}
|
||||
return 4.2
|
||||
}
|
||||
if fishing_run_left > 0 {
|
||||
fishing_run_next = fishing_run_next - dt
|
||||
if fishing_run_next <= 0.0 {
|
||||
fishing_run_left -= 1
|
||||
fishing_run_t = 2.2
|
||||
fishing_run_next = 4.0 + fishing_rand() * 4.0
|
||||
fishing_say(FISHING_RUNS)
|
||||
}
|
||||
}
|
||||
return k.speed + k.speed_per_hit * float(fishing_won)
|
||||
}
|
||||
|
||||
function fishing_run_reel(dt: float) -> void {
|
||||
let sp = fishing_run_runs(dt)
|
||||
if fishing_gentle_on {
|
||||
fishing_ring_t = fishing_ring_t - dt
|
||||
if fishing_ring_t <= 0.0 { fishing_lost(FISHING_LINE_SNAPPED) }
|
||||
return
|
||||
}
|
||||
fishing_mark = fishing_mark + sp * fishing_dir * dt
|
||||
if fishing_mark > 1.0 {
|
||||
fishing_mark = 1.0
|
||||
fishing_dir = -1.0
|
||||
}
|
||||
if fishing_mark < 0.0 {
|
||||
fishing_mark = 0.0
|
||||
fishing_dir = 1.0
|
||||
}
|
||||
if fishing_t < 0.0 { fishing_lost(FISHING_SLACK) }
|
||||
}
|
||||
|
||||
export function fishing_run(dt: float) -> void {
|
||||
if fishing_st == FISHING_OFF { return }
|
||||
fishing_t = fishing_t - dt
|
||||
if fishing_st == FISHING_WAIT {
|
||||
fishing_run_wait()
|
||||
return
|
||||
}
|
||||
if fishing_st == FISHING_BITE_ON {
|
||||
if fishing_t < 0.0 { fishing_lost(FISHING_MISSED) }
|
||||
return
|
||||
}
|
||||
fishing_run_reel(dt)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue