ludic/packages/ludic.fishing/facts.ludic
Orkuncakilkaya 36358e7a43 fix(ludic.fishing): fact records pooled (the ludic.wildlife idiom) - a record made per cast, bite and crossing was never given back
tests: fifty fish, their facts drained each time, make 5 records.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 13:17:12 +03:00

19 lines
1,008 B
Text

# facts.ludic - a fishing fact's record: one no drain holds any more, made fresh (and kept) only when
# every one is held. A cast, a bite, every crossing and run of a fight is a fact, and a record a fact
# is never given back (the ludic.wildlife idiom, facts.ludic there)
function fishing_fact_record(fishing_st: mut FishingState) -> FishingFact {
if fishing_st.fishing_fnext[0] >= len(fishing_st.fishing_ffree) {
q_unheld(fishing_st.fishing_fact_q, fishing_st.fishing_fpool, fishing_st.fishing_ffree)
fishing_st.fishing_fnext[0] = 0
}
if fishing_st.fishing_fnext[0] < len(fishing_st.fishing_ffree) {
let f = fishing_st.fishing_ffree[fishing_st.fishing_fnext[0]]
fishing_st.fishing_fnext[0] += 1
return f
}
let f = new FishingFact
push(fishing_st.fishing_fpool, f)
return f
}
# how many fact records have ever been made: the peak held at once, not the facts said
export function fishing_fact_records(fishing_st: FishingState) -> int { return len(fishing_st.fishing_fpool) }