108 lines
4.0 KiB
GDScript
108 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(10)
|
|
|
|
for character in game.ANIMATION_SPECS:
|
|
for state in game.ANIMATION_SPECS[character]:
|
|
var spec: Dictionary = game.ANIMATION_SPECS[character][state]
|
|
expect(int(spec["frames"]) > 1, "%s/%s has more than one frame" % [character, state])
|
|
var texture_0: Texture2D = game.animation_texture(character, state, 0.0)
|
|
var texture_1: Texture2D = game.animation_texture(character, state, 1.0 / float(spec["fps"]) + 0.01)
|
|
expect(texture_0 != texture_1, "%s/%s changes texture during normal rendering" % [character, state])
|
|
|
|
game.front_choice = "Wayrunner"
|
|
game.rear_choice = "Farstring"
|
|
game.depart()
|
|
game.battle_phase = 2
|
|
game.battle_clock = 0.0
|
|
game.phase_impact_committed.clear()
|
|
game.front_hp = 100
|
|
game.render()
|
|
var initial_front_texture: Texture2D = game.front_sprite.texture
|
|
game._process(0.16)
|
|
expect(game.front_sprite.texture != initial_front_texture, "Wayrunner body pose changes during evade/counter")
|
|
expect(game.front_hp == 100 and game.guard_events == 0, "front HP remains unchanged before impact frame")
|
|
game._process(0.30)
|
|
expect(game.front_hp == 88 and game.guard_events == 1, "front impact commits once after enemy strike frame")
|
|
game._process(0.30)
|
|
expect(game.front_hp == 88 and game.guard_events == 1, "front impact cannot duplicate")
|
|
game.request_restart()
|
|
var paused_clock: float = game.battle_clock
|
|
game._process(1.0)
|
|
expect(game.battle_clock == paused_clock, "Restart confirmation freezes animation and impact time")
|
|
game.cancel_restart()
|
|
|
|
game.battle_phase = 3
|
|
game.battle_clock = 0.0
|
|
game.phase_impact_committed.erase(3)
|
|
game.enemy_hp = 100
|
|
game.render()
|
|
var initial_rear_texture: Texture2D = game.rear_sprite.texture
|
|
game._process(0.16)
|
|
expect(game.rear_sprite.texture != initial_rear_texture, "Farstring body pose changes while drawing bow")
|
|
expect(game.enemy_hp == 100 and game.rear_events == 0, "rear damage waits for release frame")
|
|
game._process(0.20)
|
|
expect(game.enemy_hp == 64 and game.rear_events == 1, "arrow impact commits once at release frame")
|
|
|
|
game.battle_phase = 5
|
|
game.battle_clock = 0.0
|
|
game.phase_impact_committed.erase(5)
|
|
game.enemy_hp = 34
|
|
game.render()
|
|
game._process(0.90)
|
|
var death_final: Texture2D = game.animation_texture("Riftblade", "death", 99.0)
|
|
expect(game.enemy_sprite.texture == death_final, "non-looping death holds final frame")
|
|
expect(game.enemy_hp == 0, "death impact commits at declared frame")
|
|
game._process(0.40)
|
|
expect(game.enemy_hp == 0 and game.enemy_sprite.texture == death_final, "death cannot loop or recommit")
|
|
|
|
for front in ["Hearthguard", "Wayrunner"]:
|
|
for rear in ["Farstring", "Kindhand"]:
|
|
game.clear_experience()
|
|
game.front_choice = front
|
|
game.rear_choice = rear
|
|
game.depart()
|
|
for phase in range(6):
|
|
game.advance_battle_phase()
|
|
expect(game.page == game.AppPage.VICTORY, "%s + %s reaches victory" % [front, rear])
|
|
expect(game.victory_events == 1, "%s + %s commits one victory" % [front, rear])
|
|
|
|
game.clear_experience()
|
|
expect(game.phase_impact_committed.is_empty() and game.battle_clock == 0.0, "reset clears animation impact state")
|
|
game.reduced_motion = true
|
|
expect(game.animation_frame_index("Wayrunner", "idle", 1.0) == 0, "reduced motion freezes nonessential idle loop")
|
|
expect(game.animation_frame_index("Wayrunner", "evade_counter", 0.25) > 0, "reduced motion retains authored action frames")
|
|
|
|
game.queue_free()
|
|
await settle(60)
|
|
if failures.is_empty():
|
|
print("ABG_P9_0R2_CHARACTER_ANIMATION_OK actors=5 states=20 impact_once=true death_hold=true reduced_motion=true")
|
|
quit(0)
|
|
else:
|
|
for failure in failures:
|
|
push_error(failure)
|
|
quit(1)
|
|
|
|
|
|
func settle(frames: int) -> void:
|
|
for frame in range(frames):
|
|
await process_frame
|
|
|
|
|
|
func expect(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
failures.append("P9.0R2 character animation: %s" % message)
|