ludic.jobs jobs_posted_count, ludic.steps steps_my_shares_into - a count and a kept list for what a party asks every tick

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 15:12:24 +03:00
parent fc0f3d3790
commit ae5df73e72
4 changed files with 21 additions and 0 deletions

View file

@ -20,6 +20,13 @@ export function jobs_posted(jobs_st: JobsState, b: int) -> []int {
return out
}
# how many of a board's slots hold a post, without the list
export function jobs_posted_count(jobs_st: JobsState, b: int) -> int {
var n = 0
for s in 0 .. jobs_slots(b) { if jobs_post_kind(jobs_st, b, s) >= 0 { n += 1 } }
return n
}
# how many of a board's posts are paid
export function jobs_posts_done(jobs_st: JobsState, b: int) -> int {
var n = 0

View file

@ -162,6 +162,8 @@ program JobsTest {
jobs_morning(jobs_st)
expect_eq(len(jobs_posted(jobs_st, BOARD_DAILY)), 3)
expect_eq(len(jobs_posted(jobs_st, BOARD_ADA)), 2)
expect_eq(jobs_posted_count(jobs_st, BOARD_DAILY), 3)
expect_eq(jobs_posted_count(jobs_st, BOARD_ADA), 2)
let a = jobs_post_need(jobs_st, BOARD_DAILY, 0) * 100 + jobs_post_need(jobs_st, BOARD_DAILY, 1) * 10 + jobs_post_need(jobs_st, BOARD_DAILY, 2)
fresh(jobs_st, jobs_test_st)
jobs_test_st.day = 3

View file

@ -33,6 +33,12 @@ function steps__share(steps_st: StepsState, p: int, i: int) -> int {
}
# this machine's shares for the current chapter, to send to whoever owns the story
# the same into a list the caller keeps (a guest checks its shares every tick)
export function steps_my_shares_into(steps_st: StepsState, out: []int) -> void {
List.clear(out)
for i in 0 .. STEPS_PER_CHAPTER { push(out, steps__share(steps_st, 0, i)) }
}
export function steps_my_shares(steps_st: StepsState) -> []int {
let out = new []int
for i in 0 .. STEPS_PER_CHAPTER { push(out, steps__share(steps_st, 0, i)) }

View file

@ -154,6 +154,12 @@ program StepsTest {
steps_share(steps_st, 1, 0, shares(2, 0))
expect(steps_met(steps_st, 0))
expect_eq(steps_party_got(steps_st, 0), 5)
let kept = new []int
steps_my_shares_into(steps_st, kept)
steps_my_shares_into(steps_st, kept)
let made = steps_my_shares(steps_st)
expect_eq(len(kept), len(made))
for i in 0 .. len(made) { expect_eq(kept[i], made[i]) }
steps_set_current(steps_st, 1)
steps_test_st.vals[K_SIGNS] = 1
steps_share(steps_st, 1, 1, shares(2, 0))