feat(ludic.steps): chapters of steps, their kinds, progress and a party's pooled shares
A step is (kind, param, need) and a question about state: a kind has a
shape (yes, a count, a mask counted, every bit of a mask) and a pool
(world, any, sum, or, max, each), handed in by the game as StepsKind
records. An arc is chapters of up to STEPS_PER_CHAPTER steps; steps_check
sticks each met step of the current chapter (STEPS_MET) and opens the
next when all are (STEPS_CHAPTER), so a step met before its chapter
ticks at once. With company each seat's shares are held per chapter,
pooled as the kind says (steps_met, steps_party_got), counted for an
EACH step (steps_each, steps_lacking), and a leaver takes theirs along.
Port: StepsWorld { value(kind, param, player) (required), party,
present }. The package knows no kind's meaning and no chapter's words.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4318adc98c
commit
31e6740033
10 changed files with 719 additions and 0 deletions
43
packages/ludic.steps/check.ludic
Normal file
43
packages/ludic.steps/check.ludic
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# check.ludic - once a frame on the machine that owns the story: every open step of the current
|
||||
# chapter that is met now sticks (STEPS_MET), and a chapter with all of them done moves the arc on
|
||||
# (STEPS_CHAPTER). A step asks about STATE, so one met before its chapter opened ticks at once.
|
||||
export function steps_check() -> void {
|
||||
if steps_finished() { return }
|
||||
let ch = steps__cur
|
||||
let n = steps_in(ch)
|
||||
var all = true
|
||||
for i in 0 .. n {
|
||||
if not steps_done(i) and steps_met(i) {
|
||||
steps__done = steps__done | (1 << i)
|
||||
steps__fact(STEPS_MET, ch, i)
|
||||
}
|
||||
if not steps_done(i) { all = false }
|
||||
}
|
||||
if not all { return }
|
||||
steps__cur = ch + 1
|
||||
steps__done = 0
|
||||
steps__fact(STEPS_CHAPTER, ch, n)
|
||||
}
|
||||
|
||||
# is step i of chapter ch met by this machine's own state? (a chapter not being played, a panel)
|
||||
export function steps_check_at(ch: int, i: int) -> bool {
|
||||
if ch < 0 or ch >= steps_count() or i < 0 or i >= steps_in(ch) { return false }
|
||||
return steps_eval(steps_kind(ch, i), steps_param(ch, i), steps_need(ch, i))
|
||||
}
|
||||
|
||||
# is an open step of the current chapter asking for this kind (and this param, unless < 0)?
|
||||
export function steps_wants(kind: int, param: int) -> bool {
|
||||
if steps_finished() { return false }
|
||||
for i in 0 .. steps_in(steps__cur) {
|
||||
if steps_done(i) or steps_kind(steps__cur, i) != kind { continue }
|
||||
if param < 0 or steps_param(steps__cur, i) == param { return true }
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
# back to no arc and no party (tests)
|
||||
export function steps_reset() -> void {
|
||||
steps_arc_clear()
|
||||
steps__party_clear()
|
||||
q_clear(steps_facts())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue