refactor(packages): 0.R5 - the rest of the lazy starts are defaults - hints' rail (sized by hints_config), lab's CRC table, rpg's crafting / items / inventory / quests / dialog, shooter's weapons, prefs, and npc's and gameplay's empty ensures gone; gameplay's faction table sits beside its state, since a default names only what is declared before it; --tighten over their tests and examples
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9e4f4edb92
commit
f516148e46
15 changed files with 73 additions and 169 deletions
|
|
@ -5,7 +5,7 @@ export state HintsState {
|
|||
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
|
||||
hn_top: []int = hn_slots(3) # the cards on the rail this pass
|
||||
hn_n: int = 0
|
||||
hn_t: float = 0.0 # seconds to the next pass
|
||||
hn_pick: int = 0 # which chip the key would open
|
||||
|
|
@ -28,21 +28,19 @@ function hn_fact(hints_st: HintsState, what: int, card: int) -> void {
|
|||
export function hints_config(hints_st: mut HintsState, shown: int, every: float) -> void {
|
||||
hints_st.hn_shown = shown
|
||||
hints_st.hn_every = every
|
||||
hints_st.hn_top = null
|
||||
hints_st.hn_top = hn_slots(shown)
|
||||
}
|
||||
|
||||
function hn_ensure(hints_st: mut HintsState) -> void {
|
||||
if hints_st.hn_top == null or len(hints_st.hn_top) != hints_st.hn_shown {
|
||||
hints_st.hn_top = new []int
|
||||
for i in 0 .. hints_st.hn_shown { push(hints_st.hn_top, -1) }
|
||||
}
|
||||
# a rail of n empty places
|
||||
function hn_slots(n: int) -> []int {
|
||||
let out = new []int
|
||||
for i in 0 .. n { push(out, -1) }
|
||||
return out
|
||||
}
|
||||
|
||||
# the next pass comes on the next tick rather than in a second
|
||||
export function hints_refresh(hints_st: mut HintsState) -> void { hints_st.hn_t = 0.0 }
|
||||
|
||||
export function hints_tick(hints_st: mut HintsState, dt: float) -> void {
|
||||
hn_ensure(hints_st)
|
||||
hints_st.hn_t = hints_st.hn_t - dt
|
||||
if hints_st.hn_t > 0.0 { return }
|
||||
hints_st.hn_t = hints_st.hn_every
|
||||
|
|
@ -52,7 +50,6 @@ export function hints_tick(hints_st: mut HintsState, dt: float) -> void {
|
|||
# one pass now: the rail re-sorted, the pick kept in range, and the card following its subject
|
||||
# along the rail - or put down when what it was about stopped being true
|
||||
export function hints_sort(hints_st: mut HintsState) -> void {
|
||||
hn_ensure(hints_st)
|
||||
hints_st.hn_n = 0
|
||||
let on = HintsWorld.showing()
|
||||
for u in 0 .. 4 {
|
||||
|
|
@ -75,8 +72,7 @@ export function hints_sort(hints_st: mut HintsState) -> void {
|
|||
}
|
||||
|
||||
# the cards on the rail, most urgent first (empty while the rail is not showing)
|
||||
export function hints_rail(hints_st: mut HintsState) -> []int {
|
||||
hn_ensure(hints_st)
|
||||
export function hints_rail(hints_st: HintsState) -> []int {
|
||||
let out = new []int
|
||||
if not HintsWorld.showing() { return out }
|
||||
for k in 0 .. hints_st.hn_n { push(out, hints_st.hn_top[k]) }
|
||||
|
|
@ -95,7 +91,7 @@ export function hints_pick(hints_st: HintsState) -> int { return hints_st.hn_pic
|
|||
export function hints_hot(hints_st: HintsState, k: int) -> bool { return k == hints_st.hn_pick }
|
||||
|
||||
export function hints_reset(hints_st: mut HintsState) -> void {
|
||||
hints_st.hn_top = null
|
||||
hints_st.hn_top = hn_slots(hints_st.hn_shown)
|
||||
hints_st.hn_n = 0
|
||||
hints_st.hn_t = 0.0
|
||||
hints_st.hn_pick = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue