ludic/packages/ludic.hints/mute.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

60 lines
2.1 KiB
Text

# mute.ludic - the cards a player has said they know, kept BY KEY: a card added, removed or moved in
# the registry leaves every other mute where it was, and a key this build does not know is carried
function hn_mute_ensure(hints_st: mut HintsState) -> void {
if hints_st.hn_mute != null { return }
hints_st.hn_mute = new []bool
for i in 0 .. HINT_COUNT { push(hints_st.hn_mute, false) }
hints_st.hn_foreign = new []string
}
export function hints_muted(hints_st: mut HintsState, id: int) -> bool {
hn_mute_ensure(hints_st)
if id < 0 or id >= HINT_COUNT { return false }
return hints_st.hn_mute[id]
}
export function hints_mute(hints_st: mut HintsState, id: int, on: bool) -> void {
hn_mute_ensure(hints_st)
if id < 0 or id >= HINT_COUNT { return }
hints_st.hn_mute[id] = on
}
export function hints_mute_count(hints_st: mut HintsState) -> int {
hn_mute_ensure(hints_st)
var n = 0
for i in 0 .. HINT_COUNT { if hints_st.hn_mute[i] { n += 1 } }
return n
}
# every muted card given back, from the next pass
export function hints_unmute_all(hints_st: mut HintsState) -> void {
hn_mute_ensure(hints_st)
for i in 0 .. HINT_COUNT { hints_st.hn_mute[i] = false }
hints_st.hn_foreign = new []string
hints_st.hn_t = 0.0
hn_fact(hints_st, HINTS_F_UNMUTED, -1)
}
# the mutes as a list of keys, for wherever the game keeps the player's own choices
export function hints_mutes_save(hints_st: mut HintsState) -> Val {
hn_mute_ensure(hints_st)
let l = Value.list()
for i in 0 .. HINT_COUNT { if hints_st.hn_mute[i] { Value.add(l, Value.str(Hints[i].key)) } }
for i in 0 .. len(hints_st.hn_foreign) { Value.add(l, Value.str(hints_st.hn_foreign[i])) }
return l
}
# a list of keys read back; anything that is not a list is no mutes
export function hints_mutes_load(hints_st: mut HintsState, l: Val) -> void {
hints_st.hn_mute = null
hn_mute_ensure(hints_st)
if l == null or Value.kind(l) != 5 { return }
for i in 0 .. Value.count(l) {
let e = Value.at(l, i)
if Value.kind(e) != 4 { continue }
let k = Value.as_str(e)
let id = hints_find(k)
if id >= 0 { hints_st.hn_mute[id] = true } else { push(hints_st.hn_foreign, k) }
}
}