84 lines
3.3 KiB
GDScript
84 lines
3.3 KiB
GDScript
extends SceneTree
|
|
|
|
const Main = preload("res://main.gd")
|
|
const Fixture = preload("res://tests/p9_9/runtime_fixture.gd")
|
|
|
|
var failures: Array[String] = []
|
|
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("run_test")
|
|
|
|
|
|
func run_test() -> void:
|
|
root.content_scale_mode = Window.CONTENT_SCALE_MODE_CANVAS_ITEMS
|
|
root.content_scale_aspect = Window.CONTENT_SCALE_ASPECT_EXPAND
|
|
root.content_scale_size = Vector2i(844, 390)
|
|
root.size = Vector2i(844, 390)
|
|
var game = Main.new()
|
|
game.auto_boot = false
|
|
game.p93_experience_enabled = false
|
|
root.add_child(game)
|
|
await process_frame
|
|
var closed := Fixture.closed_p98()
|
|
expect(game._is_p99_handoff(closed), "exact closed first Contract is a P9.9 handoff")
|
|
game.start_p98_experience(closed)
|
|
await settle_frames()
|
|
expect(is_instance_valid(game.p98_experience) and game.p99_experience == null, "persistent result stays visible before continuation")
|
|
expect(game.p98_experience.find_child("P99ContinueCharterButton", true, false) != null, "persistent result exposes one Charter continuation")
|
|
await tap(game.p98_experience.find_child("P99ContinueCharterButton", true, false) as Control)
|
|
expect(game.p98_experience == null and is_instance_valid(game.p99_experience), "continuation touch replaces P9.8 with P9.9 exclusively")
|
|
expect(game.p99_experience.charter.state.persistent_renown == 14 and game.p99_experience.market == null, "handoff reconciles canonical Renown before a claim")
|
|
expect(game.p99_experience.find_child("P99CharterPacketTarget_CH-RG01-CATALOG-01", true, false) != null, "P9.9 opens the physical Charter table")
|
|
await tap(game.p99_experience.find_child("P99CharterPacketTarget_CH-RG01-CATALOG-01", true, false) as Control)
|
|
await tap(game.p99_experience.find_child("P99CharterPacketTarget_CH-RG01-CATALOG-01", true, false) as Control)
|
|
expect(game.p99_experience.market != null and not game.p99_experience.market.state.run_created, "two Charter touches enter the stable Recruit draft")
|
|
var draft_snapshot: Dictionary = game.p99_experience.market.state.snapshot()
|
|
game.p99_experience.queue_free()
|
|
game.p99_experience = null
|
|
await settle_frames()
|
|
game.start_p99_experience(draft_snapshot)
|
|
await settle_frames()
|
|
expect(is_instance_valid(game.p99_experience) and game.p99_experience.market.state.snapshot() == draft_snapshot, "valid v4 Run draft resumes without reroll")
|
|
game.queue_free()
|
|
for _index in 45:
|
|
await process_frame
|
|
if failures.is_empty():
|
|
print("ABG_P9_9_MAIN_HANDOFF_OK p98_closed=charter_touch renown=3_to_14 claim=catalog p99_v4=resume draft=stable controller=exclusive")
|
|
quit(0)
|
|
else:
|
|
for failure in failures:
|
|
push_error(failure)
|
|
quit(1)
|
|
|
|
|
|
func tap(control: Control) -> void:
|
|
expect(control != null, "handoff control exists before parsed touch")
|
|
if control == null:
|
|
return
|
|
var point := root.get_final_transform() * control.get_global_rect().get_center()
|
|
var down := InputEventScreenTouch.new()
|
|
down.index = 0
|
|
down.position = point
|
|
down.pressed = true
|
|
Input.parse_input_event(down)
|
|
await process_frame
|
|
var up := InputEventScreenTouch.new()
|
|
up.index = 0
|
|
up.position = point
|
|
up.pressed = false
|
|
Input.parse_input_event(up)
|
|
await settle_frames()
|
|
|
|
|
|
func settle_frames() -> void:
|
|
await process_frame
|
|
await process_frame
|
|
await process_frame
|
|
await process_frame
|
|
|
|
|
|
func expect(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
failures.append("P9.9 main handoff: %s" % message)
|