wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3eda72e8c2
commit
5ffe50ed02
463 changed files with 72045 additions and 67421 deletions
|
|
@ -1,32 +1,30 @@
|
|||
# fake - a place for the people: dry flat ground east of x = -50 and a lake west of it, a camp at
|
||||
# (40, 0) nobody may stop in, two players, and what the port was asked to draw
|
||||
numbers float
|
||||
export state NpcTestsFakeState {
|
||||
fk_hour: float = 12.0
|
||||
fk_day: int = 1
|
||||
fk_want: int = 0
|
||||
fk_extra: int = -1
|
||||
fk_px: []float = null
|
||||
fk_pz: []float = null
|
||||
fk_on: []bool = null
|
||||
fk_born: int = 0
|
||||
fk_gone: int = 0
|
||||
}
|
||||
var fk_hour: float = 12.0
|
||||
var fk_day: int = 1
|
||||
var fk_want: int = 0
|
||||
var fk_extra: int = -1
|
||||
var fk_px: []float = null
|
||||
var fk_pz: []float = null
|
||||
var fk_on: []bool = null
|
||||
var fk_born: int = 0
|
||||
var fk_gone: int = 0
|
||||
|
||||
function fk_setup(base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState) -> void {
|
||||
npc_tests_fake_st.fk_hour = 12.0
|
||||
npc_tests_fake_st.fk_day = 1
|
||||
npc_tests_fake_st.fk_want = 0
|
||||
npc_tests_fake_st.fk_extra = -1
|
||||
npc_tests_fake_st.fk_px = [500.0, 900.0]
|
||||
npc_tests_fake_st.fk_pz = [500.0, 900.0]
|
||||
npc_tests_fake_st.fk_on = [true, false]
|
||||
npc_tests_fake_st.fk_born = 0
|
||||
npc_tests_fake_st.fk_gone = 0
|
||||
npc_clear(npc_st)
|
||||
npc_reset(base_st, npc_st)
|
||||
npc_seed(npc_st, 7)
|
||||
npc_config(npc_st, 10)
|
||||
function fk_setup() -> void {
|
||||
fk_hour = 12.0
|
||||
fk_day = 1
|
||||
fk_want = 0
|
||||
fk_extra = -1
|
||||
fk_px = [500.0, 900.0]
|
||||
fk_pz = [500.0, 900.0]
|
||||
fk_on = [true, false]
|
||||
fk_born = 0
|
||||
fk_gone = 0
|
||||
npc_clear()
|
||||
npc_reset()
|
||||
npc_seed(7)
|
||||
npc_config(10)
|
||||
}
|
||||
|
||||
function fk_ground(x: float, z: float) -> float { return 0.0 }
|
||||
|
|
@ -35,28 +33,28 @@ function fk_water(x: float, z: float) -> float {
|
|||
return -100.0
|
||||
}
|
||||
function fk_allowed(x: float, z: float) -> bool { return npc_d(x, z, 40.0, 0.0) > 15.0 }
|
||||
function fk_hour_now(npc_tests_fake_st: NpcTestsFakeState) -> float { return npc_tests_fake_st.fk_hour }
|
||||
function fk_day_now(npc_tests_fake_st: NpcTestsFakeState) -> int { return npc_tests_fake_st.fk_day }
|
||||
function fk_hour_now() -> float { return fk_hour }
|
||||
function fk_day_now() -> int { return fk_day }
|
||||
function fk_players() -> int { return 2 }
|
||||
function fk_player_on(npc_tests_fake_st: NpcTestsFakeState, i: int) -> bool { return npc_tests_fake_st.fk_on[i] }
|
||||
function fk_x(npc_tests_fake_st: NpcTestsFakeState, i: int) -> float { return npc_tests_fake_st.fk_px[i] }
|
||||
function fk_z(npc_tests_fake_st: NpcTestsFakeState, i: int) -> float { return npc_tests_fake_st.fk_pz[i] }
|
||||
function fk_wanted(npc_tests_fake_st: NpcTestsFakeState) -> int { return npc_tests_fake_st.fk_want }
|
||||
function fk_extra_kind(npc_tests_fake_st: NpcTestsFakeState) -> int { return npc_tests_fake_st.fk_extra }
|
||||
function fk_player_on(i: int) -> bool { return fk_on[i] }
|
||||
function fk_x(i: int) -> float { return fk_px[i] }
|
||||
function fk_z(i: int) -> float { return fk_pz[i] }
|
||||
function fk_wanted() -> int { return fk_want }
|
||||
function fk_extra_kind() -> int { return fk_extra }
|
||||
function fk_taken(n: string) -> bool { return n == "Ada" }
|
||||
function fk_on_born(npc_tests_fake_st: mut NpcTestsFakeState, p: NpcPerson) -> void { npc_tests_fake_st.fk_born += 1 }
|
||||
function fk_on_gone(npc_tests_fake_st: mut NpcTestsFakeState, p: NpcPerson) -> void { npc_tests_fake_st.fk_gone += 1 }
|
||||
function fk_on_born(p: NpcPerson) -> void { fk_born += 1 }
|
||||
function fk_on_gone(p: NpcPerson) -> void { fk_gone += 1 }
|
||||
|
||||
function fk_player_at(npc_tests_fake_st: mut NpcTestsFakeState, x: float, z: float) -> void {
|
||||
npc_tests_fake_st.fk_px[0] = x
|
||||
npc_tests_fake_st.fk_pz[0] = z
|
||||
function fk_player_at(x: float, z: float) -> void {
|
||||
fk_px[0] = x
|
||||
fk_pz[0] = z
|
||||
}
|
||||
|
||||
# seconds of the place, in twentieths
|
||||
function fk_run(base_st: mut BaseState, npc_st: mut NpcState, secs: float) -> void { for k in 0 .. int(secs * 20.0) { npc_tick(base_st, npc_st, 0.05) } }
|
||||
function fk_run(secs: float) -> void { for k in 0 .. int(secs * 20.0) { npc_tick(0.05) } }
|
||||
|
||||
function fk_count(base_st: mut BaseState, npc_st: mut NpcState, what: int) -> int {
|
||||
let fs = q_drain(base_st, npc_facts(base_st, npc_st))
|
||||
function fk_count(what: int) -> int {
|
||||
let fs = q_drain(npc_facts())
|
||||
var n = 0
|
||||
for i in 0 .. len(fs) { if fs[i].what == what { n += 1 } }
|
||||
return n
|
||||
|
|
|
|||
|
|
@ -30,20 +30,18 @@ program NpcTest {
|
|||
def NpcNames from "names.lres"
|
||||
def NpcLines from "lines.lres"
|
||||
|
||||
state NpctestState {
|
||||
news_on: bool = false
|
||||
}
|
||||
function tk_say(npctest_st: NpctestState, p: NpcPerson, line: int) -> string {
|
||||
if npctest_st.news_on { return `{p.name} saw a bear.` }
|
||||
var news_on: bool = false
|
||||
function tk_say(p: NpcPerson, line: int) -> string {
|
||||
if news_on { return `{p.name} saw a bear.` }
|
||||
return ""
|
||||
}
|
||||
function tk_greeting(p: NpcPerson) -> string { return "What'll it be?" }
|
||||
function tk_start(npc_st: mut NpcState, p: NpcPerson) -> void { npc_start_near(npc_st, p, 0.0, 0.0, 0.0, 10.0) }
|
||||
function tk_start(p: NpcPerson) -> void { npc_start_near(p, 0.0, 0.0, 0.0, 10.0) }
|
||||
|
||||
function one(base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState, kind: int) -> NpcPerson {
|
||||
fk_setup(base_st, npc_st, npc_tests_fake_st)
|
||||
npc_tests_fake_st.fk_want = 1
|
||||
let p = npc_spawn(npc_st, kind)
|
||||
function one(kind: int) -> NpcPerson {
|
||||
fk_setup()
|
||||
fk_want = 1
|
||||
let p = npc_spawn(kind)
|
||||
npc_set_at(p, 0.0, 0.0)
|
||||
return p
|
||||
}
|
||||
|
|
@ -58,175 +56,175 @@ program NpcTest {
|
|||
expect_eq(NPCN_COUNT, 14)
|
||||
}
|
||||
|
||||
test "the census fills to what the place wants, by weight, and after dark only who stays out" (base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState) {
|
||||
fk_setup(base_st, npc_st, npc_tests_fake_st)
|
||||
npc_tests_fake_st.fk_want = 4
|
||||
npc_tick(base_st, npc_st, 0.05)
|
||||
expect_eq(npc_count(npc_st), 4)
|
||||
expect_eq(npc_tests_fake_st.fk_born, 4)
|
||||
expect_eq(npc_name_clashes(npc_st), 0)
|
||||
for i in 0 .. len(npc_walkers(npc_st)) { expect(npc_walkers(npc_st)[i].kind != NPCK_VENDOR) }
|
||||
fk_setup(base_st, npc_st, npc_tests_fake_st)
|
||||
npc_tests_fake_st.fk_want = 3
|
||||
npc_tests_fake_st.fk_hour = 23.0
|
||||
npc_tick(base_st, npc_st, 0.05)
|
||||
expect_eq(npc_count(npc_st), 3)
|
||||
for i in 0 .. len(npc_walkers(npc_st)) { expect_eq(npc_walkers(npc_st)[i].kind, NPCK_CAMPER) }
|
||||
test "the census fills to what the place wants, by weight, and after dark only who stays out" {
|
||||
fk_setup()
|
||||
fk_want = 4
|
||||
npc_tick(0.05)
|
||||
expect_eq(npc_count(), 4)
|
||||
expect_eq(fk_born, 4)
|
||||
expect_eq(npc_name_clashes(), 0)
|
||||
for i in 0 .. len(npc_walkers()) { expect(npc_walkers()[i].kind != NPCK_VENDOR) }
|
||||
fk_setup()
|
||||
fk_want = 3
|
||||
fk_hour = 23.0
|
||||
npc_tick(0.05)
|
||||
expect_eq(npc_count(), 3)
|
||||
for i in 0 .. len(npc_walkers()) { expect_eq(npc_walkers()[i].kind, NPCK_CAMPER) }
|
||||
}
|
||||
|
||||
test "no name twice, and never one the place keeps" (base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState) {
|
||||
fk_setup(base_st, npc_st, npc_tests_fake_st)
|
||||
npc_tests_fake_st.fk_want = 6
|
||||
npc_tick(base_st, npc_st, 0.05)
|
||||
expect_eq(npc_count(npc_st), 6)
|
||||
expect_eq(npc_name_clashes(npc_st), 0)
|
||||
for i in 0 .. 6 { expect(npc_walkers(npc_st)[i].name != "Ada") }
|
||||
test "no name twice, and never one the place keeps" {
|
||||
fk_setup()
|
||||
fk_want = 6
|
||||
npc_tick(0.05)
|
||||
expect_eq(npc_count(), 6)
|
||||
expect_eq(npc_name_clashes(), 0)
|
||||
for i in 0 .. 6 { expect(npc_walkers()[i].name != "Ada") }
|
||||
}
|
||||
|
||||
test "it walks to where it is going and begins there, facing what it came for" (base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState) {
|
||||
let p = one(base_st, npc_st, npc_tests_fake_st, NPCK_HIKER)
|
||||
npc_go(npc_st, p, 20.0, 0.0, NPCA_SIT, 30.0)
|
||||
test "it walks to where it is going and begins there, facing what it came for" {
|
||||
let p = one(NPCK_HIKER)
|
||||
npc_go(p, 20.0, 0.0, NPCA_SIT, 30.0)
|
||||
npc_face(p, 30.0, 0.0)
|
||||
fk_run(base_st, npc_st, 30.0)
|
||||
fk_run(30.0)
|
||||
expect_eq(p.act, NPCA_SIT)
|
||||
expect(npc_d(p.x, p.z, 20.0, 0.0) < 1.3)
|
||||
expect(p.phase > 20.0)
|
||||
expect_eq(fk_count(base_st, npc_st, NPC_F_ARRIVED), 1)
|
||||
expect_eq(fk_count(NPC_F_ARRIVED), 1)
|
||||
expect_near(p.fx, 30.0, 0.01)
|
||||
}
|
||||
|
||||
test "nobody walks into the lake" (base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState) {
|
||||
let p = one(base_st, npc_st, npc_tests_fake_st, NPCK_HIKER)
|
||||
npc_go(npc_st, p, -80.0, 0.0, NPCA_SIT, 30.0)
|
||||
test "nobody walks into the lake" {
|
||||
let p = one(NPCK_HIKER)
|
||||
npc_go(p, -80.0, 0.0, NPCA_SIT, 30.0)
|
||||
var west = 0.0
|
||||
for k in 0 .. 1200 {
|
||||
npc_tick(base_st, npc_st, 0.05)
|
||||
npc_tick(0.05)
|
||||
west = Math.min(west, p.x)
|
||||
}
|
||||
expect(west > -50.5)
|
||||
}
|
||||
|
||||
test "a step's spot is where its hours say: the shore by day, home by night" (base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState) {
|
||||
let p = one(base_st, npc_st, npc_tests_fake_st, NPCK_CAMPER)
|
||||
test "a step's spot is where its hours say: the shore by day, home by night" {
|
||||
let p = one(NPCK_CAMPER)
|
||||
npc_set_at(p, -20.0, 0.0)
|
||||
npc_tests_fake_st.fk_hour = 12.0
|
||||
npc_plan(npc_st, p)
|
||||
fk_hour = 12.0
|
||||
npc_plan(p)
|
||||
expect_eq(p.act, NPCA_WALK)
|
||||
expect_eq(p.next_act, NPCA_FISH)
|
||||
expect(p.fx < -50.0)
|
||||
npc_tests_fake_st.fk_hour = 23.0
|
||||
npc_plan(npc_st, p)
|
||||
fk_hour = 23.0
|
||||
npc_plan(p)
|
||||
expect_eq(p.act, NPCA_SIT)
|
||||
}
|
||||
|
||||
test "an act is not begun where the place says nobody stops" (base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState) {
|
||||
let p = one(base_st, npc_st, npc_tests_fake_st, NPCK_HIKER)
|
||||
test "an act is not begun where the place says nobody stops" {
|
||||
let p = one(NPCK_HIKER)
|
||||
npc_set_at(p, 40.0, 0.0)
|
||||
npc_do(npc_st, p, NPCA_SIT, 30.0)
|
||||
npc_do(p, NPCA_SIT, 30.0)
|
||||
expect_eq(p.act, NPCA_WALK)
|
||||
expect(fk_allowed(p.tx, p.tz))
|
||||
}
|
||||
|
||||
test "it turns to a player who comes near, greets them once, and again after they have gone" (base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState) {
|
||||
let p = one(base_st, npc_st, npc_tests_fake_st, NPCK_HIKER)
|
||||
npc_do(npc_st, p, NPCA_IDLE, 100.0)
|
||||
test "it turns to a player who comes near, greets them once, and again after they have gone" {
|
||||
let p = one(NPCK_HIKER)
|
||||
npc_do(p, NPCA_IDLE, 100.0)
|
||||
p.yaw = 0.0
|
||||
fk_player_at(npc_tests_fake_st, 0.0, 0.0 - 5.0)
|
||||
fk_run(base_st, npc_st, 2.0)
|
||||
fk_player_at(0.0, 0.0 - 5.0)
|
||||
fk_run(2.0)
|
||||
expect(Math.abs(p.yaw) < 0.05)
|
||||
fk_player_at(npc_tests_fake_st, 5.0, 0.0)
|
||||
fk_run(base_st, npc_st, 3.0)
|
||||
fk_player_at(5.0, 0.0)
|
||||
fk_run(3.0)
|
||||
expect(Math.abs(npc_wrap(p.yaw + 1.5707963)) < 0.05)
|
||||
fk_run(base_st, npc_st, 1.0)
|
||||
expect_eq(fk_count(base_st, npc_st, NPC_F_GREETED), 1)
|
||||
fk_player_at(npc_tests_fake_st, 40.0, 0.0)
|
||||
fk_run(base_st, npc_st, 0.5)
|
||||
fk_player_at(npc_tests_fake_st, 5.0, 0.0)
|
||||
fk_run(base_st, npc_st, 0.5)
|
||||
expect_eq(fk_count(base_st, npc_st, NPC_F_GREETED), 1)
|
||||
fk_run(1.0)
|
||||
expect_eq(fk_count(NPC_F_GREETED), 1)
|
||||
fk_player_at(40.0, 0.0)
|
||||
fk_run(0.5)
|
||||
fk_player_at(5.0, 0.0)
|
||||
fk_run(0.5)
|
||||
expect_eq(fk_count(NPC_F_GREETED), 1)
|
||||
}
|
||||
|
||||
test "a fisher keeps its eyes on the water, whoever is near" (base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState) {
|
||||
let p = one(base_st, npc_st, npc_tests_fake_st, NPCK_HIKER)
|
||||
npc_do(npc_st, p, NPCA_FISH, 100.0)
|
||||
test "a fisher keeps its eyes on the water, whoever is near" {
|
||||
let p = one(NPCK_HIKER)
|
||||
npc_do(p, NPCA_FISH, 100.0)
|
||||
p.yaw = 0.0
|
||||
npc_face(p, 0.0, -10.0)
|
||||
fk_player_at(npc_tests_fake_st, 5.0, 0.0)
|
||||
fk_run(base_st, npc_st, 2.0)
|
||||
fk_player_at(5.0, 0.0)
|
||||
fk_run(2.0)
|
||||
expect(Math.abs(p.yaw) < 0.05)
|
||||
}
|
||||
|
||||
test "the day ends out of sight, and not in it" (base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState) {
|
||||
let p = one(base_st, npc_st, npc_tests_fake_st, NPCK_HIKER)
|
||||
npc_do(npc_st, p, NPCA_IDLE, 1000.0)
|
||||
npc_tests_fake_st.fk_hour = 22.5
|
||||
fk_player_at(npc_tests_fake_st, 20.0, 0.0)
|
||||
fk_run(base_st, npc_st, 0.5)
|
||||
test "the day ends out of sight, and not in it" {
|
||||
let p = one(NPCK_HIKER)
|
||||
npc_do(p, NPCA_IDLE, 1000.0)
|
||||
fk_hour = 22.5
|
||||
fk_player_at(20.0, 0.0)
|
||||
fk_run(0.5)
|
||||
expect(p.active)
|
||||
fk_player_at(npc_tests_fake_st, 500.0, 0.0)
|
||||
fk_run(base_st, npc_st, 0.5)
|
||||
fk_player_at(500.0, 0.0)
|
||||
fk_run(0.5)
|
||||
expect(not p.active)
|
||||
expect_eq(npc_tests_fake_st.fk_gone, 1)
|
||||
let c = one(base_st, npc_st, npc_tests_fake_st, NPCK_CAMPER)
|
||||
npc_do(npc_st, c, NPCA_IDLE, 1000.0)
|
||||
npc_tests_fake_st.fk_hour = 22.5
|
||||
fk_run(base_st, npc_st, 0.5)
|
||||
expect_eq(fk_gone, 1)
|
||||
let c = one(NPCK_CAMPER)
|
||||
npc_do(c, NPCA_IDLE, 1000.0)
|
||||
fk_hour = 22.5
|
||||
fk_run(0.5)
|
||||
expect(c.active)
|
||||
}
|
||||
|
||||
test "lines: the highest that has something to say, the story's words, and choices" (base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState, npctest_st: mut NpctestState) {
|
||||
let p = one(base_st, npc_st, npc_tests_fake_st, NPCK_CAMPER)
|
||||
npc_do(npc_st, p, NPCA_FISH, 100.0)
|
||||
expect_eq(npc_talk(base_st, npc_st, p, 0), NPCL_HUSH)
|
||||
expect(npc_said(npc_st) == "Shh.")
|
||||
test "lines: the highest that has something to say, the story's words, and choices" {
|
||||
let p = one(NPCK_CAMPER)
|
||||
npc_do(p, NPCA_FISH, 100.0)
|
||||
expect_eq(npc_talk(p, 0), NPCL_HUSH)
|
||||
expect(npc_said() == "Shh.")
|
||||
expect(npc_talked_today(p))
|
||||
npc_do(npc_st, p, NPCA_IDLE, 100.0)
|
||||
expect_eq(npc_line_for(npc_st, p), NPCL_HELLO)
|
||||
npctest_st.news_on = true
|
||||
expect_eq(npc_line_for(npc_st, p), NPCL_NEWS)
|
||||
expect(npc_said(npc_st) == `{p.name} saw a bear.`)
|
||||
npctest_st.news_on = false
|
||||
expect_eq(npc_choose(base_st, npc_st, p, NPCL_HELLO, 0, 0), NPCL_FISH_NO)
|
||||
expect(npc_said(npc_st) == "Not today.")
|
||||
expect_eq(npc_choose(base_st, npc_st, p, NPCL_HELLO, 1, 0), -1)
|
||||
let fs = q_drain(base_st, npc_facts(base_st, npc_st))
|
||||
npc_do(p, NPCA_IDLE, 100.0)
|
||||
expect_eq(npc_line_for(p), NPCL_HELLO)
|
||||
news_on = true
|
||||
expect_eq(npc_line_for(p), NPCL_NEWS)
|
||||
expect(npc_said() == `{p.name} saw a bear.`)
|
||||
news_on = false
|
||||
expect_eq(npc_choose(p, NPCL_HELLO, 0, 0), NPCL_FISH_NO)
|
||||
expect(npc_said() == "Not today.")
|
||||
expect_eq(npc_choose(p, NPCL_HELLO, 1, 0), -1)
|
||||
let fs = q_drain(npc_facts())
|
||||
expect_eq(len(fs), 3)
|
||||
expect_eq(fs[1].choice, 7)
|
||||
expect(npc_greeting(p) == "What'll it be?")
|
||||
}
|
||||
|
||||
test "a post stands where it was put, is not counted, and turns back when nobody is near" (base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState) {
|
||||
fk_setup(base_st, npc_st, npc_tests_fake_st)
|
||||
let v = npc_place(npc_st, NPCK_VENDOR, 0.0, 0.0, 0.0, "Mateo", 5)
|
||||
test "a post stands where it was put, is not counted, and turns back when nobody is near" {
|
||||
fk_setup()
|
||||
let v = npc_place(NPCK_VENDOR, 0.0, 0.0, 0.0, "Mateo", 5)
|
||||
expect(v.fixed)
|
||||
expect_eq(npc_count(npc_st), 0)
|
||||
fk_player_at(npc_tests_fake_st, 8.0, 0.0)
|
||||
fk_run(base_st, npc_st, 3.0)
|
||||
expect_eq(npc_count(), 0)
|
||||
fk_player_at(8.0, 0.0)
|
||||
fk_run(3.0)
|
||||
expect(Math.abs(npc_wrap(v.yaw + 1.5707963)) < 0.05)
|
||||
fk_player_at(npc_tests_fake_st, 300.0, 0.0)
|
||||
fk_run(base_st, npc_st, 3.0)
|
||||
fk_player_at(300.0, 0.0)
|
||||
fk_run(3.0)
|
||||
expect(Math.abs(v.yaw) < 0.05)
|
||||
expect(npc_d(v.x, v.z, 0.0, 0.0) < 0.001)
|
||||
expect(npc_by_id(npc_st, v.id).name == "Mateo")
|
||||
expect(npc_by_id(v.id).name == "Mateo")
|
||||
}
|
||||
|
||||
test "a guest's copy: the host's slot put, heard and eased toward, and not drawn once it goes quiet" (base_st: mut BaseState, npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState) {
|
||||
fk_setup(base_st, npc_st, npc_tests_fake_st)
|
||||
npc_tests_fake_st.fk_want = 2
|
||||
npc_tick(base_st, npc_st, 0.05)
|
||||
npc_mirror(npc_st, true)
|
||||
expect_eq(npc_count(npc_st), 0)
|
||||
let p = npc_put(npc_st, 3, 99, NPCK_HIKER, 12, 1.5, "Wren", 10.0, 10.0)
|
||||
test "a guest's copy: the host's slot put, heard and eased toward, and not drawn once it goes quiet" {
|
||||
fk_setup()
|
||||
fk_want = 2
|
||||
npc_tick(0.05)
|
||||
npc_mirror(true)
|
||||
expect_eq(npc_count(), 0)
|
||||
let p = npc_put(3, 99, NPCK_HIKER, 12, 1.5, "Wren", 10.0, 10.0)
|
||||
expect(p.active)
|
||||
expect_eq(npc_count(npc_st), 1)
|
||||
npc_heard(npc_st, 3, 10.0, 0.0, 10.0, 0.0, 1.2, NPCA_WALK, false)
|
||||
npc_heard(npc_st, 3, 12.0, 0.0, 10.0, 0.0, 1.2, NPCA_WALK, false)
|
||||
for k in 0 .. 40 { npc_mirror_tick(npc_st, 0.05) }
|
||||
expect_eq(npc_count(), 1)
|
||||
npc_heard(3, 10.0, 0.0, 10.0, 0.0, 1.2, NPCA_WALK, false)
|
||||
npc_heard(3, 12.0, 0.0, 10.0, 0.0, 1.2, NPCA_WALK, false)
|
||||
for k in 0 .. 40 { npc_mirror_tick(0.05) }
|
||||
expect_near(p.x, 12.0, 0.01)
|
||||
expect(p.phase > 0.0)
|
||||
npc_tick(base_st, npc_st, 0.05)
|
||||
npc_tick(0.05)
|
||||
expect_near(p.x, 12.0, 0.01)
|
||||
for k in 0 .. 140 { npc_mirror_tick(npc_st, 0.05) }
|
||||
expect(not npc_heard_lately(npc_st, p))
|
||||
for k in 0 .. 140 { npc_mirror_tick(0.05) }
|
||||
expect(not npc_heard_lately(p))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue