93 lines
3.0 KiB
GDScript
93 lines
3.0 KiB
GDScript
extends SceneTree
|
|
|
|
const MainScene = preload("res://main.tscn")
|
|
|
|
var game: Control
|
|
var failures: Array[String] = []
|
|
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("run_test")
|
|
|
|
|
|
func run_test() -> void:
|
|
game = MainScene.instantiate()
|
|
game.auto_boot = false
|
|
game.audio_enabled = false
|
|
root.add_child(game)
|
|
await settle(12)
|
|
game.locale = "zh_CN"
|
|
game.text_scale = 1.0
|
|
game.reduced_motion = false
|
|
game.muted = true
|
|
game.boot_verified = true
|
|
game.front_choice = read_string("ABG_P9_0R3_FRONT", "Hearthguard")
|
|
game.rear_choice = read_string("ABG_P9_0R3_REAR", "Farstring")
|
|
game.depart()
|
|
var seen_feedback_labels := 0
|
|
var seen_values: Dictionary = {}
|
|
var elapsed := 0.0
|
|
while game.page != game.AppPage.VICTORY and elapsed < 14.0:
|
|
await process_frame
|
|
elapsed += 1.0 / 30.0
|
|
if find_control(game, "BattleFeedbackLabel") != null:
|
|
seen_feedback_labels += 1
|
|
if not game.active_battle_feedback.is_empty():
|
|
seen_values[int(game.active_battle_feedback["delta"])] = true
|
|
if game.page != game.AppPage.VICTORY:
|
|
failures.append("dynamic feedback slice did not reach victory")
|
|
if game.battle_feedback_history.size() != 4:
|
|
failures.append("dynamic feedback slice did not commit exactly four payloads")
|
|
if seen_feedback_labels < 12:
|
|
failures.append("dynamic feedback labels were not visible across enough rendered frames")
|
|
if seen_values.size() != 4:
|
|
failures.append("dynamic feedback values were not distinct across all phase commits")
|
|
if elapsed >= 8.0:
|
|
failures.append("dynamic feedback battle exceeded eight-second pacing target")
|
|
if game.guard_events != 1 or game.rear_events != 1 or game.victory_events != 1:
|
|
failures.append("dynamic feedback changed authoritative event counts")
|
|
await create_timer(1.0).timeout
|
|
game.queue_free()
|
|
game = null
|
|
await settle(210)
|
|
if failures.is_empty():
|
|
print("ABG_P9_0R3_DYNAMIC_SLICE_OK duration=%.2f front=%s rear=%s feedback=4 values=%s visible_frames=%d impact_once=true renderer=normal" % [elapsed, read_string("ABG_P9_0R3_FRONT", "Hearthguard"), read_string("ABG_P9_0R3_REAR", "Farstring"), sorted_values(seen_values), seen_feedback_labels])
|
|
call_deferred("finish", 0)
|
|
else:
|
|
for failure in failures:
|
|
push_error(failure)
|
|
call_deferred("finish", 1)
|
|
|
|
|
|
func sorted_values(values: Dictionary) -> String:
|
|
var keys := values.keys()
|
|
keys.sort()
|
|
var output: Array[String] = []
|
|
for value in keys:
|
|
output.append(("+" if int(value) > 0 else "") + str(value))
|
|
return ",".join(output)
|
|
|
|
|
|
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 read_string(key: String, fallback: String) -> String:
|
|
var value := OS.get_environment(key)
|
|
return value if not value.is_empty() else fallback
|
|
|
|
|
|
func finish(exit_code: int) -> void:
|
|
quit(exit_code)
|
|
|
|
|
|
func settle(frames: int) -> void:
|
|
for frame in range(frames):
|
|
await process_frame
|