Files
aetherbound-guild/runtime/tests/p9_0r1_domain_test.gd
T

110 lines
4.0 KiB
GDScript

extends SceneTree
const MainScene = preload("res://main.tscn")
var failures: Array[String] = []
func _initialize() -> void:
call_deferred("run_test")
func run_test() -> void:
var game := MainScene.instantiate()
game.auto_boot = false
root.add_child(game)
await settle()
expect(game.page == game.AppPage.BOOT, "fresh instance starts at Boot")
expect(game.front_choice.is_empty() and game.rear_choice.is_empty(), "fresh team is empty")
game.boot_paths_override.assign(["res://missing/p9_0r1_required_resource.tres"])
await game.run_boot_verification()
expect(game.page == game.AppPage.BOOT, "failed boot stays at Boot")
expect(game.boot_failed_path == "res://missing/p9_0r1_required_resource.tres", "failed boot retains path")
expect(find_control(game, "BootRetry") != null, "failed boot exposes Retry")
game.boot_paths_override.clear()
await game.run_boot_verification()
expect(game.boot_verified and game.page == game.AppPage.TITLE, "verified boot reaches Title")
expect(find_control(game, "EnterGameButton") != null, "Title exposes one game entry")
game.enter_game()
expect(game.page == game.AppPage.MAIN_MENU, "entry reaches Main Menu")
game.start_adventure()
expect(game.page == game.AppPage.YARD, "entry reaches Guild Yard")
game.choose_candidate("Hearthguard")
game.choose_candidate("Wayrunner")
expect(game.front_choice == "Wayrunner", "front candidate replaces same position")
game.choose_candidate("Farstring")
game.choose_candidate("Kindhand")
expect(game.rear_choice == "Kindhand", "rear candidate replaces same position")
game.choose_candidate("Farstring")
expect(game.rear_choice == "Farstring", "rear candidate can be selected again")
game.depart()
expect(game.page == game.AppPage.BATTLE and game.battle_playing, "ready team begins battle")
for phase in range(6):
game.advance_battle_phase()
expect(game.page == game.AppPage.VICTORY, "fixed tutorial sequence reaches victory")
expect(game.enemy_hp == 0 and game.victory_events == 1, "victory commits once")
expect(game.guard_events == 1 and game.rear_events == 1, "front and rear roles both act")
game.advance_battle_phase()
expect(game.victory_events == 1, "victory cannot duplicate")
game.request_restart()
expect(game.restart_confirmation, "restart requires confirmation")
game.cancel_restart()
expect(not game.restart_confirmation and game.page == game.AppPage.VICTORY, "cancel preserves current state")
game.request_restart()
game.confirm_restart()
expect(game.page == game.AppPage.MAIN_MENU, "confirmed restart returns Main Menu")
expect(game.front_choice.is_empty() and game.rear_choice.is_empty(), "restart clears team")
expect(game.front_hp == 100 and game.enemy_hp == 100 and game.victory_events == 0, "restart clears battle state")
game.start_adventure()
game.choose_candidate("Hearthguard")
game.choose_candidate("Kindhand")
game.depart()
for phase in range(6):
game.advance_battle_phase()
expect(game.page == game.AppPage.VICTORY, "healer route reaches victory")
expect(game.front_hp == 94, "healer visibly restores front after guarded hit")
expect(game.rear_events == 1, "healer contribution recorded")
game.go_home()
expect(game.page == game.AppPage.MAIN_MENU and game.front_choice.is_empty(), "Home clears transient experience")
game.queue_free()
await drain_cleanup()
if failures.is_empty():
print("ABG_P9_0R1_DOMAIN_OK routes=2 replace=front,rear restart=confirmed home=1 battle_phases=6 victory_once=1")
quit(0)
else:
for failure in failures:
push_error(failure)
quit(1)
func find_control(node: Node, node_name: String) -> Control:
if node.name == node_name and node is Control and not node.is_queued_for_deletion():
return node
for child in node.get_children():
var found := find_control(child, node_name)
if found != null:
return found
return null
func settle() -> void:
for frame in range(8):
await process_frame
func drain_cleanup() -> void:
for frame in range(40):
await process_frame
func expect(condition: bool, message: String) -> void:
if not condition:
failures.append("P9.0R1 domain: %s" % message)