P23-03: 生活の観察
This commit is contained in:
Vendored
+35
-6
@@ -2,6 +2,7 @@ extends "res://tests/fixtures/p08-03/placement.gd"
|
||||
## Real Runtime commands; inherited formal codec/save-operation helpers unchanged.
|
||||
const Stream := preload("res://tests/fixtures/p23-03/diagnostic_stream.gd")
|
||||
const Comparison := preload("res://tests/fixtures/p23-03/layout_comparison.gd")
|
||||
const PurchaseQuoteV2 := preload("res://scripts/supply/supply_purchase_quote_v2.gd")
|
||||
var stream: RefCounted
|
||||
var layout := "A"
|
||||
var facility_ids: Dictionary = {}
|
||||
@@ -28,7 +29,7 @@ func setup() -> void:
|
||||
|
||||
func command(id: StringName, payload: Dictionary) -> bool:
|
||||
var result: CommandResult = runtime.submit_command(id, payload)
|
||||
expect(result.is_success(), String(id) + ": " + str(result.code))
|
||||
expect(result.is_success(), String(id) + " " + str(payload) + ": " + str(result.code))
|
||||
expect(stream.record("command", {&"command": id, &"payload": payload,
|
||||
&"result": result.to_dictionary(), &"minute": clock.absolute_minute}), "record public command")
|
||||
return result.is_success()
|
||||
@@ -46,7 +47,7 @@ func observe_progress() -> void:
|
||||
pass
|
||||
|
||||
func prepare() -> void:
|
||||
# Both layouts receive the same definition-derived diagnostic construction budget.
|
||||
# Both layouts receive the same runtime-derived budget for all setup spends.
|
||||
# Cafeteria/kitchen move together to x=6, leaving x=4..5 for the declared B EV.
|
||||
var builds: Array = [[&"reception", Vector3i(-8, 0, 0)],
|
||||
[&"cafeteria", Vector3i(6, 0, 0)], [&"warehouse", Vector3i(-8, 0, 1)],
|
||||
@@ -59,6 +60,9 @@ func prepare() -> void:
|
||||
var improvement: Dictionary = Comparison.new().declaration()[&"improvement"]
|
||||
var budget_builds := builds.duplicate(true)
|
||||
budget_builds.append([improvement[&"definition_id"], improvement[&"origin"]])
|
||||
var assignments: Array = [[&"staff_akane", &"reception"], [&"staff_gina", &"warehouse"],
|
||||
[&"staff_chika", &"kitchen"], [&"staff_iris", &"cafeteria"], [&"staff_juno", &"cafeteria"]]
|
||||
var purchase_quantity := 40
|
||||
var needed := {&"gold": 0, &"materials": 0}
|
||||
var costs: Array = []
|
||||
for row: Array in budget_builds:
|
||||
@@ -66,13 +70,36 @@ func prepare() -> void:
|
||||
costs.append({&"definition": row[0], &"cost": definition.construction_cost.duplicate(true)})
|
||||
for key: StringName in needed:
|
||||
needed[key] += int(definition.construction_cost.get(key, 0))
|
||||
var construction_total := needed.duplicate(true)
|
||||
var signing_costs: Array = []
|
||||
var signing_total := 0
|
||||
for assignment: Array in assignments:
|
||||
var candidate: Dictionary = runtime.mvp_content_catalog.get_recruitment_entry(assignment[0])
|
||||
expect(candidate.has(&"signing_cost"), "registered signing cost " + String(assignment[0]))
|
||||
var signing_cost := int(candidate[&"signing_cost"])
|
||||
signing_costs.append({&"candidate_id": assignment[0], &"signing_cost": signing_cost,
|
||||
&"source": "MvpContentCatalog.get_recruitment_entry.signing_cost"})
|
||||
signing_total += signing_cost
|
||||
needed[&"gold"] += signing_total
|
||||
# Before warehouse construction, use the purchase service's catalog/quote
|
||||
# branch. Check this total against its live preview immediately before buying.
|
||||
var item := SupplyCatalog.get_item(SupplyCatalog.RAW_FOOD)
|
||||
var purchase_quote := PurchaseQuoteV2.make(SupplyCatalog.RAW_FOOD, purchase_quantity, int(item[&"unit_price"]))
|
||||
expect(not purchase_quote.is_empty(), "registered raw-food purchase quote")
|
||||
var purchase_total := int(purchase_quote[&"effective_total"] if PurchaseQuoteV2.eligible(runtime) else purchase_quote[&"base_total"])
|
||||
needed[&"gold"] += purchase_total
|
||||
var purchase_cost := {&"item_id": SupplyCatalog.RAW_FOOD, &"quantity": purchase_quantity,
|
||||
&"unit_price": item[&"unit_price"], &"quote": purchase_quote, &"total_cost": purchase_total,
|
||||
&"source": "SupplyCatalog.unit_price / PurchaseQuoteV2.make; preview_purchase eligibility"}
|
||||
var state: Variant = tree.root.get_node("GameState")
|
||||
var deltas := {}
|
||||
for key: StringName in needed:
|
||||
if needed[key] > state.get_resource(key):
|
||||
deltas[key] = needed[key] - state.get_resource(key)
|
||||
budget = {"setup": "diagnostic", "costs": costs, "needed": needed,
|
||||
"initial": state.resources.duplicate(true), "deltas": deltas}
|
||||
"initial": state.resources.duplicate(true), "deltas": deltas,
|
||||
"construction_total": construction_total, "signing_costs": signing_costs,
|
||||
"signing_total": signing_total, "purchase_cost": purchase_cost}
|
||||
if not deltas.is_empty(): command(&"change_resources", {&"deltas": deltas})
|
||||
expect(stream.record("budget", budget), "common diagnostic budget")
|
||||
if layout == "B": builds.append([improvement[&"definition_id"], improvement[&"origin"]])
|
||||
@@ -90,13 +117,15 @@ func prepare() -> void:
|
||||
facility_ids[facility.definition_id] = facility.instance_id
|
||||
command(&"set_facility_conditions", {&"facility_id": facility_ids[&"cafeteria"],
|
||||
&"conditions": {&"related_facility_id": facility_ids[&"kitchen"]}})
|
||||
for assignment: Array in [[&"staff_akane", &"reception"], [&"staff_gina", &"warehouse"],
|
||||
[&"staff_chika", &"kitchen"], [&"staff_iris", &"cafeteria"], [&"staff_juno", &"cafeteria"]]:
|
||||
for assignment: Array in assignments:
|
||||
command(&"hire_staff_candidate", {&"candidate_id": assignment[0]})
|
||||
command(&"set_staff_work_assignment", {&"staff_id": assignment[0],
|
||||
&"facility_id": facility_ids[assignment[1]], &"template_id": &"DAY"})
|
||||
var actual_quote: Dictionary = runtime.preview_supply_purchase(facility_ids[&"warehouse"], SupplyCatalog.RAW_FOOD, purchase_quantity)
|
||||
expect(int(actual_quote[&"total_cost"]) == purchase_total, "budget matches actual purchase quote")
|
||||
expect(stream.record("setup-purchase-quote", actual_quote), "record actual setup purchase quote")
|
||||
command(&"purchase_supplies", {&"warehouse_id": facility_ids[&"warehouse"],
|
||||
&"item_id": SupplyCatalog.RAW_FOOD, &"quantity": 40})
|
||||
&"item_id": SupplyCatalog.RAW_FOOD, &"quantity": purchase_quantity})
|
||||
command(&"set_kitchen_production", {&"facility_id": facility_ids[&"kitchen"],
|
||||
&"enabled": true, &"target_stock": 8})
|
||||
# The OS observation uses the already declared transport cohort, plus
|
||||
|
||||
Reference in New Issue
Block a user