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>
81 lines
3.6 KiB
Text
81 lines
3.6 KiB
Text
# keep.ludic - the frame onto the roll, and a frame off it
|
|
# The composed frame, kept as `file` on `day` at `hour`: the index, or -1 when the card is full.
|
|
# Every subject in it counts as photographed, and its best grade may rise.
|
|
export function photo_keep(photo_st: mut PhotoState, file: string, day: int, hour: float) -> int {
|
|
if photo_st.pht_n >= photo_st.pht_max {
|
|
pht_fact(photo_st, PHOTO_FULL, -1)
|
|
return -1
|
|
}
|
|
var firsts = 0
|
|
for sp in 0 .. 32 { if (photo_st.pht_pending_mask & (1 << sp)) != 0 and photo_st.pht_best[sp] == 0 { firsts = firsts | (1 << sp) } }
|
|
let i = photo_add(photo_st, day, hour, photo_st.pht_pending_mask, photo_st.pht_pending_legend, false, photo_st.pht_pending_tags, file, photo_st.pht_pending_grade, photo_st.pht_pending_why)
|
|
photo_st.pht_legend_shot = photo_st.pht_legend_shot | photo_st.pht_pending_legend
|
|
let f = pht_fact(photo_st, PHOTO_KEPT, i)
|
|
f.mask = photo_st.pht_pending_mask
|
|
f.legend = photo_st.pht_pending_legend
|
|
f.firsts = firsts
|
|
f.grade = photo_st.pht_pending_grade
|
|
f.sign = photo_st.pht_pending_sign
|
|
f.stars = photo_st.pht_pending_stars
|
|
f.file = file
|
|
f.tags = photo_st.pht_pending_tags
|
|
return i
|
|
}
|
|
|
|
# a frame onto the roll as it stands (a save, an older trip): the index, or -1 when full
|
|
export function photo_add(photo_st: mut PhotoState, day: int, hour: float, mask: int, legend: int, sold: bool, tags: string, file: string, grade: int, why: int) -> int {
|
|
if photo_st.pht_day == null { pht_blank(photo_st) }
|
|
if photo_st.pht_n >= photo_st.pht_max { return -1 }
|
|
let i = photo_st.pht_n
|
|
photo_st.pht_day[i] = day
|
|
photo_st.pht_hour[i] = hour
|
|
photo_st.pht_mask[i] = mask
|
|
photo_st.pht_legend[i] = legend
|
|
photo_st.pht_sold[i] = 0
|
|
if sold { photo_st.pht_sold[i] = 1 }
|
|
photo_st.pht_grade[i] = grade
|
|
photo_st.pht_why[i] = why
|
|
push(photo_st.pht_tags, tags)
|
|
push(photo_st.pht_file, file)
|
|
photo_st.pht_n += 1
|
|
photo_st.pht_species_shot = photo_st.pht_species_shot | mask
|
|
for sp in 0 .. 32 { if (mask & (1 << sp)) != 0 and grade > photo_st.pht_best[sp] { photo_st.pht_best[sp] = grade } }
|
|
return i
|
|
}
|
|
|
|
# forgetting one: the record goes, the ones after it close up, and the game is told the file
|
|
export function photo_remove(photo_st: mut PhotoState, i: int) -> void {
|
|
if i < 0 or i >= photo_st.pht_n { return }
|
|
let f = pht_fact(photo_st, PHOTO_DELETED, i)
|
|
f.file = photo_st.pht_file[i]
|
|
let tags = new []string
|
|
let files = new []string
|
|
for k in 0 .. photo_st.pht_n {
|
|
if k == i { continue }
|
|
push(tags, photo_st.pht_tags[k])
|
|
push(files, photo_st.pht_file[k])
|
|
}
|
|
for k in i .. photo_st.pht_n - 1 {
|
|
photo_st.pht_day[k] = photo_st.pht_day[k + 1]
|
|
photo_st.pht_hour[k] = photo_st.pht_hour[k + 1]
|
|
photo_st.pht_mask[k] = photo_st.pht_mask[k + 1]
|
|
photo_st.pht_legend[k] = photo_st.pht_legend[k + 1]
|
|
photo_st.pht_sold[k] = photo_st.pht_sold[k + 1]
|
|
photo_st.pht_grade[k] = photo_st.pht_grade[k + 1]
|
|
photo_st.pht_why[k] = photo_st.pht_why[k + 1]
|
|
}
|
|
photo_st.pht_tags = tags
|
|
photo_st.pht_file = files
|
|
photo_st.pht_n -= 1
|
|
if photo_st.pht_cover == i { photo_st.pht_cover = -1 } else if photo_st.pht_cover > i { photo_st.pht_cover -= 1 }
|
|
}
|
|
|
|
export function photo_cover_set(photo_st: mut PhotoState, i: int) -> void { photo_st.pht_cover = i }
|
|
|
|
# what has been photographed outright (a network's word, a staged trip)
|
|
export function photo_record_set(photo_st: mut PhotoState, species: int, legends: int) -> void {
|
|
photo_st.pht_species_shot = species
|
|
photo_st.pht_legend_shot = legends
|
|
}
|
|
|
|
export function photo_best_set(photo_st: mut PhotoState, sp: int, grade: int) -> void { if sp >= 0 and sp < 32 { photo_st.pht_best[sp] = grade } }
|