Implement the bounded Godot opening Company and first-Market preparation flow with deterministic one-shot state, real touch verification, responsive layouts, prototype feedback, and current design regressions.\n\nCo-Authored-By: Codex <noreply@anthropic.com>
98 lines
4.1 KiB
GDScript
98 lines
4.1 KiB
GDScript
extends SceneTree
|
|
|
|
const RunState = preload("res://domain/run_state.gd")
|
|
|
|
var failures: Array[String] = []
|
|
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("run_test")
|
|
|
|
|
|
func run_test() -> void:
|
|
var state := RunState.new()
|
|
expect(not state.select_difficulty("standard").ok, "difficulty requires Contract")
|
|
expect(state.snapshot().coin == 52, "invalid difficulty does not mutate Coin")
|
|
expect(state.select_contract().ok, "Contract selection")
|
|
expect(state.select_difficulty("standard").ok, "difficulty selection")
|
|
expect(state.open_offers().ok, "open stable offers")
|
|
expect(offer_ids(state) == ["OFF-01", "OFF-02", "OFF-03", "OFF-04"], "stable opening offer IDs")
|
|
for id in ["OFF-01", "OFF-02", "OFF-03", "OFF-04"]:
|
|
expect(state.inspect_offer(id).ok, "inspect %s" % id)
|
|
expect(state.toggle_offer("OFF-03").ok, "select Tomas")
|
|
expect(state.toggle_offer("OFF-04").ok, "select Sable")
|
|
expect(not state.toggle_offer("OFF-01").ok, "reject a third opening Recruit")
|
|
expect(state.selected == ["OFF-03", "OFF-04"], "third selection leaves pair unchanged")
|
|
expect(state.review_opening().ok, "review opening Company")
|
|
expect(state.revise_opening().ok, "revise opening Company")
|
|
expect(offer_ids(state) == ["OFF-01", "OFF-02", "OFF-03", "OFF-04"], "revision retains stable offers")
|
|
expect(state.review_opening().ok, "review revised Company")
|
|
expect(state.commit_opening().ok, "commit opening once")
|
|
expect(not state.commit_opening().ok, "reject duplicate opening commit")
|
|
expect(state.company == ["OFF-03", "OFF-04"], "opening Company is exact pair")
|
|
expect(state.coin == 52, "opening commit is free")
|
|
expect(state.open_market().ok, "open first Market")
|
|
expect(state.hire("MKT-R1-01").ok, "hire Mael")
|
|
expect(not state.hire("MKT-R1-01").ok, "reject duplicate Mael hire")
|
|
expect(state.company.size() == 3 and state.coin == 38, "Mael receipt values")
|
|
expect(state.hire("MKT-R1-02").ok, "hire Ilya")
|
|
expect(not state.hire("MKT-R1-02").ok, "reject duplicate Ilya hire")
|
|
expect(state.company.size() == 4 and state.coin == 24, "Ilya receipt values")
|
|
expect(state.purchase_equipment().ok, "purchase EQ-012")
|
|
expect(not state.purchase_equipment().ok, "reject duplicate EQ-012 purchase")
|
|
expect(state.coin == 12 and state.equipment_wearer.is_empty(), "purchase and equip are separate")
|
|
expect(not state.equip_member("OFF-01").ok, "reject non-Company wearer")
|
|
expect(state.equip_member("OFF-03").ok, "equip Tomas")
|
|
expect(not state.equip_member("OFF-03").ok, "reject duplicate equip")
|
|
expect(state.equipment_wearer == "OFF-03", "one active EQ-012 wearer")
|
|
expect(state.choose_order_unit("OFF-03").ok, "select order source")
|
|
expect(state.choose_order_unit("MKT-R1-01").ok, "swap order destination")
|
|
expect(state.order_changed, "order changed before commit")
|
|
expect(state.commit_order().ok, "commit readiness once")
|
|
expect(not state.commit_order().ok, "reject duplicate readiness receipt")
|
|
var snapshot := state.snapshot()
|
|
expect(snapshot.step == RunState.Step.READY, "final readiness state")
|
|
expect(snapshot.coin == 12 and snapshot.company.size() == 4, "exact final resources")
|
|
expect(snapshot.operation_counts == {
|
|
"opening": 1,
|
|
"MKT-R1-01": 1,
|
|
"MKT-R1-02": 1,
|
|
"purchase": 1,
|
|
"equip": 1,
|
|
"order": 1,
|
|
}, "all committed operations are one-shot")
|
|
|
|
var alternate := RunState.new()
|
|
alternate.select_contract()
|
|
alternate.select_difficulty("wayfinder")
|
|
alternate.open_offers()
|
|
alternate.toggle_offer("OFF-01")
|
|
alternate.toggle_offer("OFF-02")
|
|
alternate.review_opening()
|
|
alternate.commit_opening()
|
|
alternate.open_market()
|
|
alternate.hire("MKT-R1-01")
|
|
alternate.hire("MKT-R1-02")
|
|
alternate.purchase_equipment()
|
|
expect(alternate.equip_member("OFF-01").ok, "alternate legal pair can equip EQ-012")
|
|
|
|
if failures.is_empty():
|
|
print("ABG_P9_1_DOMAIN_OK cases=40 final_coin=12 company=4 commits=6")
|
|
quit(0)
|
|
else:
|
|
for failure in failures:
|
|
push_error(failure)
|
|
quit(1)
|
|
|
|
|
|
func offer_ids(state: RunState) -> Array[String]:
|
|
var ids: Array[String] = []
|
|
for entry in RunState.OFFERS:
|
|
ids.append(entry.id)
|
|
return ids
|
|
|
|
|
|
func expect(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
failures.append("P9.1 domain: %s" % message)
|