refactor(packages): 0.R5 - jobs, session, settings, hints and net make their tables when the state is made, not on the first question (jobs__ensure, session__init and ply_init, sg_init, hn_mute_ensure, net__init gone); their questions read
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
63c30b9ebe
commit
9e4f4edb92
21 changed files with 98 additions and 163 deletions
|
|
@ -1,27 +1,18 @@
|
|||
# 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)
|
||||
export function hints_muted(hints_st: HintsState, id: int) -> bool {
|
||||
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)
|
||||
export function hints_mute_count(hints_st: HintsState) -> int {
|
||||
var n = 0
|
||||
for i in 0 .. HINT_COUNT { if hints_st.hn_mute[i] { n += 1 } }
|
||||
return n
|
||||
|
|
@ -29,7 +20,6 @@ export function hints_mute_count(hints_st: mut HintsState) -> int {
|
|||
|
||||
# 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
|
||||
|
|
@ -37,8 +27,7 @@ export function hints_unmute_all(hints_st: mut HintsState) -> void {
|
|||
}
|
||||
|
||||
# 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)
|
||||
export function hints_mutes_save(hints_st: HintsState) -> Val {
|
||||
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])) }
|
||||
|
|
@ -47,8 +36,7 @@ export function hints_mutes_save(hints_st: mut HintsState) -> Val {
|
|||
|
||||
# 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)
|
||||
hints_st.hn_mute = hn_mutes()
|
||||
if l == null or Value.kind(l) != 5 { return }
|
||||
for i in 0 .. Value.count(l) {
|
||||
let e = Value.at(l, i)
|
||||
|
|
@ -58,3 +46,8 @@ export function hints_mutes_load(hints_st: mut HintsState, l: Val) -> void {
|
|||
if id >= 0 { hints_st.hn_mute[id] = true } else { push(hints_st.hn_foreign, k) }
|
||||
}
|
||||
}
|
||||
function hn_mutes() -> []bool {
|
||||
let out = new []bool
|
||||
for i in 0 .. HINT_COUNT { push(out, false) }
|
||||
return out
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# rail.ludic - the rail: once a pass (a second by default) the most urgent true cards, up to a few,
|
||||
# muted ones left out; in a tie the registry's order decides
|
||||
export state HintsState {
|
||||
hn_mute: []bool = null
|
||||
hn_foreign: []string = null # muted keys with no card in this build, written back as read
|
||||
hn_mute: []bool = hn_mutes()
|
||||
hn_foreign: []string = new []string # muted keys with no card in this build, written back as read
|
||||
hn_shown: int = 3 # how many the rail holds
|
||||
hn_every: float = 1.0 # seconds between passes
|
||||
hn_top: []int = null # the cards on the rail this pass
|
||||
|
|
@ -36,7 +36,6 @@ function hn_ensure(hints_st: mut HintsState) -> void {
|
|||
hints_st.hn_top = new []int
|
||||
for i in 0 .. hints_st.hn_shown { push(hints_st.hn_top, -1) }
|
||||
}
|
||||
hn_mute_ensure(hints_st)
|
||||
}
|
||||
|
||||
# the next pass comes on the next tick rather than in a second
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue