wip(0.S3): the packages migrated by ludic migrate state packages - every package test green
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1e8b5b0523
commit
07505e7ef2
294 changed files with 14996 additions and 14675 deletions
|
|
@ -1,78 +1,78 @@
|
|||
# arc.ludic - an arc is a table of chapters, each a table of up to STEPS_PER_CHAPTER steps. The
|
||||
# game builds one with steps_chapter_add / steps_add; what a chapter is called is the game's.
|
||||
# empty the tables for another arc (the progress goes back to the first chapter)
|
||||
export function steps_arc_clear() -> void {
|
||||
steps__n = new []int
|
||||
steps__kind = new []int
|
||||
steps__param = new []int
|
||||
steps__need = new []int
|
||||
steps__cur = 0
|
||||
steps__done = 0
|
||||
export function steps_arc_clear(steps_st: mut StepsState) -> void {
|
||||
steps_st.steps__n = new []int
|
||||
steps_st.steps__kind = new []int
|
||||
steps_st.steps__param = new []int
|
||||
steps_st.steps__need = new []int
|
||||
steps_st.steps__cur = 0
|
||||
steps_st.steps__done = 0
|
||||
}
|
||||
|
||||
function steps__ready() -> void { if steps__n == null { steps_arc_clear() } }
|
||||
function steps__ready(steps_st: mut StepsState) -> void { if steps_st.steps__n == null { steps_arc_clear(steps_st) } }
|
||||
|
||||
# open the next chapter; its number
|
||||
export function steps_chapter_add() -> int {
|
||||
steps__ready()
|
||||
push(steps__n, 0)
|
||||
export function steps_chapter_add(steps_st: mut StepsState) -> int {
|
||||
steps__ready(steps_st)
|
||||
push(steps_st.steps__n, 0)
|
||||
for i in 0 .. STEPS_PER_CHAPTER {
|
||||
push(steps__kind, -1)
|
||||
push(steps__param, 0)
|
||||
push(steps__need, 0)
|
||||
push(steps_st.steps__kind, -1)
|
||||
push(steps_st.steps__param, 0)
|
||||
push(steps_st.steps__need, 0)
|
||||
}
|
||||
return len(steps__n) - 1
|
||||
return len(steps_st.steps__n) - 1
|
||||
}
|
||||
|
||||
# a step in the chapter just opened; false when there is no chapter or it is full
|
||||
export function steps_add(kind: int, param: int, need: int) -> bool {
|
||||
steps__ready()
|
||||
let c = len(steps__n) - 1
|
||||
if c < 0 or steps__n[c] >= STEPS_PER_CHAPTER { return false }
|
||||
let k = c * STEPS_PER_CHAPTER + steps__n[c]
|
||||
steps__kind[k] = kind
|
||||
steps__param[k] = param
|
||||
steps__need[k] = need
|
||||
steps__n[c] += 1
|
||||
export function steps_add(steps_st: mut StepsState, kind: int, param: int, need: int) -> bool {
|
||||
steps__ready(steps_st)
|
||||
let c = len(steps_st.steps__n) - 1
|
||||
if c < 0 or steps_st.steps__n[c] >= STEPS_PER_CHAPTER { return false }
|
||||
let k = c * STEPS_PER_CHAPTER + steps_st.steps__n[c]
|
||||
steps_st.steps__kind[k] = kind
|
||||
steps_st.steps__param[k] = param
|
||||
steps_st.steps__need[k] = need
|
||||
steps_st.steps__n[c] += 1
|
||||
return true
|
||||
}
|
||||
|
||||
export function steps_count() -> int {
|
||||
if steps__n == null { return 0 }
|
||||
return len(steps__n)
|
||||
export function steps_count(steps_st: StepsState) -> int {
|
||||
if steps_st.steps__n == null { return 0 }
|
||||
return len(steps_st.steps__n)
|
||||
}
|
||||
|
||||
export function steps_in(ch: int) -> int {
|
||||
if ch < 0 or ch >= steps_count() { return 0 }
|
||||
return steps__n[ch]
|
||||
export function steps_in(steps_st: StepsState, ch: int) -> int {
|
||||
if ch < 0 or ch >= steps_count(steps_st) { return 0 }
|
||||
return steps_st.steps__n[ch]
|
||||
}
|
||||
|
||||
# a step by its flat index, ch * STEPS_PER_CHAPTER + i (-1, 0, 0 past the table)
|
||||
export function steps_kind_at(k: int) -> int {
|
||||
if steps__kind == null or k < 0 or k >= len(steps__kind) { return -1 }
|
||||
return steps__kind[k]
|
||||
export function steps_kind_at(steps_st: StepsState, k: int) -> int {
|
||||
if steps_st.steps__kind == null or k < 0 or k >= len(steps_st.steps__kind) { return -1 }
|
||||
return steps_st.steps__kind[k]
|
||||
}
|
||||
|
||||
export function steps_param_at(k: int) -> int {
|
||||
if steps__param == null or k < 0 or k >= len(steps__param) { return 0 }
|
||||
return steps__param[k]
|
||||
export function steps_param_at(steps_st: StepsState, k: int) -> int {
|
||||
if steps_st.steps__param == null or k < 0 or k >= len(steps_st.steps__param) { return 0 }
|
||||
return steps_st.steps__param[k]
|
||||
}
|
||||
|
||||
export function steps_need_at(k: int) -> int {
|
||||
if steps__need == null or k < 0 or k >= len(steps__need) { return 0 }
|
||||
return steps__need[k]
|
||||
export function steps_need_at(steps_st: StepsState, k: int) -> int {
|
||||
if steps_st.steps__need == null or k < 0 or k >= len(steps_st.steps__need) { return 0 }
|
||||
return steps_st.steps__need[k]
|
||||
}
|
||||
|
||||
export function steps_kind(ch: int, i: int) -> int { return steps_kind_at(ch * STEPS_PER_CHAPTER + i) }
|
||||
export function steps_param(ch: int, i: int) -> int { return steps_param_at(ch * STEPS_PER_CHAPTER + i) }
|
||||
export function steps_need(ch: int, i: int) -> int { return steps_need_at(ch * STEPS_PER_CHAPTER + i) }
|
||||
export function steps_kind(steps_st: StepsState, ch: int, i: int) -> int { return steps_kind_at(steps_st, ch * STEPS_PER_CHAPTER + i) }
|
||||
export function steps_param(steps_st: StepsState, ch: int, i: int) -> int { return steps_param_at(steps_st, ch * STEPS_PER_CHAPTER + i) }
|
||||
export function steps_need(steps_st: StepsState, ch: int, i: int) -> int { return steps_need_at(steps_st, ch * STEPS_PER_CHAPTER + i) }
|
||||
|
||||
# the chapter being played, and which of its steps are done (sticky)
|
||||
export function steps_current() -> int { return steps__cur }
|
||||
export function steps_done_mask() -> int { return steps__done }
|
||||
export function steps_done(i: int) -> bool { return (steps__done & (1 << i)) != 0 }
|
||||
export function steps_finished() -> bool { return steps__cur >= steps_count() }
|
||||
export function steps_current(steps_st: StepsState) -> int { return steps_st.steps__cur }
|
||||
export function steps_done_mask(steps_st: StepsState) -> int { return steps_st.steps__done }
|
||||
export function steps_done(steps_st: StepsState, i: int) -> bool { return (steps_st.steps__done & (1 << i)) != 0 }
|
||||
export function steps_finished(steps_st: StepsState) -> bool { return steps_st.steps__cur >= steps_count(steps_st) }
|
||||
|
||||
# the progress outright: a load, the host's word, a test
|
||||
export function steps_set_current(ch: int) -> void { steps__cur = ch }
|
||||
export function steps_set_done(mask: int) -> void { steps__done = mask }
|
||||
export function steps_set_current(steps_st: mut StepsState, ch: int) -> void { steps_st.steps__cur = ch }
|
||||
export function steps_set_done(steps_st: mut StepsState, mask: int) -> void { steps_st.steps__done = mask }
|
||||
|
|
|
|||
|
|
@ -1,43 +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)
|
||||
export function steps_check(base_st: mut BaseState, steps_st: mut StepsState) -> void {
|
||||
if steps_finished(steps_st) { return }
|
||||
let ch = steps_st.steps__cur
|
||||
let n = steps_in(steps_st, 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(steps_st, i) and steps_met(steps_st, i) {
|
||||
steps_st.steps__done = steps_st.steps__done | (1 << i)
|
||||
steps__fact(base_st, steps_st, STEPS_MET, ch, i)
|
||||
}
|
||||
if not steps_done(i) { all = false }
|
||||
if not steps_done(steps_st, i) { all = false }
|
||||
}
|
||||
if not all { return }
|
||||
steps__cur = ch + 1
|
||||
steps__done = 0
|
||||
steps__fact(STEPS_CHAPTER, ch, n)
|
||||
steps_st.steps__cur = ch + 1
|
||||
steps_st.steps__done = 0
|
||||
steps__fact(base_st, steps_st, 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))
|
||||
export function steps_check_at(steps_st: StepsState, ch: int, i: int) -> bool {
|
||||
if ch < 0 or ch >= steps_count(steps_st) or i < 0 or i >= steps_in(steps_st, ch) { return false }
|
||||
return steps_eval(steps_st, steps_kind(steps_st, ch, i), steps_param(steps_st, ch, i), steps_need(steps_st, 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 }
|
||||
export function steps_wants(steps_st: StepsState, kind: int, param: int) -> bool {
|
||||
if steps_finished(steps_st) { return false }
|
||||
for i in 0 .. steps_in(steps_st, steps_st.steps__cur) {
|
||||
if steps_done(steps_st, i) or steps_kind(steps_st, steps_st.steps__cur, i) != kind { continue }
|
||||
if param < 0 or steps_param(steps_st, steps_st.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())
|
||||
export function steps_reset(base_st: mut BaseState, steps_st: mut StepsState) -> void {
|
||||
steps_arc_clear(steps_st)
|
||||
steps__party_clear(steps_st)
|
||||
q_clear(base_st, steps_facts(base_st, steps_st))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
# each.ludic - a step every player must meet in their own pack: how many seats are taken, how
|
||||
# many of them carry it, and which do not
|
||||
export function steps_players() -> int {
|
||||
export function steps_players(steps_st: StepsState) -> int {
|
||||
var n = 0
|
||||
for p in 0 .. steps__players { if StepsWorld.present(p) { n += 1 } }
|
||||
for p in 0 .. steps_st.steps__players { if StepsWorld.present(p) { n += 1 } }
|
||||
return n
|
||||
}
|
||||
|
||||
# how many seats taken have step i's thing (seat 0 counted live)
|
||||
export function steps_each(i: int) -> int {
|
||||
steps__cols()
|
||||
export function steps_each(steps_st: mut StepsState, i: int) -> int {
|
||||
steps__cols(steps_st)
|
||||
var n = 0
|
||||
for p in 0 .. steps__players {
|
||||
if StepsWorld.present(p) and steps__col[p * STEPS_PER_CHAPTER + i] != 0 { n += 1 }
|
||||
for p in 0 .. steps_st.steps__players {
|
||||
if StepsWorld.present(p) and steps_st.steps__col[p * STEPS_PER_CHAPTER + i] != 0 { n += 1 }
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
# the seats that do not have it yet
|
||||
export function steps_lacking(i: int) -> []int {
|
||||
steps__cols()
|
||||
export function steps_lacking(steps_st: mut StepsState, i: int) -> []int {
|
||||
steps__cols(steps_st)
|
||||
let out = new []int
|
||||
for p in 0 .. steps__players {
|
||||
if StepsWorld.present(p) and steps__col[p * STEPS_PER_CHAPTER + i] == 0 { push(out, p) }
|
||||
for p in 0 .. steps_st.steps__players {
|
||||
if StepsWorld.present(p) and steps_st.steps__col[p * STEPS_PER_CHAPTER + i] == 0 { push(out, p) }
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,34 @@
|
|||
# kinds.ludic - the kinds the game hands in, and a step answered from its kind's shape: met or
|
||||
# not, its count, what it wants. A kind past the list is a plain yes, the world's.
|
||||
export function steps_kinds(ks: []StepsKind) -> void { steps__kinds = ks }
|
||||
export function steps_kinds(steps_st: mut StepsState, ks: []StepsKind) -> void { steps_st.steps__kinds = ks }
|
||||
|
||||
function steps__known(kind: int) -> bool { return steps__kinds != null and kind >= 0 and kind < len(steps__kinds) }
|
||||
function steps__known(steps_st: StepsState, kind: int) -> bool { return steps_st.steps__kinds != null and kind >= 0 and kind < len(steps_st.steps__kinds) }
|
||||
|
||||
export function steps_shape(kind: int) -> int {
|
||||
if not steps__known(kind) { return STEPS_SHAPE_YES }
|
||||
return steps__kinds[kind].shape
|
||||
export function steps_shape(steps_st: StepsState, kind: int) -> int {
|
||||
if not steps__known(steps_st, kind) { return STEPS_SHAPE_YES }
|
||||
return steps_st.steps__kinds[kind].shape
|
||||
}
|
||||
|
||||
export function steps_pool(kind: int) -> int {
|
||||
if not steps__known(kind) { return STEPS_POOL_WORLD }
|
||||
return steps__kinds[kind].pool
|
||||
export function steps_pool(steps_st: StepsState, kind: int) -> int {
|
||||
if not steps__known(steps_st, kind) { return STEPS_POOL_WORLD }
|
||||
return steps_st.steps__kinds[kind].pool
|
||||
}
|
||||
|
||||
export function steps_shows(kind: int) -> bool {
|
||||
if not steps__known(kind) { return false }
|
||||
return steps__kinds[kind].shows
|
||||
export function steps_shows(steps_st: StepsState, kind: int) -> bool {
|
||||
if not steps__known(steps_st, kind) { return false }
|
||||
return steps_st.steps__kinds[kind].shows
|
||||
}
|
||||
|
||||
function steps__value(kind: int, param: int) -> int { return StepsWorld.value(kind, param, 0) }
|
||||
|
||||
# is (kind, param, need) met by this machine's own state?
|
||||
export function steps_eval(kind: int, param: int, need: int) -> bool {
|
||||
export function steps_eval(steps_st: StepsState, kind: int, param: int, need: int) -> bool {
|
||||
if kind < 0 { return false }
|
||||
return steps__met_by(kind, param, need, steps__value(kind, param))
|
||||
return steps__met_by(steps_st, kind, param, need, steps__value(kind, param))
|
||||
}
|
||||
|
||||
function steps__met_by(kind: int, param: int, need: int, v: int) -> bool {
|
||||
let sh = steps_shape(kind)
|
||||
function steps__met_by(steps_st: StepsState, kind: int, param: int, need: int, v: int) -> bool {
|
||||
let sh = steps_shape(steps_st, kind)
|
||||
if sh == STEPS_SHAPE_COUNT { return v >= need }
|
||||
if sh == STEPS_SHAPE_MASK { return steps_popcount(v) >= need }
|
||||
if sh == STEPS_SHAPE_MASK_ALL { return (v & param) == param }
|
||||
|
|
@ -36,30 +36,30 @@ function steps__met_by(kind: int, param: int, need: int, v: int) -> bool {
|
|||
}
|
||||
|
||||
# how far a counted step has got, -1 for a kind a panel shows no count for
|
||||
export function steps_got(kind: int, param: int) -> int {
|
||||
if kind < 0 or not steps_shows(kind) { return -1 }
|
||||
return steps__shaped(kind, param, steps__value(kind, param))
|
||||
export function steps_got(steps_st: StepsState, kind: int, param: int) -> int {
|
||||
if kind < 0 or not steps_shows(steps_st, kind) { return -1 }
|
||||
return steps__shaped(steps_st, kind, param, steps__value(kind, param))
|
||||
}
|
||||
|
||||
function steps__shaped(kind: int, param: int, v: int) -> int {
|
||||
let sh = steps_shape(kind)
|
||||
function steps__shaped(steps_st: StepsState, kind: int, param: int, v: int) -> int {
|
||||
let sh = steps_shape(steps_st, kind)
|
||||
if sh == STEPS_SHAPE_MASK { return steps_popcount(v) }
|
||||
if sh == STEPS_SHAPE_MASK_ALL { return steps_popcount(v & param) }
|
||||
return v
|
||||
}
|
||||
|
||||
export function steps_want(kind: int, param: int, need: int) -> int {
|
||||
if steps_shape(kind) == STEPS_SHAPE_MASK_ALL { return steps_popcount(param) }
|
||||
export function steps_want(steps_st: StepsState, kind: int, param: int, need: int) -> int {
|
||||
if steps_shape(steps_st, kind) == STEPS_SHAPE_MASK_ALL { return steps_popcount(param) }
|
||||
return need
|
||||
}
|
||||
|
||||
# THIS machine's share: a mask for OR, a count for SUM and MAX, 1 or 0 for ANY and EACH, and
|
||||
# nothing for a question about the world
|
||||
export function steps_mine(kind: int, param: int, need: int) -> int {
|
||||
let how = steps_pool(kind)
|
||||
export function steps_mine(steps_st: StepsState, kind: int, param: int, need: int) -> int {
|
||||
let how = steps_pool(steps_st, kind)
|
||||
if how == STEPS_POOL_WORLD { return 0 }
|
||||
if how == STEPS_POOL_ANY or how == STEPS_POOL_EACH {
|
||||
if steps_eval(kind, param, need) { return 1 }
|
||||
if steps_eval(steps_st, kind, param, need) { return 1 }
|
||||
return 0
|
||||
}
|
||||
return steps__value(kind, param)
|
||||
|
|
@ -67,22 +67,22 @@ export function steps_mine(kind: int, param: int, need: int) -> int {
|
|||
|
||||
# the party's verdict from what it has between it: `v` combined as the pool says; for EACH,
|
||||
# how many are in the party and how many carry it
|
||||
export function steps_from(kind: int, param: int, need: int, v: int, players: int, have: int) -> bool {
|
||||
let how = steps_pool(kind)
|
||||
if how == STEPS_POOL_WORLD { return steps_eval(kind, param, need) }
|
||||
export function steps_from(steps_st: StepsState, kind: int, param: int, need: int, v: int, players: int, have: int) -> bool {
|
||||
let how = steps_pool(steps_st, kind)
|
||||
if how == STEPS_POOL_WORLD { return steps_eval(steps_st, kind, param, need) }
|
||||
if how == STEPS_POOL_ANY { return v != 0 }
|
||||
if how == STEPS_POOL_EACH { return players > 0 and have >= players }
|
||||
if how == STEPS_POOL_OR {
|
||||
if steps_shape(kind) == STEPS_SHAPE_MASK_ALL { return (v & param) == param }
|
||||
if steps_shape(steps_st, kind) == STEPS_SHAPE_MASK_ALL { return (v & param) == param }
|
||||
return steps_popcount(v) >= need
|
||||
}
|
||||
return v >= need
|
||||
}
|
||||
|
||||
# the count from a share already combined across the party
|
||||
export function steps_got_from(kind: int, param: int, v: int) -> int {
|
||||
let how = steps_pool(kind)
|
||||
if not steps_shows(kind) { return -1 }
|
||||
if how == STEPS_POOL_OR or how == STEPS_POOL_SUM or how == STEPS_POOL_MAX { return steps__shaped(kind, param, v) }
|
||||
return steps_got(kind, param)
|
||||
export function steps_got_from(steps_st: StepsState, kind: int, param: int, v: int) -> int {
|
||||
let how = steps_pool(steps_st, kind)
|
||||
if not steps_shows(steps_st, kind) { return -1 }
|
||||
if how == STEPS_POOL_OR or how == STEPS_POOL_SUM or how == STEPS_POOL_MAX { return steps__shaped(steps_st, kind, param, v) }
|
||||
return steps_got(steps_st, kind, param)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,66 +1,63 @@
|
|||
# party.ludic - with company every player reports what THEY have toward each step of the current
|
||||
# chapter (steps_mine) and the owner of the story answers the step from the lot. Held per seat,
|
||||
# so a player who leaves takes their column with them; seat 0 is this machine, read live.
|
||||
var steps__players: int = 12
|
||||
var steps__col: []int = null # players * STEPS_PER_CHAPTER shares
|
||||
var steps__col_ch: int = -1 # the chapter they are about
|
||||
|
||||
# how many seats a party has
|
||||
export function steps_config(players: int) -> void {
|
||||
steps__players = players
|
||||
steps__col = null
|
||||
export function steps_config(steps_st: mut StepsState, players: int) -> void {
|
||||
steps_st.steps__players = players
|
||||
steps_st.steps__col = null
|
||||
}
|
||||
|
||||
function steps__party_clear() -> void {
|
||||
steps__col = new []int
|
||||
for i in 0 .. steps__players * STEPS_PER_CHAPTER { push(steps__col, 0) }
|
||||
steps__col_ch = steps__cur
|
||||
function steps__party_clear(steps_st: mut StepsState) -> void {
|
||||
steps_st.steps__col = new []int
|
||||
for i in 0 .. steps_st.steps__players * STEPS_PER_CHAPTER { push(steps_st.steps__col, 0) }
|
||||
steps_st.steps__col_ch = steps_st.steps__cur
|
||||
}
|
||||
|
||||
# a party over (or a new one): every column forgotten
|
||||
export function steps_party_reset() -> void { steps__col = null }
|
||||
export function steps_party_reset(steps_st: mut StepsState) -> void { steps_st.steps__col = null }
|
||||
|
||||
# the columns, emptied when the chapter they were about is not this one; seat 0 refilled
|
||||
function steps__cols() -> void {
|
||||
if steps__col == null or steps__col_ch != steps__cur { steps__party_clear() }
|
||||
if steps_finished() { return }
|
||||
for i in 0 .. steps_in(steps__cur) {
|
||||
steps__col[i] = steps_mine(steps_kind(steps__cur, i), steps_param(steps__cur, i), steps_need(steps__cur, i))
|
||||
function steps__cols(steps_st: mut StepsState) -> void {
|
||||
if steps_st.steps__col == null or steps_st.steps__col_ch != steps_st.steps__cur { steps__party_clear(steps_st) }
|
||||
if steps_finished(steps_st) { return }
|
||||
for i in 0 .. steps_in(steps_st, steps_st.steps__cur) {
|
||||
steps_st.steps__col[i] = steps_mine(steps_st, steps_kind(steps_st, steps_st.steps__cur, i), steps_param(steps_st, steps_st.steps__cur, i), steps_need(steps_st, steps_st.steps__cur, i))
|
||||
}
|
||||
}
|
||||
|
||||
# this machine's shares for the current chapter, to send to whoever owns the story
|
||||
export function steps_my_shares() -> []int {
|
||||
steps__cols()
|
||||
export function steps_my_shares(steps_st: mut StepsState) -> []int {
|
||||
steps__cols(steps_st)
|
||||
let out = new []int
|
||||
for i in 0 .. STEPS_PER_CHAPTER { push(out, steps__col[i]) }
|
||||
for i in 0 .. STEPS_PER_CHAPTER { push(out, steps_st.steps__col[i]) }
|
||||
return out
|
||||
}
|
||||
|
||||
# a teammate's shares, as they sent them; ignored when they were about another chapter
|
||||
export function steps_share(p: int, ch: int, shares: []int) -> void {
|
||||
if p <= 0 or p >= steps__players or ch != steps__cur { return }
|
||||
steps__cols()
|
||||
for i in 0 .. min(len(shares), STEPS_PER_CHAPTER) { steps__col[p * STEPS_PER_CHAPTER + i] = shares[i] }
|
||||
export function steps_share(steps_st: mut StepsState, p: int, ch: int, shares: []int) -> void {
|
||||
if p <= 0 or p >= steps_st.steps__players or ch != steps_st.steps__cur { return }
|
||||
steps__cols(steps_st)
|
||||
for i in 0 .. min(len(shares), STEPS_PER_CHAPTER) { steps_st.steps__col[p * STEPS_PER_CHAPTER + i] = shares[i] }
|
||||
}
|
||||
|
||||
export function steps_share_of(p: int, i: int) -> int {
|
||||
steps__cols()
|
||||
return steps__col[p * STEPS_PER_CHAPTER + i]
|
||||
export function steps_share_of(steps_st: mut StepsState, p: int, i: int) -> int {
|
||||
steps__cols(steps_st)
|
||||
return steps_st.steps__col[p * STEPS_PER_CHAPTER + i]
|
||||
}
|
||||
|
||||
# a seat emptied: what it had goes with it
|
||||
export function steps_leave(p: int) -> void {
|
||||
if steps__col == null or p <= 0 or p >= steps__players { return }
|
||||
for i in 0 .. STEPS_PER_CHAPTER { steps__col[p * STEPS_PER_CHAPTER + i] = 0 }
|
||||
export function steps_leave(steps_st: mut StepsState, p: int) -> void {
|
||||
if steps_st.steps__col == null or p <= 0 or p >= steps_st.steps__players { return }
|
||||
for i in 0 .. STEPS_PER_CHAPTER { steps_st.steps__col[p * STEPS_PER_CHAPTER + i] = 0 }
|
||||
}
|
||||
|
||||
# the shares of every seat taken, combined as the pool says (seat 0 is the start)
|
||||
function steps__combined(i: int, how: int) -> int {
|
||||
var v = steps__col[i]
|
||||
for p in 1 .. steps__players {
|
||||
function steps__combined(steps_st: StepsState, i: int, how: int) -> int {
|
||||
var v = steps_st.steps__col[i]
|
||||
for p in 1 .. steps_st.steps__players {
|
||||
if not StepsWorld.present(p) { continue }
|
||||
let c = steps__col[p * STEPS_PER_CHAPTER + i]
|
||||
let c = steps_st.steps__col[p * STEPS_PER_CHAPTER + i]
|
||||
if how == STEPS_POOL_ANY or how == STEPS_POOL_OR { v = v | c }
|
||||
else if how == STEPS_POOL_SUM { v += c }
|
||||
else if how == STEPS_POOL_MAX { if c > v { v = c } }
|
||||
|
|
@ -69,24 +66,24 @@ function steps__combined(i: int, how: int) -> int {
|
|||
}
|
||||
|
||||
# the answer to step i of the current chapter: solo this is steps_eval and nothing more
|
||||
export function steps_met(i: int) -> bool {
|
||||
let ch = steps__cur
|
||||
let kind = steps_kind(ch, i)
|
||||
if not StepsWorld.party() { return steps_eval(kind, steps_param(ch, i), steps_need(ch, i)) }
|
||||
let how = steps_pool(kind)
|
||||
if how == STEPS_POOL_WORLD { return steps_eval(kind, steps_param(ch, i), steps_need(ch, i)) }
|
||||
steps__cols()
|
||||
return steps_from(kind, steps_param(ch, i), steps_need(ch, i), steps__combined(i, how), steps_players(), steps_each(i))
|
||||
export function steps_met(steps_st: mut StepsState, i: int) -> bool {
|
||||
let ch = steps_st.steps__cur
|
||||
let kind = steps_kind(steps_st, ch, i)
|
||||
if not StepsWorld.party() { return steps_eval(steps_st, kind, steps_param(steps_st, ch, i), steps_need(steps_st, ch, i)) }
|
||||
let how = steps_pool(steps_st, kind)
|
||||
if how == STEPS_POOL_WORLD { return steps_eval(steps_st, kind, steps_param(steps_st, ch, i), steps_need(steps_st, ch, i)) }
|
||||
steps__cols(steps_st)
|
||||
return steps_from(steps_st, kind, steps_param(steps_st, ch, i), steps_need(steps_st, ch, i), steps__combined(steps_st, i, how), steps_players(steps_st), steps_each(steps_st, i))
|
||||
}
|
||||
|
||||
# the party's count for step i of the current chapter, -1 for one that is not a tally
|
||||
export function steps_party_got(i: int) -> int {
|
||||
let ch = steps__cur
|
||||
let kind = steps_kind(ch, i)
|
||||
let param = steps_param(ch, i)
|
||||
if steps_got(kind, param) < 0 { return -1 }
|
||||
let how = steps_pool(kind)
|
||||
if not StepsWorld.party() or how == STEPS_POOL_WORLD or how == STEPS_POOL_ANY or how == STEPS_POOL_EACH { return steps_got(kind, param) }
|
||||
steps__cols()
|
||||
return steps_got_from(kind, param, steps__combined(i, how))
|
||||
export function steps_party_got(steps_st: mut StepsState, i: int) -> int {
|
||||
let ch = steps_st.steps__cur
|
||||
let kind = steps_kind(steps_st, ch, i)
|
||||
let param = steps_param(steps_st, ch, i)
|
||||
if steps_got(steps_st, kind, param) < 0 { return -1 }
|
||||
let how = steps_pool(steps_st, kind)
|
||||
if not StepsWorld.party() or how == STEPS_POOL_WORLD or how == STEPS_POOL_ANY or how == STEPS_POOL_EACH { return steps_got(steps_st, kind, param) }
|
||||
steps__cols(steps_st)
|
||||
return steps_got_from(steps_st, kind, param, steps__combined(steps_st, i, how))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,26 +45,31 @@ export property StepsFact {
|
|||
step: int = 0
|
||||
}
|
||||
|
||||
var steps__kinds: []StepsKind = null
|
||||
var steps__n: []int = null # steps per chapter
|
||||
var steps__kind: []int = null # STEPS_PER_CHAPTER per chapter
|
||||
var steps__param: []int = null
|
||||
var steps__need: []int = null
|
||||
var steps__cur: int = 0
|
||||
var steps__done: int = 0
|
||||
var steps__facts: Queue<StepsFact> = null
|
||||
|
||||
export function steps_facts() -> Queue<StepsFact> {
|
||||
if steps__facts == null { steps__facts = queue_new("steps.facts") }
|
||||
return steps__facts
|
||||
export state StepsState {
|
||||
steps__players: int = 12
|
||||
steps__col: []int = null # players * STEPS_PER_CHAPTER shares
|
||||
steps__col_ch: int = -1 # the chapter they are about
|
||||
steps__kinds: []StepsKind = null
|
||||
steps__n: []int = null # steps per chapter
|
||||
steps__kind: []int = null # STEPS_PER_CHAPTER per chapter
|
||||
steps__param: []int = null
|
||||
steps__need: []int = null
|
||||
steps__cur: int = 0
|
||||
steps__done: int = 0
|
||||
steps__facts: Queue<StepsFact> = null
|
||||
}
|
||||
|
||||
function steps__fact(what: int, ch: int, i: int) -> void {
|
||||
export function steps_facts(base_st: mut BaseState, steps_st: mut StepsState) -> Queue<StepsFact> {
|
||||
if steps_st.steps__facts == null { steps_st.steps__facts = queue_new(base_st, "steps.facts") }
|
||||
return steps_st.steps__facts
|
||||
}
|
||||
|
||||
function steps__fact(base_st: mut BaseState, steps_st: mut StepsState, what: int, ch: int, i: int) -> void {
|
||||
let f = new StepsFact
|
||||
f.what = what
|
||||
f.chapter = ch
|
||||
f.step = i
|
||||
q_push(steps_facts(), f)
|
||||
q_push(base_st, steps_facts(base_st, steps_st), f)
|
||||
}
|
||||
|
||||
export function steps_popcount(m: int) -> int {
|
||||
|
|
|
|||
|
|
@ -4,16 +4,18 @@ import "ludic.steps"
|
|||
import "ludic.base"
|
||||
program StepsTest {
|
||||
numbers float
|
||||
var vals: []int = null # value of kind k for this machine
|
||||
var party: bool = false
|
||||
var seats: int = 1 # seats 0 .. seats-1 are taken
|
||||
|
||||
function fake_value(kind: int, param: int, player: int) -> int {
|
||||
if player != 0 or kind < 0 or kind >= len(vals) { return 0 }
|
||||
return vals[kind]
|
||||
state StepstestState {
|
||||
vals: []int = null # value of kind k for this machine
|
||||
party: bool = false
|
||||
seats: int = 1 # seats 0 .. seats-1 are taken
|
||||
}
|
||||
function fake_party() -> bool { return party }
|
||||
function fake_present(p: int) -> bool { return p < seats }
|
||||
|
||||
function fake_value(stepstest_st: StepstestState, kind: int, param: int, player: int) -> int {
|
||||
if player != 0 or kind < 0 or kind >= len(stepstest_st.vals) { return 0 }
|
||||
return stepstest_st.vals[kind]
|
||||
}
|
||||
function fake_party(stepstest_st: StepstestState) -> bool { return stepstest_st.party }
|
||||
function fake_present(stepstest_st: StepstestState, p: int) -> bool { return p < stepstest_st.seats }
|
||||
|
||||
bind StepsWorld { value: fn fake_value, party: fn fake_party, present: fn fake_present }
|
||||
|
||||
|
|
@ -33,13 +35,13 @@ program StepsTest {
|
|||
return k
|
||||
}
|
||||
|
||||
function fresh() -> void {
|
||||
steps_reset()
|
||||
steps_config(4)
|
||||
party = false
|
||||
seats = 1
|
||||
vals = new []int
|
||||
for i in 0 .. 7 { push(vals, 0) }
|
||||
function fresh(base_st: mut BaseState, steps_st: mut StepsState, stepstest_st: mut StepstestState) -> void {
|
||||
steps_reset(base_st, steps_st)
|
||||
steps_config(steps_st, 4)
|
||||
stepstest_st.party = false
|
||||
stepstest_st.seats = 1
|
||||
stepstest_st.vals = new []int
|
||||
for i in 0 .. 7 { push(stepstest_st.vals, 0) }
|
||||
let ks = new []StepsKind
|
||||
push(ks, kind(STEPS_SHAPE_COUNT, STEPS_POOL_SUM, true))
|
||||
push(ks, kind(STEPS_SHAPE_MASK, STEPS_POOL_OR, true))
|
||||
|
|
@ -48,21 +50,21 @@ program StepsTest {
|
|||
push(ks, kind(STEPS_SHAPE_COUNT, STEPS_POOL_MAX, true))
|
||||
push(ks, kind(STEPS_SHAPE_YES, STEPS_POOL_EACH, false))
|
||||
push(ks, kind(STEPS_SHAPE_YES, STEPS_POOL_WORLD, false))
|
||||
steps_kinds(ks)
|
||||
steps_kinds(steps_st, ks)
|
||||
}
|
||||
|
||||
# chapter 0: 5 wood, a fire; chapter 1: two signs, the compass
|
||||
function two_chapters() -> void {
|
||||
steps_chapter_add()
|
||||
steps_add(K_WOOD, 0, 5)
|
||||
steps_add(K_FIRE, 0, 1)
|
||||
steps_chapter_add()
|
||||
steps_add(K_SIGNS, 0, 2)
|
||||
steps_add(K_COMPASS, 0, 1)
|
||||
function two_chapters(steps_st: mut StepsState) -> void {
|
||||
steps_chapter_add(steps_st)
|
||||
steps_add(steps_st, K_WOOD, 0, 5)
|
||||
steps_add(steps_st, K_FIRE, 0, 1)
|
||||
steps_chapter_add(steps_st)
|
||||
steps_add(steps_st, K_SIGNS, 0, 2)
|
||||
steps_add(steps_st, K_COMPASS, 0, 1)
|
||||
}
|
||||
|
||||
function facts_of(what: int) -> int {
|
||||
let fs = q_drain(steps_facts())
|
||||
function facts_of(base_st: mut BaseState, steps_st: mut StepsState, what: int) -> int {
|
||||
let fs = q_drain(base_st, steps_facts(base_st, steps_st))
|
||||
var n = 0
|
||||
for i in 0 .. len(fs) { if fs[i].what == what { n += 1 } }
|
||||
return n
|
||||
|
|
@ -75,150 +77,150 @@ program StepsTest {
|
|||
return s
|
||||
}
|
||||
|
||||
test "a step is answered by its kind's shape" {
|
||||
fresh()
|
||||
vals[K_WOOD] = 4
|
||||
expect(not steps_eval(K_WOOD, 0, 5))
|
||||
vals[K_WOOD] = 5
|
||||
expect(steps_eval(K_WOOD, 0, 5))
|
||||
vals[K_SIGNS] = 5
|
||||
expect(steps_eval(K_SIGNS, 0, 2))
|
||||
expect_eq(steps_got(K_SIGNS, 0), 2)
|
||||
vals[K_ALL] = 3
|
||||
expect(not steps_eval(K_ALL, 7, 0))
|
||||
expect_eq(steps_got(K_ALL, 7), 2)
|
||||
expect_eq(steps_want(K_ALL, 7, 0), 3)
|
||||
expect_eq(steps_got(K_FIRE, 0), -1)
|
||||
test "a step is answered by its kind's shape" (base_st: mut BaseState, steps_st: mut StepsState, stepstest_st: mut StepstestState) {
|
||||
fresh(base_st, steps_st, stepstest_st)
|
||||
stepstest_st.vals[K_WOOD] = 4
|
||||
expect(not steps_eval(steps_st, K_WOOD, 0, 5))
|
||||
stepstest_st.vals[K_WOOD] = 5
|
||||
expect(steps_eval(steps_st, K_WOOD, 0, 5))
|
||||
stepstest_st.vals[K_SIGNS] = 5
|
||||
expect(steps_eval(steps_st, K_SIGNS, 0, 2))
|
||||
expect_eq(steps_got(steps_st, K_SIGNS, 0), 2)
|
||||
stepstest_st.vals[K_ALL] = 3
|
||||
expect(not steps_eval(steps_st, K_ALL, 7, 0))
|
||||
expect_eq(steps_got(steps_st, K_ALL, 7), 2)
|
||||
expect_eq(steps_want(steps_st, K_ALL, 7, 0), 3)
|
||||
expect_eq(steps_got(steps_st, K_FIRE, 0), -1)
|
||||
}
|
||||
|
||||
test "an arc's steps stick as they are met, and a full chapter opens the next" {
|
||||
fresh()
|
||||
two_chapters()
|
||||
expect_eq(steps_count(), 2)
|
||||
expect_eq(steps_in(1), 2)
|
||||
vals[K_FIRE] = 1
|
||||
steps_check()
|
||||
expect(steps_done(1))
|
||||
expect(not steps_done(0))
|
||||
expect_eq(facts_of(STEPS_MET), 1)
|
||||
vals[K_FIRE] = 0
|
||||
steps_check()
|
||||
expect(steps_done(1))
|
||||
vals[K_WOOD] = 9
|
||||
steps_check()
|
||||
expect_eq(steps_current(), 1)
|
||||
expect_eq(steps_done_mask(), 0)
|
||||
let fs = q_drain(steps_facts())
|
||||
test "an arc's steps stick as they are met, and a full chapter opens the next" (base_st: mut BaseState, steps_st: mut StepsState, stepstest_st: mut StepstestState) {
|
||||
fresh(base_st, steps_st, stepstest_st)
|
||||
two_chapters(steps_st)
|
||||
expect_eq(steps_count(steps_st), 2)
|
||||
expect_eq(steps_in(steps_st, 1), 2)
|
||||
stepstest_st.vals[K_FIRE] = 1
|
||||
steps_check(base_st, steps_st)
|
||||
expect(steps_done(steps_st, 1))
|
||||
expect(not steps_done(steps_st, 0))
|
||||
expect_eq(facts_of(base_st, steps_st, STEPS_MET), 1)
|
||||
stepstest_st.vals[K_FIRE] = 0
|
||||
steps_check(base_st, steps_st)
|
||||
expect(steps_done(steps_st, 1))
|
||||
stepstest_st.vals[K_WOOD] = 9
|
||||
steps_check(base_st, steps_st)
|
||||
expect_eq(steps_current(steps_st), 1)
|
||||
expect_eq(steps_done_mask(steps_st), 0)
|
||||
let fs = q_drain(base_st, steps_facts(base_st, steps_st))
|
||||
expect_eq(len(fs), 2)
|
||||
expect_eq(fs[1].what, STEPS_CHAPTER)
|
||||
expect_eq(fs[1].chapter, 0)
|
||||
}
|
||||
|
||||
test "a step met before its chapter opens ticks the moment it is looked at" {
|
||||
fresh()
|
||||
two_chapters()
|
||||
vals[K_SIGNS] = 3
|
||||
vals[K_COMPASS] = 1
|
||||
vals[K_WOOD] = 5
|
||||
vals[K_FIRE] = 1
|
||||
steps_check()
|
||||
expect_eq(steps_current(), 1)
|
||||
steps_check()
|
||||
expect(steps_finished())
|
||||
test "a step met before its chapter opens ticks the moment it is looked at" (base_st: mut BaseState, steps_st: mut StepsState, stepstest_st: mut StepstestState) {
|
||||
fresh(base_st, steps_st, stepstest_st)
|
||||
two_chapters(steps_st)
|
||||
stepstest_st.vals[K_SIGNS] = 3
|
||||
stepstest_st.vals[K_COMPASS] = 1
|
||||
stepstest_st.vals[K_WOOD] = 5
|
||||
stepstest_st.vals[K_FIRE] = 1
|
||||
steps_check(base_st, steps_st)
|
||||
expect_eq(steps_current(steps_st), 1)
|
||||
steps_check(base_st, steps_st)
|
||||
expect(steps_finished(steps_st))
|
||||
}
|
||||
|
||||
test "a chapter holds at most six steps" {
|
||||
fresh()
|
||||
expect(not steps_add(K_WOOD, 0, 1))
|
||||
steps_chapter_add()
|
||||
for i in 0 .. STEPS_PER_CHAPTER { expect(steps_add(K_WOOD, 0, i)) }
|
||||
expect(not steps_add(K_WOOD, 0, 9))
|
||||
test "a chapter holds at most six steps" (base_st: mut BaseState, steps_st: mut StepsState, stepstest_st: mut StepstestState) {
|
||||
fresh(base_st, steps_st, stepstest_st)
|
||||
expect(not steps_add(steps_st, K_WOOD, 0, 1))
|
||||
steps_chapter_add(steps_st)
|
||||
for i in 0 .. STEPS_PER_CHAPTER { expect(steps_add(steps_st, K_WOOD, 0, i)) }
|
||||
expect(not steps_add(steps_st, K_WOOD, 0, 9))
|
||||
}
|
||||
|
||||
test "the steps asked for right now" {
|
||||
fresh()
|
||||
two_chapters()
|
||||
expect(steps_wants(K_FIRE, -1))
|
||||
expect(not steps_wants(K_SIGNS, -1))
|
||||
test "the steps asked for right now" (base_st: mut BaseState, steps_st: mut StepsState, stepstest_st: mut StepstestState) {
|
||||
fresh(base_st, steps_st, stepstest_st)
|
||||
two_chapters(steps_st)
|
||||
expect(steps_wants(steps_st, K_FIRE, -1))
|
||||
expect(not steps_wants(steps_st, K_SIGNS, -1))
|
||||
}
|
||||
|
||||
test "a tally adds up across the party, and a mask unions" {
|
||||
fresh()
|
||||
two_chapters()
|
||||
party = true
|
||||
seats = 2
|
||||
vals[K_WOOD] = 3
|
||||
expect(not steps_met(0))
|
||||
steps_share(1, 0, shares(2, 0))
|
||||
expect(steps_met(0))
|
||||
expect_eq(steps_party_got(0), 5)
|
||||
steps_set_current(1)
|
||||
vals[K_SIGNS] = 1
|
||||
steps_share(1, 1, shares(2, 0))
|
||||
expect(steps_met(0))
|
||||
test "a tally adds up across the party, and a mask unions" (base_st: mut BaseState, steps_st: mut StepsState, stepstest_st: mut StepstestState) {
|
||||
fresh(base_st, steps_st, stepstest_st)
|
||||
two_chapters(steps_st)
|
||||
stepstest_st.party = true
|
||||
stepstest_st.seats = 2
|
||||
stepstest_st.vals[K_WOOD] = 3
|
||||
expect(not steps_met(steps_st, 0))
|
||||
steps_share(steps_st, 1, 0, shares(2, 0))
|
||||
expect(steps_met(steps_st, 0))
|
||||
expect_eq(steps_party_got(steps_st, 0), 5)
|
||||
steps_set_current(steps_st, 1)
|
||||
stepstest_st.vals[K_SIGNS] = 1
|
||||
steps_share(steps_st, 1, 1, shares(2, 0))
|
||||
expect(steps_met(steps_st, 0))
|
||||
}
|
||||
|
||||
test "anyone having done it is the party having done it" {
|
||||
fresh()
|
||||
two_chapters()
|
||||
party = true
|
||||
seats = 3
|
||||
steps_share(2, 0, shares(0, 1))
|
||||
expect(steps_met(1))
|
||||
test "anyone having done it is the party having done it" (base_st: mut BaseState, steps_st: mut StepsState, stepstest_st: mut StepstestState) {
|
||||
fresh(base_st, steps_st, stepstest_st)
|
||||
two_chapters(steps_st)
|
||||
stepstest_st.party = true
|
||||
stepstest_st.seats = 3
|
||||
steps_share(steps_st, 2, 0, shares(0, 1))
|
||||
expect(steps_met(steps_st, 1))
|
||||
}
|
||||
|
||||
test "a thing in the pack is met when every player has one, and says who has not" {
|
||||
fresh()
|
||||
two_chapters()
|
||||
steps_set_current(1)
|
||||
party = true
|
||||
seats = 3
|
||||
vals[K_COMPASS] = 1
|
||||
steps_share(1, 1, shares(0, 1))
|
||||
expect(not steps_met(1))
|
||||
expect_eq(steps_each(1), 2)
|
||||
let lack = steps_lacking(1)
|
||||
test "a thing in the pack is met when every player has one, and says who has not" (base_st: mut BaseState, steps_st: mut StepsState, stepstest_st: mut StepstestState) {
|
||||
fresh(base_st, steps_st, stepstest_st)
|
||||
two_chapters(steps_st)
|
||||
steps_set_current(steps_st, 1)
|
||||
stepstest_st.party = true
|
||||
stepstest_st.seats = 3
|
||||
stepstest_st.vals[K_COMPASS] = 1
|
||||
steps_share(steps_st, 1, 1, shares(0, 1))
|
||||
expect(not steps_met(steps_st, 1))
|
||||
expect_eq(steps_each(steps_st, 1), 2)
|
||||
let lack = steps_lacking(steps_st, 1)
|
||||
expect_eq(len(lack), 1)
|
||||
expect_eq(lack[0], 2)
|
||||
steps_share(2, 1, shares(0, 1))
|
||||
expect(steps_met(1))
|
||||
steps_share(steps_st, 2, 1, shares(0, 1))
|
||||
expect(steps_met(steps_st, 1))
|
||||
}
|
||||
|
||||
test "a player who leaves takes their share with them" {
|
||||
fresh()
|
||||
two_chapters()
|
||||
party = true
|
||||
seats = 2
|
||||
steps_share(1, 0, shares(5, 0))
|
||||
expect(steps_met(0))
|
||||
steps_leave(1)
|
||||
expect(not steps_met(0))
|
||||
test "a player who leaves takes their share with them" (base_st: mut BaseState, steps_st: mut StepsState, stepstest_st: mut StepstestState) {
|
||||
fresh(base_st, steps_st, stepstest_st)
|
||||
two_chapters(steps_st)
|
||||
stepstest_st.party = true
|
||||
stepstest_st.seats = 2
|
||||
steps_share(steps_st, 1, 0, shares(5, 0))
|
||||
expect(steps_met(steps_st, 0))
|
||||
steps_leave(steps_st, 1)
|
||||
expect(not steps_met(steps_st, 0))
|
||||
}
|
||||
|
||||
test "a share about another chapter is ignored, and the best of a tally is the best" {
|
||||
fresh()
|
||||
steps_chapter_add()
|
||||
steps_add(K_REP, 0, 25)
|
||||
party = true
|
||||
seats = 2
|
||||
steps_share(1, 3, shares(99, 0))
|
||||
expect(not steps_met(0))
|
||||
vals[K_REP] = 10
|
||||
steps_share(1, 0, shares(30, 0))
|
||||
expect(steps_met(0))
|
||||
expect_eq(steps_party_got(0), 30)
|
||||
test "a share about another chapter is ignored, and the best of a tally is the best" (base_st: mut BaseState, steps_st: mut StepsState, stepstest_st: mut StepstestState) {
|
||||
fresh(base_st, steps_st, stepstest_st)
|
||||
steps_chapter_add(steps_st)
|
||||
steps_add(steps_st, K_REP, 0, 25)
|
||||
stepstest_st.party = true
|
||||
stepstest_st.seats = 2
|
||||
steps_share(steps_st, 1, 3, shares(99, 0))
|
||||
expect(not steps_met(steps_st, 0))
|
||||
stepstest_st.vals[K_REP] = 10
|
||||
steps_share(steps_st, 1, 0, shares(30, 0))
|
||||
expect(steps_met(steps_st, 0))
|
||||
expect_eq(steps_party_got(steps_st, 0), 30)
|
||||
}
|
||||
|
||||
test "the world's steps are asked of this machine alone" {
|
||||
fresh()
|
||||
steps_chapter_add()
|
||||
steps_add(K_HOUR, 0, 1)
|
||||
party = true
|
||||
seats = 2
|
||||
steps_share(1, 0, shares(1, 0))
|
||||
expect(not steps_met(0))
|
||||
vals[K_HOUR] = 1
|
||||
expect(steps_met(0))
|
||||
expect_eq(steps_mine(K_HOUR, 0, 1), 0)
|
||||
test "the world's steps are asked of this machine alone" (base_st: mut BaseState, steps_st: mut StepsState, stepstest_st: mut StepstestState) {
|
||||
fresh(base_st, steps_st, stepstest_st)
|
||||
steps_chapter_add(steps_st)
|
||||
steps_add(steps_st, K_HOUR, 0, 1)
|
||||
stepstest_st.party = true
|
||||
stepstest_st.seats = 2
|
||||
steps_share(steps_st, 1, 0, shares(1, 0))
|
||||
expect(not steps_met(steps_st, 0))
|
||||
stepstest_st.vals[K_HOUR] = 1
|
||||
expect(steps_met(steps_st, 0))
|
||||
expect_eq(steps_mine(steps_st, K_HOUR, 0, 1), 0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue