ludic/packages/ludic.fishing/system.ludic
Orkuncakilkaya 80f3468ff8 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>
2026-09-25 06:53:14 +03:00

41 lines
1.2 KiB
Text

# system.ludic - fishing as a system: its tick, and the record in its own save section (a line in
# the water is never saved)
export function fishing_reset() -> void {
fishing_stop()
fishing_n = 0
fishing_big = 0
fishing_leg = false
fishing_dice = rng_new(fishing_seed_n)
q_clear(fishing_facts())
}
# the record outright (staging, a test, the network's word)
export function fishing_record_set(caught: int, biggest: int, legend: bool) -> void {
fishing_n = caught
fishing_big = biggest
fishing_leg = legend
}
export function fishing_save() -> Val {
let v = Value.object()
sv_put_int(v, "caught", fishing_n)
sv_put_int(v, "biggest", fishing_big)
sv_put_bool(v, "legend", fishing_leg)
return v
}
export function fishing_load(v: Val, version: int) -> void {
fishing_reset()
fishing_record_set(sv_int(v, "caught", 0), sv_int(v, "biggest", 0), sv_bool(v, "legend", false))
}
function fishing_sys_tick(t: Tick) -> void { fishing_run(t.dt) }
export function fishing_system() -> System {
let s = system_new("fishing", PH_SIMULATE)
s.reset = fn fishing_reset
s.tick = fn fishing_sys_tick
s.save = fn fishing_save
s.load = fn fishing_load
return s
}