Files
mortal-maze-the-game/tests/test_level_02_visual_resources.py
T

67 lines
3.4 KiB
Python

"""Contratos del parche incremental: arte, animacion y puerta del Nivel 02.
Verifica recursos sin sustituir la inspeccion visual ni las pruebas del motor.
"""
from pathlib import Path
import re
import unittest
from xml.etree import ElementTree
ROOT = Path(__file__).resolve().parents[1]
LEVEL = (ROOT / "levels/level_02.tscn").read_text(encoding="utf-8")
BOSS = (ROOT / "bosses/spectral_death/spectral_death.tscn").read_text(encoding="utf-8")
BOSS_CODE = (ROOT / "bosses/spectral_death/spectral_death.gd").read_text(encoding="utf-8")
GATE_CODE = (ROOT / "world/triggers/ossuary_gate_visual.gd").read_text(encoding="utf-8")
class Level02VisualResourceTests(unittest.TestCase):
def test_scene_references_are_real_files(self):
for scene in [LEVEL, BOSS]:
for resource in re.findall(r'path="res://([^\"]+)"', scene):
self.assertTrue((ROOT / resource).is_file(), resource)
def test_reaper_has_real_animation_frames_and_separate_weapon(self):
atlas = ROOT / "assets/bosses/muerte/muerte_body_atlas.svg"
scythe = ROOT / "assets/bosses/muerte/spectral_scythe.svg"
for path in (atlas, scythe):
root = ElementTree.parse(path).getroot()
self.assertIn("viewBox", root.attrib)
self.assertGreater(int(root.attrib["width"]), 90)
frames = (ROOT / "assets/bosses/muerte/muerte_frames.tres").read_text()
for animation in ("idle", "approach", "telegraph", "slash", "cast", "dash", "phase", "hurt", "death"):
self.assertIn(f'"name": &"{animation}"', frames)
self.assertIn('name="WeaponPivot"', BOSS)
self.assertIn('name="ThrownScythe"', BOSS)
self.assertIn('name="Body" type="AnimatedSprite2D"', BOSS)
def test_hit_reaction_and_movement_do_not_replace_combat_patterns(self):
self.assertIn('func _spawn_damage_number(amount: int)', BOSS_CODE)
self.assertIn('body.play(&"hurt")', BOSS_CODE)
self.assertIn('func _start_camera_framing()', BOSS_CODE)
self.assertIn('"move":', BOSS_CODE)
self.assertIn('"double_sweep", "scythe", "runes", "dash", "rest"', BOSS_CODE)
self.assertIn('current_health = PHASE_HEALTH', BOSS_CODE)
def test_gate_uses_reusable_scene_and_opens_visibly(self):
gate_scene = (ROOT / "world/triggers/kill_gate.tscn").read_text()
gate_code = (ROOT / "world/triggers/kill_gate.gd").read_text()
victory_code = (ROOT / "world/triggers/boss_victory.gd").read_text()
self.assertIn('instance=ExtResource("gate")', LEVEL)
self.assertIn('enemies_root_path = NodePath("../Enemies")', LEVEL)
self.assertIn('instance=ExtResource("boss_victory")', LEVEL)
self.assertIn('boss_path = NodePath("../Boss")', LEVEL)
self.assertIn('remaining == 0', gate_code)
self.assertIn('has de derrotar a todos los mal nacidos para poder atravesar esta puerta!', gate_code)
self.assertIn('gate_visual.fully_open.connect(', gate_code)
self.assertIn('gate_visual.set_unlocked(_open)', gate_code)
self.assertIn('fully_open.emit()', GATE_CODE)
self.assertIn('func _draw_skull(', GATE_CODE)
self.assertIn('func _draw_leaf(', GATE_CODE)
self.assertIn('name="Visual" type="Node2D"', gate_scene)
self.assertIn('level.complete_level()', victory_code)
self.assertNotIn('res://levels/level_02.gd', LEVEL)
if __name__ == "__main__":
unittest.main()