ludic/packages/ludic.photo/system.ludic
Orkuncakilkaya 71735b10a2 feat(base): 0.R4 - a queue keeps its own count, so every package verb takes only its own state; ludic migrate state --prune
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>
2026-09-26 04:19:56 +03:00

62 lines
2.3 KiB
Text

# system.ludic - the camera as a system: the roll and what has been photographed in its own save
# section, by key. The best per subject follows from the frames, as a buyer would judge them.
export function photo_config(photo_st: mut PhotoState, max: int) -> void {
photo_st.pht_max = Math.max(max, 1)
photo_reset(photo_st)
}
export function photo_reset(photo_st: mut PhotoState) -> void {
pht_blank(photo_st)
photo_st.pht_species_shot = 0
photo_st.pht_legend_shot = 0
photo_st.pht_cover = -1
photo_st.pht_page = 0
photo_frame_begin(photo_st)
q_clear(photo_facts(photo_st))
}
export function photo_save(photo_st: PhotoState) -> Val {
let v = Value.object()
let l = Value.list()
for i in 0 .. photo_st.pht_n {
let o = Value.object()
sv_put_int(o, "day", photo_st.pht_day[i])
sv_put_float(o, "hour", photo_st.pht_hour[i])
sv_put_int(o, "mask", photo_st.pht_mask[i])
sv_put_int(o, "legend", photo_st.pht_legend[i])
sv_put_bool(o, "sold", photo_st.pht_sold[i] != 0)
sv_put_str(o, "tags", photo_st.pht_tags[i])
sv_put_str(o, "file", photo_st.pht_file[i])
sv_put_int(o, "grade", photo_st.pht_grade[i])
sv_put_int(o, "why", photo_st.pht_why[i])
Value.add(l, o)
}
Value.put(v, "frames", l)
sv_put_int(v, "shot", photo_st.pht_species_shot)
sv_put_int(v, "legend_shot", photo_st.pht_legend_shot)
sv_put_int(v, "cover", photo_st.pht_cover)
sv_put_int(v, "sort", photo_st.pht_sort)
return v
}
export function photo_load(photo_st: mut PhotoState, v: Val, version: int) -> void {
photo_reset(photo_st)
if Value.has(v, "frames") != 0 {
let l = Value.get(v, "frames")
for i in 0 .. Value.count(l) {
let o = Value.at(l, i)
photo_add(photo_st, sv_int(o, "day", 1), sv_float(o, "hour", 0.0), sv_int(o, "mask", 0), sv_int(o, "legend", 0), sv_bool(o, "sold", false), sv_str(o, "tags", ""), sv_str(o, "file", ""), sv_int(o, "grade", 40), sv_int(o, "why", PHOTO_WHY_NONE))
}
}
photo_record_set(photo_st, photo_st.pht_species_shot | sv_int(v, "shot", 0), sv_int(v, "legend_shot", 0))
photo_st.pht_cover = sv_int(v, "cover", -1)
photo_sort_set(photo_st, sv_int(v, "sort", PHOTO_NEWEST))
}
export function photo_system() -> System {
let s = system_new("photo", PH_COMMIT)
s.reset = fn photo_reset
s.save = fn photo_save
s.load = fn photo_load
return s
}