ludic.things: a Thing's dawn (the last day a restock reached it, saved); things_restock takes the day; things_catch_up restocks a chunk's Things that missed a dawn once a morning would reach them, as that morning would have

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-29 21:14:42 +03:00
parent 0634116d59
commit b053bf625c
7 changed files with 57 additions and 8 deletions

View file

@ -16,6 +16,20 @@ export function things_drop_chunk(things_st: mut ThingsState, chunk: int) -> int
return n
}
# the chunk's Things that missed a dawn and a morning would now reach, restocked as that morning
# would have (no dice: a restock rolls none) and filed into the caller's list; how many
export function things_catch_up(things_st: ThingsState, chunk: int, day: int, out: []Thing) -> int {
List.clear(out)
let rows = ix_rows(things_st.th.chunks, chunk)
for i in 0 .. len(rows) {
let t = things_st.th.tab.rec[rows[i]]
if t.dawn >= day or thing_is_put_down(t) or not ThingsWorld.restocks(t.x, t.z) { continue }
th_restock_one(t, day)
kept_push(out, t)
}
return len(out)
}
# change detection: the tick now, the table moving on to the next - a consumer keeps what this
# returned and asks things_changed(since: it) for what was written after
export function things_now(things_st: mut ThingsState) -> int {