feat(packages): ludic.hints - a rail of things that are true now and can be acted on now: cards as an open registry (urgency, a glyph or an item's picture, the chip's line, three steps and how not to be here again) asked through a port whether each is true, the most urgent few once a pass in registry order within an urgency, a card opened off the rail, walked along it and put down when its subject stops being true, and "I know this" muting kept by the card's key (a key this build lacks is carried through); opened, closed, muted and unmuted as facts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1005a677f2
commit
fe9d28bf4e
12 changed files with 540 additions and 0 deletions
62
packages/ludic.hints/mute.ludic
Normal file
62
packages/ludic.hints/mute.ludic
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
# 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
|
||||
var hn_mute: []bool = null
|
||||
var hn_foreign: []string = null # muted keys with no card in this build, written back as read
|
||||
|
||||
function hn_mute_ensure() -> void {
|
||||
if hn_mute != null { return }
|
||||
hn_mute = new []bool
|
||||
for i in 0 .. HINT_COUNT { push(hn_mute, false) }
|
||||
hn_foreign = new []string
|
||||
}
|
||||
|
||||
export function hints_muted(id: int) -> bool {
|
||||
hn_mute_ensure()
|
||||
if id < 0 or id >= HINT_COUNT { return false }
|
||||
return hn_mute[id]
|
||||
}
|
||||
|
||||
export function hints_mute(id: int, on: bool) -> void {
|
||||
hn_mute_ensure()
|
||||
if id < 0 or id >= HINT_COUNT { return }
|
||||
hn_mute[id] = on
|
||||
}
|
||||
|
||||
export function hints_mute_count() -> int {
|
||||
hn_mute_ensure()
|
||||
var n = 0
|
||||
for i in 0 .. HINT_COUNT { if hn_mute[i] { n += 1 } }
|
||||
return n
|
||||
}
|
||||
|
||||
# every muted card given back, from the next pass
|
||||
export function hints_unmute_all() -> void {
|
||||
hn_mute_ensure()
|
||||
for i in 0 .. HINT_COUNT { hn_mute[i] = false }
|
||||
hn_foreign = new []string
|
||||
hn_t = 0.0
|
||||
hn_fact(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() -> Val {
|
||||
hn_mute_ensure()
|
||||
let l = Value.list()
|
||||
for i in 0 .. HINT_COUNT { if hn_mute[i] { Value.add(l, Value.str(Hints[i].key)) } }
|
||||
for i in 0 .. len(hn_foreign) { Value.add(l, Value.str(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(l: Val) -> void {
|
||||
hn_mute = null
|
||||
hn_mute_ensure()
|
||||
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 { hn_mute[id] = true } else { push(hn_foreign, k) }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue