88 lines
4.6 KiB
Python
88 lines
4.6 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
|
|
try:
|
|
from .art_asset_helpers import atlas_path, atlas_regions, region_hash, rgba_png
|
|
except ImportError:
|
|
from art_asset_helpers import atlas_path, atlas_regions, region_hash, rgba_png
|
|
|
|
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):
|
|
frames = (ROOT / "assets/bosses/muerte/muerte_frames.tres").read_text()
|
|
atlas = atlas_path(ROOT, frames)
|
|
self.assertEqual(atlas.suffix, ".png")
|
|
image = rgba_png(atlas)
|
|
self.assertEqual(image[:2], (1536, 1536))
|
|
self.assertEqual(min(image[2][3::4]), 0)
|
|
self.assertGreaterEqual(max(image[2][3::4]), 250)
|
|
regions = atlas_regions(frames)
|
|
self.assertEqual(len(regions), 16)
|
|
self.assertEqual(len({region_hash(image, region) for region in regions.values()}), 16)
|
|
for x, y, width, height in regions.values():
|
|
self.assertEqual((width, height), (384, 384))
|
|
self.assertEqual((x % 384, y % 384), (0, 0))
|
|
scythe = ROOT / "assets/ashen/bosses/spectral_scythe.png"
|
|
weapon = rgba_png(scythe)
|
|
self.assertEqual(weapon[:2], (192, 288))
|
|
self.assertEqual(min(weapon[2][3::4]), 0)
|
|
self.assertIn('path="res://assets/ashen/bosses/spectral_scythe.png"', BOSS)
|
|
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_visual = (ROOT / "world/triggers/ossuary_gate_visual.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('name="Visual" parent="." instance=ExtResource("visual")', gate_scene)
|
|
for name in ("LeftLeaf", "RightLeaf", "Arch", "Seal"):
|
|
self.assertIn(f'name="{name}" type="Sprite2D"', gate_visual)
|
|
textures = re.findall(r'\[ext_resource type="Texture2D" path="res://([^\"]+)"', gate_visual)
|
|
self.assertGreaterEqual(len(textures), 5)
|
|
for path in textures:
|
|
self.assertTrue((ROOT / path).is_file(), path)
|
|
self.assertEqual(Path(path).suffix, ".png")
|
|
self.assertIn('texture_filter = 1', gate_visual)
|
|
self.assertIn('level.complete_level()', victory_code)
|
|
self.assertNotIn('res://levels/level_02.gd', LEVEL)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|