P07-01-WX: 仕上がった天候の機能の受入:自然天候・雨・嵐・世界樹と成人客のマナ霧・上部の表示と予報・保存と移行(マナ炉の産出 120 を除く。P07-01 の補助の作業。原単位への加算 0)
This commit is contained in:
@@ -5,8 +5,12 @@ extends RefCounted
|
||||
## (tests/environment/test_p07_weather_restart_2_read.gd), which run as separate
|
||||
## engine processes. Seed 1106 opens day 0 with rain 06:00-12:00 (A13), a guest
|
||||
## due at 06:02 is held to 10:02, production arrivals run, and day 1 draws at 06:00.
|
||||
## The fog scene (WX7): seed 1592 opens day 0 with mana fog 06:00-10:00, two
|
||||
## adult-verified guests arrive at 06:58 and 09:58 (with no facility in this
|
||||
## world a guest leaves after a few minutes, so each one is present at its
|
||||
## saves), and the saves bracket the 07:00 mana boundary and the fog end.
|
||||
const HANDOFF_PATH := "res://artifacts/p07-01/restart-handoff.json"
|
||||
const HANDOFF_SCHEMA := "p07-01-restart-handoff-v1"
|
||||
const HANDOFF_SCHEMA := "p07-01-restart-handoff-v2"
|
||||
const WRITER_SOURCE := "res://tests/environment/test_p07_weather_restart_1_write.gd"
|
||||
const WRITER_SAVE := "user://p07_restart_write/minute_%d"
|
||||
const READER_SAVE := "user://p07_restart_read/minute_%d"
|
||||
@@ -17,6 +21,13 @@ const SAVE_MINUTES: Array[int] = [500, 719, 720, 1799, 1800]
|
||||
const LAST_MINUTE := 1830
|
||||
const DRAW_MINUTES: Array[int] = [1800]
|
||||
const HELD_GUEST := &"p07_restart_guest"
|
||||
const FOG_SEED := 1592
|
||||
const FOG_WRITER_SAVE := "user://p07_restart_write/fog_minute_%d"
|
||||
const FOG_READER_SAVE := "user://p07_restart_read/fog_minute_%d"
|
||||
# Just before, at and after the 07:00 mana boundary in fog; just before, at and after the fog end.
|
||||
const FOG_SAVE_MINUTES: Array[int] = [419, 420, 421, 599, 600, 601]
|
||||
const FOG_LAST_MINUTE := 630
|
||||
const FOG_ADULTS := {418: &"p07_restart_fog_adult_a", 598: &"p07_restart_fog_adult_b"}
|
||||
|
||||
var _expect: Callable
|
||||
|
||||
@@ -25,18 +36,18 @@ func _init(expect: Callable) -> void:
|
||||
_expect = expect
|
||||
|
||||
|
||||
func new_fixture(with_guest := true) -> Dictionary:
|
||||
func new_fixture(with_guest := true, seed := SEED) -> Dictionary:
|
||||
var clock: Variant = load("res://autoload/game_clock.gd").new()
|
||||
var state: Variant = load("res://autoload/game_state.gd").new()
|
||||
var runtime: Variant = load("res://autoload/simulation_runtime.gd").new()
|
||||
clock.reset(1, 6, 0)
|
||||
state.reset()
|
||||
_expect.call(bool(runtime.initialize(clock, state, SEED).get(&"valid", false)), "fixture Runtime initializes")
|
||||
_expect.call(bool(runtime.initialize(clock, state, seed).get(&"valid", false)), "fixture Runtime initializes")
|
||||
clock.set_paused(true)
|
||||
runtime.configure_save_policy({&"enabled": false, &"daily_checkpoint_enabled": false})
|
||||
_expect.call(bool(runtime.enable_production_operations().get(&"ok", false)), "fixture enables production Operations")
|
||||
var fixture := {&"clock": clock, &"state": state, &"runtime": runtime, &"draws": {&"count": 0}}
|
||||
if with_guest:
|
||||
var fixture := {&"clock": clock, &"state": state, &"runtime": runtime, &"draws": {&"count": 0}, &"seed": seed}
|
||||
if with_guest and seed == SEED:
|
||||
var result: CommandResult = runtime.submit_command(&"spawn_guest", {
|
||||
&"guest_id": HELD_GUEST,
|
||||
&"guest_type_id": &"traveler",
|
||||
@@ -65,22 +76,51 @@ func free_fixture(fixture: Dictionary) -> void:
|
||||
|
||||
|
||||
## Advances one minute at a time after `after_minute` through `through_minute`
|
||||
## and calls `on_minute` after each minute (the writer saves there).
|
||||
## and calls `on_minute` after each minute (the writer saves there). In the fog
|
||||
## scene the adult-verified guests arrive at their minutes in every run.
|
||||
func play(fixture: Dictionary, after_minute: int, through_minute: int, on_minute: Callable) -> void:
|
||||
var clock: Variant = fixture[&"clock"]
|
||||
_expect.call(clock.absolute_minute == after_minute, "play starts at minute %d" % after_minute)
|
||||
for minute: int in range(after_minute + 1, through_minute + 1):
|
||||
clock.advance_minutes(1)
|
||||
if fixture[&"seed"] == FOG_SEED and FOG_ADULTS.has(minute):
|
||||
_spawn_adult(fixture[&"runtime"], FOG_ADULTS[minute])
|
||||
if on_minute.is_valid():
|
||||
on_minute.call(minute)
|
||||
|
||||
|
||||
func _spawn_adult(runtime: Variant, guest_id: StringName) -> void:
|
||||
var result: CommandResult = runtime.submit_command(&"spawn_guest", {
|
||||
&"guest_id": guest_id,
|
||||
&"guest_type_id": &"adventurer",
|
||||
&"gold": 100,
|
||||
&"options": {
|
||||
&"current_cell": Vector3i(0, 0, WorldService.LAYER_FRONT),
|
||||
&"needs": {&"hunger": 10, &"sleep": 10, &"hygiene": 10, &"medical": 0, &"leisure": 10, &"intimacy": 0},
|
||||
&"planned_exit_at": 2000,
|
||||
},
|
||||
}, &"world", guest_id, 10, -1, StringName("p07.restart." + String(guest_id)))
|
||||
_expect.call(result.is_success(), "the fog scene spawns the adult-verified guest %s" % guest_id)
|
||||
|
||||
|
||||
## The weather-facing state compared across processes: weather and its stream,
|
||||
## guest plans, the reserve flow and the arrival totals.
|
||||
## guest plans and needs (the fog intimacy), the whole reserve with its last
|
||||
## flow (the fog yield) and the arrival totals. Needs are listed in text order of
|
||||
## their names, because a loaded guest may keep its needs in another key order
|
||||
## (StringName ordering is not text ordering and differs between processes).
|
||||
func state_value(runtime: Variant) -> Dictionary:
|
||||
var plans := {}
|
||||
var needs := {}
|
||||
for guest: GuestRuntime in runtime.guest_service.get_guests():
|
||||
plans[String(guest.guest_id)] = guest.planned_exit_at
|
||||
var names: Array[String] = []
|
||||
for name: Variant in guest.needs:
|
||||
names.append(String(name))
|
||||
names.sort()
|
||||
var row := {}
|
||||
for name: String in names:
|
||||
row[name] = guest.needs[name]
|
||||
needs[String(guest.guest_id)] = row
|
||||
var arrivals := 0
|
||||
for report: Dictionary in runtime.operations_coordinator.get_arrival_reports():
|
||||
arrivals += int(report[&"total_count"])
|
||||
@@ -89,6 +129,8 @@ func state_value(runtime: Variant) -> Dictionary:
|
||||
"weather": runtime.weather.create_snapshot(),
|
||||
"stream": runtime.get_rng_stream(&"weather").snapshot(),
|
||||
"plans": plans,
|
||||
"needs": needs,
|
||||
"reserve": runtime.mana_reserve.create_snapshot(),
|
||||
"reserve_flow": runtime.mana_reserve.get_last_flow(),
|
||||
"arrivals": arrivals,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user