♻️REFACTOR: Mejoras en la viabilidad para desarrollo
This commit is contained in:
1 parent
5aba6c7b47
commit
fd0118d964
98 files changed
+5985
-3024
No files matched your search
+349
@@ -0,0 +1,349 @@
|
||||
{
|
||||
"levels/level_01.tscn": {
|
||||
"World/Floor": {
|
||||
"position": [
|
||||
4250.0,
|
||||
620.0
|
||||
],
|
||||
"dimensions": [
|
||||
8500.0,
|
||||
40.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/Step1": {
|
||||
"position": [
|
||||
1530.0,
|
||||
455.0
|
||||
],
|
||||
"dimensions": [
|
||||
240.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/High1": {
|
||||
"position": [
|
||||
1690.0,
|
||||
291.0
|
||||
],
|
||||
"dimensions": [
|
||||
180.0,
|
||||
16.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/Step2": {
|
||||
"position": [
|
||||
3370.0,
|
||||
485.0
|
||||
],
|
||||
"dimensions": [
|
||||
240.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/High2": {
|
||||
"position": [
|
||||
3520.0,
|
||||
338.0
|
||||
],
|
||||
"dimensions": [
|
||||
180.0,
|
||||
16.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/Step3": {
|
||||
"position": [
|
||||
5600.0,
|
||||
455.0
|
||||
],
|
||||
"dimensions": [
|
||||
240.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/High3": {
|
||||
"position": [
|
||||
5750.0,
|
||||
291.0
|
||||
],
|
||||
"dimensions": [
|
||||
180.0,
|
||||
16.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/Step4": {
|
||||
"position": [
|
||||
6890.0,
|
||||
485.0
|
||||
],
|
||||
"dimensions": [
|
||||
240.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": false
|
||||
}
|
||||
},
|
||||
"levels/level_02.tscn": {
|
||||
"World/Ground/Street01": {
|
||||
"position": [
|
||||
740.0,
|
||||
1095.0
|
||||
],
|
||||
"dimensions": [
|
||||
1480.0,
|
||||
500.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/Ground/Street02": {
|
||||
"position": [
|
||||
2145.0,
|
||||
1005.0
|
||||
],
|
||||
"dimensions": [
|
||||
1330.0,
|
||||
500.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/Ground/Street03": {
|
||||
"position": [
|
||||
3480.0,
|
||||
1140.0
|
||||
],
|
||||
"dimensions": [
|
||||
1340.0,
|
||||
500.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/Ground/Street04": {
|
||||
"position": [
|
||||
4825.0,
|
||||
1055.0
|
||||
],
|
||||
"dimensions": [
|
||||
1350.0,
|
||||
500.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/Ground/Street05": {
|
||||
"position": [
|
||||
6150.0,
|
||||
950.0
|
||||
],
|
||||
"dimensions": [
|
||||
1300.0,
|
||||
500.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/Ground/Street06": {
|
||||
"position": [
|
||||
7440.0,
|
||||
1125.0
|
||||
],
|
||||
"dimensions": [
|
||||
1280.0,
|
||||
500.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/Ground/Street07": {
|
||||
"position": [
|
||||
8720.0,
|
||||
1035.0
|
||||
],
|
||||
"dimensions": [
|
||||
1280.0,
|
||||
500.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/Ground/Street08": {
|
||||
"position": [
|
||||
10180.0,
|
||||
1095.0
|
||||
],
|
||||
"dimensions": [
|
||||
1640.0,
|
||||
500.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/Walkways/Walkway01": {
|
||||
"position": [
|
||||
690.0,
|
||||
720.0
|
||||
],
|
||||
"dimensions": [
|
||||
270.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": true
|
||||
},
|
||||
"World/Walkways/Walkway02": {
|
||||
"position": [
|
||||
950.0,
|
||||
625.0
|
||||
],
|
||||
"dimensions": [
|
||||
230.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": true
|
||||
},
|
||||
"World/Walkways/Walkway03": {
|
||||
"position": [
|
||||
2135.0,
|
||||
638.0
|
||||
],
|
||||
"dimensions": [
|
||||
230.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": true
|
||||
},
|
||||
"World/Walkways/Walkway04": {
|
||||
"position": [
|
||||
3180.0,
|
||||
775.0
|
||||
],
|
||||
"dimensions": [
|
||||
220.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": true
|
||||
},
|
||||
"World/Walkways/Walkway05": {
|
||||
"position": [
|
||||
3405.0,
|
||||
665.0
|
||||
],
|
||||
"dimensions": [
|
||||
190.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": true
|
||||
},
|
||||
"World/Walkways/Walkway06": {
|
||||
"position": [
|
||||
4720.0,
|
||||
685.0
|
||||
],
|
||||
"dimensions": [
|
||||
260.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": true
|
||||
},
|
||||
"World/Walkways/Walkway07": {
|
||||
"position": [
|
||||
5780.0,
|
||||
585.0
|
||||
],
|
||||
"dimensions": [
|
||||
200.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": true
|
||||
},
|
||||
"World/Walkways/Walkway08": {
|
||||
"position": [
|
||||
5995.0,
|
||||
485.0
|
||||
],
|
||||
"dimensions": [
|
||||
190.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": true
|
||||
},
|
||||
"World/Walkways/Walkway09": {
|
||||
"position": [
|
||||
7360.0,
|
||||
755.0
|
||||
],
|
||||
"dimensions": [
|
||||
220.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": true
|
||||
},
|
||||
"World/Walkways/Walkway10": {
|
||||
"position": [
|
||||
8705.0,
|
||||
655.0
|
||||
],
|
||||
"dimensions": [
|
||||
230.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": true
|
||||
},
|
||||
"World/Walkways/Walkway11": {
|
||||
"position": [
|
||||
10035.0,
|
||||
735.0
|
||||
],
|
||||
"dimensions": [
|
||||
270.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": true
|
||||
},
|
||||
"World/Barriers/Left": {
|
||||
"position": [
|
||||
0.0,
|
||||
690.0
|
||||
],
|
||||
"dimensions": [
|
||||
60.0,
|
||||
920.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/Barriers/Right": {
|
||||
"position": [
|
||||
11000.0,
|
||||
690.0
|
||||
],
|
||||
"dimensions": [
|
||||
60.0,
|
||||
920.0
|
||||
],
|
||||
"one_way": false
|
||||
}
|
||||
},
|
||||
"levels/test/combat_test.tscn": {
|
||||
"World/Floor": {
|
||||
"position": [
|
||||
585.0,
|
||||
465.0
|
||||
],
|
||||
"dimensions": [
|
||||
1171.0,
|
||||
20.0
|
||||
],
|
||||
"one_way": false
|
||||
},
|
||||
"World/LeftWall": {
|
||||
"position": [
|
||||
77.0,
|
||||
361.0
|
||||
],
|
||||
"dimensions": [
|
||||
136.0,
|
||||
156.0
|
||||
],
|
||||
"one_way": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
extends SceneTree
|
||||
|
||||
## Real-engine integration checks; Python resource tests do not execute these.
|
||||
## Pruebas de integracion con el motor real; las pruebas de Python no las ejecutan.
|
||||
## godot --headless --path . --script res://tests/test_enemy_ai_runtime.gd
|
||||
|
||||
var _failures: int = 0
|
||||
@@ -41,8 +41,8 @@ func _test_safe_start() -> void:
|
||||
_check(enemies.get_child_count() == 29, "Keep all 29 encounters")
|
||||
_check(is_equal_approx((enemies.get_node("Enemy01") as Node2D).position.x, 1260.0),
|
||||
"First enemy was not relocated")
|
||||
# Notifier callbacks do not run in headless mode. Waking EVERY enemy also
|
||||
# proves that a wide window cannot bypass the new proximity check.
|
||||
# Los avisos de visibilidad no se ejecutan sin ventana. Activar TODOS los enemigos
|
||||
# tambien comprueba que una ventana ancha no evita el filtro de proximidad.
|
||||
for node: Node in enemies.get_children():
|
||||
node.set("is_awake", true)
|
||||
await _frames(90)
|
||||
@@ -124,8 +124,8 @@ func _test_damage_and_push() -> void:
|
||||
_enemy.set("attack_direction", 1.0)
|
||||
_enemy.call("_set_attack_hitbox_progress", 0.5)
|
||||
await _frames(3)
|
||||
# This puts the sweep centre PAST the player. Push must still be away from
|
||||
# the enemy, not towards it. Exercise the real Area2D overlap path.
|
||||
# El centro del barrido queda MAS ALLA del jugador. El empuje debe alejarlo
|
||||
# del enemigo, no acercarlo. Se prueba el solapamiento real de Area2D.
|
||||
_enemy.call("_update_attack_damage")
|
||||
_check(int(_player.get("current_health")) == 44, "Guard hit must deal six HP")
|
||||
_check(is_equal_approx(_player.velocity.x, 558.0), "Guard must push away with 1.8x horizontal impulse")
|
||||
@@ -181,8 +181,8 @@ func _arena(variant: String, floors: Array[Rect2], enemy_position: Vector2,
|
||||
_enemy.set("show_debug_enemy_info", false)
|
||||
_world.add_child(_enemy)
|
||||
_enemy.set("is_awake", false)
|
||||
# Settle onto the floor before enabling pursuit. Ground sweep checks use
|
||||
# the collision state from move_and_slide(), not merely the spawn position.
|
||||
# Apoyar al enemigo antes de activar la persecucion. El barrido utiliza el
|
||||
# estado de colision de move_and_slide(), no solo la posicion de aparicion.
|
||||
await _frames(10)
|
||||
_enemy.set("attack_cooldown_timer", 1000.0)
|
||||
_enemy.set("is_awake", true)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Configuration regressions only; actual physics is tested by the .gd suite."""
|
||||
"""Regresiones de configuracion; la fisica real se comprueba en la suite .gd."""
|
||||
from pathlib import Path
|
||||
import math
|
||||
import re
|
||||
@@ -67,14 +67,15 @@ class EnemyProfileTests(unittest.TestCase):
|
||||
self.assertEqual(len({e[0] for e in enemies}), 29)
|
||||
first = next(e for e in enemies if e[0] == 'Enemy01')
|
||||
self.assertEqual((float(first[2]), float(first[3])), (1260, 811))
|
||||
# Even with a wide screen waking every notifier, no enemy starts in aggro range.
|
||||
# Ningun enemigo comienza en rango de ataque aunque todos esten visibles.
|
||||
for name, variant, x, y in enemies:
|
||||
distance = math.hypot(float(x) - 125.0, float(y) - 795.0)
|
||||
self.assertGreater(distance - self.profiles[variant]['aggro_range'], 200.0, name)
|
||||
|
||||
def test_jumps_can_climb_the_street_steps(self):
|
||||
heights = [float(y) - 250 for y in re.findall(
|
||||
r'parent="World/Ground"\]\nposition = Vector2\([^,]+, ([^)]+)\)', LEVEL)]
|
||||
r'parent="World/Ground" instance=ExtResource\("kit_ground"\)\]\nposition = Vector2\([^,]+, ([^)]+)\)', LEVEL)]
|
||||
self.assertEqual(len(heights), 8)
|
||||
largest_step = max(a - b for a, b in zip(heights, heights[1:]))
|
||||
for name in ('pogo_fan', 'rival_guitarist'):
|
||||
jump = self.profiles[name]['jump_velocity']
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
"""Static checks for the Android item test course (no Godot runtime needed).
|
||||
"""Pruebas estaticas del laboratorio de objetos, sin ejecutar Godot.
|
||||
|
||||
Run from the project root: python -m unittest discover -s tests -v
|
||||
These tests check references and test-course configuration, not gameplay.
|
||||
"""
|
||||
Ejecutar: python -m unittest discover -s tests -v
|
||||
Comprueban referencias y configuracion del recorrido, no la jugabilidad."""
|
||||
|
||||
from pathlib import Path
|
||||
import re
|
||||
@@ -20,7 +19,7 @@ class Level01ConfigurationTests(unittest.TestCase):
|
||||
cls.resources = dict(
|
||||
re.findall(r'\[ext_resource [^\n]*path="res://([^"]+)" id="([^"]+)"\]', cls.scene)
|
||||
)
|
||||
# Format is path -> id; invert to follow ExtResource("item_N").
|
||||
# El formato es ruta -> id; invertirlo para resolver ExtResource("item_N").
|
||||
cls.by_id = {resource_id: path for path, resource_id in cls.resources.items()}
|
||||
cls.stations = re.findall(
|
||||
r'\[node name="Station(\d{2})" parent="TestEnemies" instance=ExtResource\("(v\d+)"\)\]'
|
||||
@@ -50,9 +49,9 @@ class Level01ConfigurationTests(unittest.TestCase):
|
||||
xs = [float(station[2]) for station in self.stations]
|
||||
self.assertEqual(xs, sorted(xs))
|
||||
self.assertTrue(all(0 <= x <= 8500 for x in xs))
|
||||
self.assertIn("size = Vector2(8500, 40)", self.scene)
|
||||
self.assertIn("dimensions = Vector2(8500, 40)", self.scene)
|
||||
self.assertIn("position = Vector2(8180, 535)", self.scene)
|
||||
self.assertIn("camera.limit_right = LEVEL_WIDTH", (ROOT / "levels/level_01.gd").read_text())
|
||||
self.assertIn("camera_bounds = Rect2(0, 0, 8500, 2500)", self.scene)
|
||||
|
||||
def test_finish_and_death_areas_detect_player_layer(self):
|
||||
for area in ("FinishZone", "DeathZone"):
|
||||
@@ -74,8 +73,8 @@ class Level01ConfigurationTests(unittest.TestCase):
|
||||
self.assertTrue(len(root) > 20, svg.name)
|
||||
|
||||
def test_control_pickup_and_death_tracking_are_separate(self):
|
||||
# The independent control object distinguishes a rendering fault from
|
||||
# a death/drop fault without relying on running the Python test in Godot.
|
||||
# El objeto de control permite distinguir un fallo de dibujo de uno de
|
||||
# muerte/recompensa, sin pretender que esta prueba de Python ejecute Godot.
|
||||
self.assertIn('name="ControlPickup"', self.scene)
|
||||
self.assertIn('pickup_data = ExtResource("lab_control")', self.scene)
|
||||
self.assertTrue((ROOT / 'pickups/data/lab_control.tres').is_file())
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
"""Fast, engine-independent checks of the Level 02 alpha route.
|
||||
"""Pruebas rapidas de los recursos del recorrido de Level02, sin motor.
|
||||
|
||||
Run: python -m unittest discover -s tests -v
|
||||
A Godot playtest is still needed for physics, importing, and Android controls.
|
||||
"""
|
||||
Ejecutar: python -m unittest discover -s tests -v
|
||||
La fisica, importacion y controles de Android requieren pruebas con Godot."""
|
||||
|
||||
from pathlib import Path
|
||||
import re
|
||||
@@ -12,6 +11,7 @@ import struct
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
LEVEL = (ROOT / "levels/level_02.tscn").read_text(encoding="utf-8")
|
||||
SCRIPT = (ROOT / "levels/level_02.gd").read_text(encoding="utf-8")
|
||||
BACKGROUND = (ROOT / "world/backgrounds/city_background.tscn").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
class Level02ResourceTests(unittest.TestCase):
|
||||
@@ -30,34 +30,31 @@ class Level02ResourceTests(unittest.TestCase):
|
||||
width, height = struct.unpack(">II", content[16:24])
|
||||
self.assertGreater(width, 15)
|
||||
self.assertGreater(height, 15)
|
||||
self.assertEqual(LEVEL.count('type="Parallax2D"'), 4)
|
||||
self.assertEqual(LEVEL.count('repeat_size = Vector2(1024, 0)'), 4)
|
||||
self.assertIn('autoscroll = Vector2(3, 0)', LEVEL)
|
||||
self.assertEqual(BACKGROUND.count('type="Parallax2D"'), 4)
|
||||
self.assertEqual(BACKGROUND.count('repeat_size = Vector2(1024, 0)'), 4)
|
||||
self.assertIn('autoscroll = Vector2(3, 0)', BACKGROUND)
|
||||
self.assertIn('texture_repeat = 2', LEVEL)
|
||||
|
||||
def test_road_is_continuous_and_has_end_walls(self):
|
||||
widths = [float(w) for w in re.findall(
|
||||
r'\[sub_resource type="RectangleShape2D" id="Ground\d+"\]\nsize = Vector2\((\d+), 500\)', LEVEL
|
||||
)]
|
||||
# Each section uses a native CollisionShape2D with its own width.
|
||||
# Las instancias conservan los mismos centros y medidas del suelo original.
|
||||
sections = re.findall(
|
||||
r'\[node name="Street\d+" type="CollisionShape2D" parent="World/Ground"\]\n'
|
||||
r'position = Vector2\((\d+(?:\.\d+)?), (\d+(?:\.\d+)?)\)\n'
|
||||
r'shape = SubResource\("Ground\d+"\)', LEVEL,
|
||||
r'\[node name="Street\d+" parent="World/Ground" instance=ExtResource\("kit_ground"\)\]\s*'
|
||||
r'position = Vector2\(([^,]+), ([^)]+)\)\s*'
|
||||
r'dimensions = Vector2\(([^,]+), ([^)]+)\)', LEVEL,
|
||||
)
|
||||
self.assertEqual(len(sections), 8)
|
||||
self.assertEqual(len(widths), len(sections))
|
||||
left_edge = 0
|
||||
left_edge = 0.0
|
||||
tops = []
|
||||
for w, (center,y) in zip(widths, sections):
|
||||
self.assertEqual(float(center) - w / 2, left_edge)
|
||||
left_edge += w
|
||||
tops.append(float(y) - 250.0)
|
||||
for center, y, width, height in sections:
|
||||
center, y, width, height = map(float, (center, y, width, height))
|
||||
self.assertEqual(center - width / 2, left_edge)
|
||||
left_edge += width
|
||||
tops.append(y - height / 2)
|
||||
self.assertEqual(left_edge, 11000)
|
||||
self.assertTrue(all(a-b <= 110 for a,b in zip(tops, tops[1:])), tops)
|
||||
for name in ('Left', 'Right'):
|
||||
self.assertRegex(LEVEL, rf'\[node name="{name}" type="CollisionShape2D" parent="World/Barriers"\]')
|
||||
self.assertIn('camera.limit_right = WORLD_WIDTH', SCRIPT)
|
||||
self.assertIn(f'[node name="{name}" parent="World/Barriers" instance=ExtResource("kit_wall")]', LEVEL)
|
||||
self.assertIn('camera_bounds = Rect2(0, 0, 11000, 1280)', LEVEL)
|
||||
self.assertIn('collision_mask = 2', LEVEL)
|
||||
|
||||
def test_multiple_encounters_and_optional_items(self):
|
||||
@@ -66,7 +63,8 @@ class Level02ResourceTests(unittest.TestCase):
|
||||
self.assertEqual(len(enemies), 29)
|
||||
self.assertEqual(len(set(enemies)), 5)
|
||||
self.assertEqual(len(pickups), 14)
|
||||
self.assertEqual(LEVEL.count('one_way_collision = true'), 11)
|
||||
self.assertEqual(LEVEL.count('instance=ExtResource("kit_platform")'), 11)
|
||||
self.assertIn('one_way = true', (ROOT / 'world/terrain/platform.tscn').read_text())
|
||||
self.assertIn('run/main_scene="res://levels/level_02.tscn"', (ROOT / 'project.godot').read_text())
|
||||
self.assertIn('respawn_delay = 0.0', (ROOT / 'enemies/variants/roadie.tscn').read_text())
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extends SceneTree
|
||||
|
||||
## Godot integration smoke test. Engine required; not covered by Python tests.
|
||||
## Run after importing assets: godot --headless --path . --script res://tests/test_level_02_runtime.gd
|
||||
## Comprobacion basica de integracion en Godot; no la ejecutan las pruebas de Python.
|
||||
## Ejecutar despues de importar los recursos: godot --headless --path . --script res://tests/test_level_02_runtime.gd
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
@@ -53,7 +53,7 @@ func _run() -> void:
|
||||
return
|
||||
|
||||
for name: String in ["Sky", "HighClouds", "FarBuildings", "NearBuildings"]:
|
||||
var layer: Parallax2D = level.get_node(name) as Parallax2D
|
||||
var layer: Parallax2D = level.get_node("CityBackground/" + name) as Parallax2D
|
||||
if layer == null or layer.repeat_size.x != 1024:
|
||||
_fail("Falta la capa de parallax repetible: " + name)
|
||||
return
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
"""Contratos de recursos y geometria. No sustituyen a las pruebas dentro de Godot."""
|
||||
|
||||
from pathlib import Path
|
||||
import json
|
||||
import re
|
||||
import unittest
|
||||
from xml.etree import ElementTree
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def sections(text: str) -> list[str]:
|
||||
"""Separa las secciones textuales del formato de escenas, sin interpretar GDScript."""
|
||||
return [part for part in re.split(r"(?=^\[)", text, flags=re.MULTILINE) if part.strip()]
|
||||
|
||||
|
||||
def vector_property(block: str, name: str) -> list[float]:
|
||||
match = re.search(rf"^{name} = Vector2\(([^,]+), ([^)]+)\)", block, re.MULTILINE)
|
||||
if match is None:
|
||||
raise AssertionError(f"Missing {name} in {block}")
|
||||
return [float(match[1]), float(match[2])]
|
||||
|
||||
|
||||
class LevelKitResourceTests(unittest.TestCase):
|
||||
def test_every_own_resource_reference_resolves(self):
|
||||
for extension in ("*.tscn", "*.tres"):
|
||||
for path in ROOT.rglob(extension):
|
||||
if "addons" in path.parts or ".godot" in path.parts:
|
||||
continue
|
||||
text = path.read_text(encoding="utf-8")
|
||||
for relative in re.findall(r'path="res://([^"]+)"', text):
|
||||
self.assertTrue((ROOT / relative).is_file(), (path, relative))
|
||||
for kind, declaration in (("ExtResource", "ext_resource"), ("SubResource", "sub_resource")):
|
||||
defined = re.findall(rf'^\[{declaration} [^\n]*id="([^"]+)"', text, re.MULTILINE)
|
||||
self.assertEqual(len(defined), len(set(defined)), path)
|
||||
for used in re.findall(rf'{kind}\("([^"]+)"\)', text):
|
||||
self.assertIn(used, defined, (path, kind, used))
|
||||
|
||||
def test_legacy_geometry_has_identical_positions_sizes_and_one_way_flags(self):
|
||||
fixtures = json.loads((ROOT / "tests/fixtures/legacy_level_geometry.json").read_text())
|
||||
for relative, expected in fixtures.items():
|
||||
nodes = {}
|
||||
for block in sections((ROOT / relative).read_text(encoding="utf-8")):
|
||||
match = re.match(r'\[node name="([^"]+)" parent="(World[^"]*)" instance=ExtResource\("kit_([^"]+)"\)\]', block)
|
||||
if match:
|
||||
name, parent, preset = match.groups()
|
||||
preset_text = (ROOT / f"world/terrain/{preset}.tscn").read_text()
|
||||
nodes[parent + "/" + name] = {
|
||||
"position": vector_property(block, "position"),
|
||||
"dimensions": vector_property(block, "dimensions"),
|
||||
"one_way": "one_way = true" in preset_text,
|
||||
}
|
||||
self.assertEqual(nodes, expected, relative)
|
||||
|
||||
def test_levels_no_longer_render_their_terrain(self):
|
||||
for relative in ("levels/level_01.gd", "levels/level_02.gd"):
|
||||
text = (ROOT / relative).read_text()
|
||||
self.assertNotIn("func _draw()", text)
|
||||
self.assertIn("extends LevelRoot", text)
|
||||
self.assertIn("Engine.is_editor_hint()", text)
|
||||
|
||||
def test_camera_has_no_hidden_runtime_limits(self):
|
||||
camera = (ROOT / "player/camera_2d.gd").read_text()
|
||||
self.assertNotRegex(camera, r"limit_(left|top|right|bottom)\s*=")
|
||||
level = (ROOT / "levels/level_root.gd").read_text()
|
||||
self.assertIn("camera_bounds", level)
|
||||
self.assertIn('get_node_or_null("Player")', level)
|
||||
|
||||
def test_template_and_example_are_playable_scenes_not_generators(self):
|
||||
for relative in ("levels/templates/level_template.tscn", "levels/examples/scenery_catalog.tscn"):
|
||||
text = (ROOT / relative).read_text()
|
||||
self.assertIn('path="res://levels/level_root.gd"', text)
|
||||
self.assertIn('[node name="Player" parent="." instance=', text)
|
||||
for container in ("World", "Scenery", "Signs", "Enemies", "Items", "Triggers"):
|
||||
self.assertIn(f'[node name="{container}" type="Node2D" parent="."]', text)
|
||||
self.assertIn('run/main_scene="res://levels/level_02.tscn"', (ROOT / "project.godot").read_text())
|
||||
|
||||
def test_all_seventeen_collectibles_have_drag_ready_variants(self):
|
||||
variants = sorted((ROOT / "pickups/variants").glob("*.tscn"))
|
||||
self.assertEqual(len(variants), 17)
|
||||
assigned = set()
|
||||
for path in variants:
|
||||
text = path.read_text()
|
||||
self.assertIn('pickup_data = ExtResource("data")', text)
|
||||
assigned.add(re.search(r'path="res://(pickups/data/[^"]+)"', text)[1])
|
||||
expected = {str(path.relative_to(ROOT)) for path in (ROOT / "pickups/data").glob("*.tres") if path.stem != "lab_control"}
|
||||
self.assertEqual(assigned, expected)
|
||||
|
||||
def test_preview_code_guards_runtime_and_keeps_shapes_per_instance(self):
|
||||
pickup = (ROOT / "pickups/pickup.gd").read_text()
|
||||
self.assertTrue(pickup.startswith("@tool\n"))
|
||||
self.assertRegex(pickup, r"func _physics_process\([^\n]+\n\tif Engine.is_editor_hint\(\):\n\t\treturn")
|
||||
for relative in ("world/terrain/terrain_piece.gd", "world/props/scenery_prop.gd"):
|
||||
text = (ROOT / relative).read_text()
|
||||
self.assertTrue(text.startswith("@tool\n"))
|
||||
self.assertIn("RectangleShape2D.new()", text)
|
||||
self.assertIn("collision_enabled", text)
|
||||
self.assertNotIn("func _process(", text)
|
||||
|
||||
def test_prop_art_is_self_contained_and_valid_svg(self):
|
||||
assets = sorted((ROOT / "assets/props").glob("*.svg"))
|
||||
self.assertEqual(len(assets), 7)
|
||||
for asset in assets:
|
||||
root = ElementTree.parse(asset).getroot()
|
||||
self.assertEqual(root.attrib["shape-rendering"], "crispEdges")
|
||||
self.assertFalse(list(root.iter("{http://www.w3.org/2000/svg}image")))
|
||||
self.assertGreater(int(root.attrib["width"]), 0)
|
||||
self.assertGreater(int(root.attrib["height"]), 0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,185 @@
|
||||
extends SceneTree
|
||||
|
||||
## Pruebas reales de instanciacion, independencia, actualizacion y fisica.
|
||||
## Ejecutar tras importar: godot --headless --path . --script res://tests/test_level_kit_runtime.gd
|
||||
## Estas pruebas NO se ejecutan mediante unittest de Python.
|
||||
|
||||
var _failures: int = 0
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
await _verify_terrain()
|
||||
await _verify_props_and_signs()
|
||||
await _verify_one_way_physics()
|
||||
await _verify_presets()
|
||||
await _verify_levels()
|
||||
if _failures == 0:
|
||||
print("OK LEVEL KIT: superficies, independencia, props, carteles, one-way, presets y niveles")
|
||||
quit(0 if _failures == 0 else 1)
|
||||
|
||||
|
||||
## Un cambio de tamano no debe alterar otras instancias ni separar arte y fisica.
|
||||
func _verify_terrain() -> void:
|
||||
var packed: PackedScene = load("res://world/terrain/ground.tscn") as PackedScene
|
||||
var first: TerrainPiece = packed.instantiate() as TerrainPiece
|
||||
var second: TerrainPiece = packed.instantiate() as TerrainPiece
|
||||
root.add_child(first)
|
||||
root.add_child(second)
|
||||
first.dimensions = Vector2(736.0, 160.0)
|
||||
await process_frame
|
||||
await process_frame
|
||||
var first_shape: RectangleShape2D = first.get_node("CollisionShape2D").shape as RectangleShape2D
|
||||
var second_shape: RectangleShape2D = second.get_node("CollisionShape2D").shape as RectangleShape2D
|
||||
_check(first_shape != second_shape, "Las formas fisicas no pueden compartirse entre instancias")
|
||||
_check(first_shape.size == Vector2(736.0, 160.0), "La colision debe seguir Dimensions")
|
||||
_check(second_shape.size == Vector2(512.0, 256.0), "Editar una pieza no debe redimensionar otra")
|
||||
_check((first.get_node("Texture") as Sprite2D).region_rect.size == first.dimensions, "La textura debe seguir Dimensions")
|
||||
_check((first.get_node("Top") as Sprite2D).position == -first.dimensions * 0.5, "El borde superior debe conservar su anclaje")
|
||||
first.collision_enabled = false
|
||||
await process_frame
|
||||
await process_frame
|
||||
_check(first.collision_layer == 0 and (first.get_node("CollisionShape2D") as CollisionShape2D).disabled, "Una superficie decorativa no debe bloquear")
|
||||
_check(second.collision_layer == 1, "Desactivar una pieza no debe afectar a la otra")
|
||||
first.queue_free()
|
||||
second.queue_free()
|
||||
await process_frame
|
||||
|
||||
|
||||
## Colision y profundidad son independientes; el texto pertenece a cada cartel.
|
||||
func _verify_props_and_signs() -> void:
|
||||
var packed: PackedScene = load("res://world/props/barrel.tscn") as PackedScene
|
||||
var barrel: SceneryProp = packed.instantiate() as SceneryProp
|
||||
var other: SceneryProp = packed.instantiate() as SceneryProp
|
||||
root.add_child(barrel)
|
||||
root.add_child(other)
|
||||
barrel.draw_layer = 10
|
||||
barrel.collision_dimensions = Vector2(40.0, 60.0)
|
||||
await process_frame
|
||||
await process_frame
|
||||
_check(barrel.z_index == 10, "El barril debe poder dibujarse delante")
|
||||
_check((barrel.get_node("Body") as StaticBody2D).collision_layer == 1, "Cambiar profundidad no debe eliminar colision")
|
||||
var shape: RectangleShape2D = barrel.get_node("Body/CollisionShape2D").shape as RectangleShape2D
|
||||
var other_shape: RectangleShape2D = other.get_node("Body/CollisionShape2D").shape as RectangleShape2D
|
||||
_check(shape != other_shape and other_shape.size == Vector2(54.0, 76.0), "Las colisiones de decoracion deben ser independientes")
|
||||
barrel.collision_enabled = false
|
||||
await process_frame
|
||||
await process_frame
|
||||
_check((barrel.get_node("Body") as StaticBody2D).collision_layer == 0, "El barril decorativo debe atravesarse")
|
||||
_check(barrel.z_index == 10, "Desactivar colision no debe cambiar profundidad")
|
||||
|
||||
var sign_scene: PackedScene = load("res://world/signs/sign_post.tscn") as PackedScene
|
||||
var sign: Node2D = sign_scene.instantiate() as Node2D
|
||||
root.add_child(sign)
|
||||
sign.set("text", "TEST\nSECOND LINE")
|
||||
sign.set("font_size", 18)
|
||||
await process_frame
|
||||
await process_frame
|
||||
var label: Label = sign.get_node("Text") as Label
|
||||
_check(label.text == "TEST\nSECOND LINE", "El cartel debe mostrar el texto editado")
|
||||
_check(label.get_theme_font_size("font_size") == 18, "El cartel debe actualizar el tamano de letra")
|
||||
sign.queue_free()
|
||||
barrel.queue_free()
|
||||
other.queue_free()
|
||||
await process_frame
|
||||
|
||||
|
||||
## Comprueba el comportamiento de la fisica, no solo el flag guardado en la escena.
|
||||
func _verify_one_way_physics() -> void:
|
||||
var packed: PackedScene = load("res://world/terrain/platform.tscn") as PackedScene
|
||||
var platform: TerrainPiece = packed.instantiate() as TerrainPiece
|
||||
platform.position = Vector2(300.0, 100.0)
|
||||
root.add_child(platform)
|
||||
var body := CharacterBody2D.new()
|
||||
body.position = Vector2(300.0, 170.0)
|
||||
body.collision_layer = 2
|
||||
body.collision_mask = 1
|
||||
var collision := CollisionShape2D.new()
|
||||
var shape := RectangleShape2D.new()
|
||||
shape.size = Vector2(20.0, 20.0)
|
||||
collision.shape = shape
|
||||
body.add_child(collision)
|
||||
root.add_child(body)
|
||||
await physics_frame
|
||||
await physics_frame
|
||||
# La velocidad depende del paso de fisica del motor; no se cambia su configuracion.
|
||||
var frames: int = ceili(float(Engine.physics_ticks_per_second) * 0.5)
|
||||
for _frame: int in range(frames):
|
||||
await physics_frame
|
||||
body.velocity = Vector2(0.0, -300.0)
|
||||
body.move_and_slide()
|
||||
_check(body.position.y < 70.0, "La plataforma debe atravesarse desde abajo")
|
||||
for _frame: int in range(frames):
|
||||
await physics_frame
|
||||
body.velocity = Vector2(0.0, 300.0)
|
||||
body.move_and_slide()
|
||||
_check(body.is_on_floor(), "El cuerpo debe aterrizar sobre la plataforma")
|
||||
_check(absf(body.position.y - 80.0) < 2.0, "El aterrizaje debe coincidir con la cara superior")
|
||||
body.queue_free()
|
||||
platform.queue_free()
|
||||
await process_frame
|
||||
|
||||
|
||||
## Carga recursivamente las piezas y verifica que los objetos tengan icono real.
|
||||
func _verify_presets() -> void:
|
||||
for path: String in _scene_paths("res://world") + _scene_paths("res://pickups/variants"):
|
||||
var packed: PackedScene = load(path) as PackedScene
|
||||
_check(packed != null, "No se pudo cargar " + path)
|
||||
if packed == null:
|
||||
continue
|
||||
var instance: Node = packed.instantiate()
|
||||
root.add_child(instance)
|
||||
await process_frame
|
||||
if instance is Pickup:
|
||||
_check((instance as Pickup).pickup_data != null, "Objeto sin datos: " + path)
|
||||
_check((instance.get_node("Sprite2D") as Sprite2D).texture != null, "Objeto sin icono: " + path)
|
||||
instance.queue_free()
|
||||
await process_frame
|
||||
|
||||
|
||||
## F6 debe funcionar sin un menu o singleton que inicialice antes el escenario.
|
||||
func _verify_levels() -> void:
|
||||
for path: String in [
|
||||
"res://levels/templates/level_template.tscn",
|
||||
"res://levels/examples/scenery_catalog.tscn",
|
||||
"res://levels/level_01.tscn",
|
||||
"res://levels/level_02.tscn",
|
||||
]:
|
||||
var packed: PackedScene = load(path) as PackedScene
|
||||
_check(packed != null, "No se pudo cargar el nivel " + path)
|
||||
if packed == null:
|
||||
continue
|
||||
var level: LevelRoot = packed.instantiate() as LevelRoot
|
||||
root.add_child(level)
|
||||
current_scene = level
|
||||
await physics_frame
|
||||
await physics_frame
|
||||
var camera: Camera2D = level.get_node("Player/Camera2D") as Camera2D
|
||||
_check(camera.limit_right == ceili(level.camera_bounds.end.x), "La camara debe respetar Camera Bounds en " + path)
|
||||
if path.ends_with("level_template.tscn"):
|
||||
var player: CharacterBody2D = level.get_node("Player") as CharacterBody2D
|
||||
for _frame: int in range(6):
|
||||
await physics_frame
|
||||
_check(player.is_on_floor(), "El jugador de la plantilla debe comenzar apoyado en el suelo")
|
||||
current_scene = null
|
||||
level.queue_free()
|
||||
await process_frame
|
||||
|
||||
|
||||
func _scene_paths(folder: String) -> Array[String]:
|
||||
var result: Array[String] = []
|
||||
for file_name: String in DirAccess.get_files_at(folder):
|
||||
if file_name.ends_with(".tscn"):
|
||||
result.append(folder.path_join(file_name))
|
||||
for directory: String in DirAccess.get_directories_at(folder):
|
||||
result.append_array(_scene_paths(folder.path_join(directory)))
|
||||
return result
|
||||
|
||||
|
||||
func _check(condition: bool, message: String) -> void:
|
||||
if not condition:
|
||||
_failures += 1
|
||||
push_error("Level Kit: " + message)
|
||||
@@ -1,9 +1,8 @@
|
||||
"""Validate Godot pickup resources before exporting Android.
|
||||
"""Valida recursos de objetos antes de exportar a Android.
|
||||
|
||||
Godot's serialized .tres files only accept Color(r, g, b, a) with numeric
|
||||
arguments. The GDScript syntax Color("#hex") is *not* valid here and caused
|
||||
all item data to fail to load (white squares named "Item").
|
||||
"""
|
||||
Los archivos .tres utilizan Color(r, g, b, a) con argumentos numericos.
|
||||
La forma de GDScript Color("#hex") no se utiliza en estos datos serializados;
|
||||
la regresion original impedia cargar los objetos y mostraba cuadros blancos."""
|
||||
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
@@ -2,8 +2,8 @@ extends SceneTree
|
||||
|
||||
const PICKUP_SCENE: PackedScene = preload("res://pickups/pickup.tscn")
|
||||
|
||||
## Full Godot integration test. Requires the real engine and imported SVGs.
|
||||
## Run: godot --headless --path . --script res://tests/test_pickup_runtime.gd
|
||||
## Prueba de integracion en Godot. Requiere el motor real y los SVG importados.
|
||||
## Ejecutar: godot --headless --path . --script res://tests/test_pickup_runtime.gd
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
@@ -26,7 +26,7 @@ func _run() -> void:
|
||||
_fail("No se esta ejecutando level_01.gd")
|
||||
return
|
||||
|
||||
# The pre-placed control pickup must work even without any enemy death.
|
||||
# El objeto de control colocado en la escena debe funcionar sin muertes enemigas.
|
||||
var control: Pickup = level.get_node("ControlPickup") as Pickup
|
||||
if control == null or control.pickup_data == null or control.pickup_data.id != &"lab_control":
|
||||
_fail("El pickup de control no se instancio")
|
||||
@@ -41,8 +41,8 @@ func _run() -> void:
|
||||
_fail("Un objeto fijo debe ser recogible desde el primer instante")
|
||||
return
|
||||
|
||||
# Test a real collision, not a direct call to collect_pickup(). This used
|
||||
# to fail when monitoring was disabled while the player ran past the item.
|
||||
# Probar una colision real, no una llamada directa a collect_pickup(). Antes
|
||||
# fallaba al pasar corriendo junto al objeto con la deteccion desactivada.
|
||||
var player: CharacterBody2D = level.get_node("Player") as CharacterBody2D
|
||||
player.global_position = control.global_position
|
||||
await physics_frame
|
||||
@@ -58,8 +58,8 @@ func _run() -> void:
|
||||
_fail("El objeto de control no debe contar entre los 17 drops")
|
||||
return
|
||||
|
||||
# Touch a dropped speed item while the 0.75-second collection delay is
|
||||
# running, then move away as if running through it. It must not be lost.
|
||||
# Tocar un objeto de velocidad durante los 0,75 segundos de espera para
|
||||
# recogerlo y alejarse como al pasar corriendo. No debe perderse la recogida.
|
||||
var base_speed: float = float(player.call("get_move_speed"))
|
||||
var speed_drop: Pickup = PICKUP_SCENE.instantiate() as Pickup
|
||||
speed_drop.pickup_data = load("res://pickups/data/coffee.tres") as PickupData
|
||||
@@ -79,7 +79,7 @@ func _run() -> void:
|
||||
_fail("El Tostado del Averno no ha aumentado la velocidad un 25%%")
|
||||
return
|
||||
|
||||
# The multiplier must affect actual horizontal movement, not just a label.
|
||||
# El multiplicador debe afectar al movimiento real, no solo a una etiqueta.
|
||||
Input.action_press("move_right")
|
||||
await create_timer(0.3).timeout
|
||||
Input.action_release("move_right")
|
||||
@@ -90,8 +90,8 @@ func _run() -> void:
|
||||
player.global_position = Vector2(170, 557)
|
||||
await create_timer(0.15).timeout
|
||||
|
||||
# A full-health heal should stay on the floor, then get collected without
|
||||
# requiring a second body_entered signal when HP decreases in place.
|
||||
# Una cura con la vida llena debe seguir en el suelo y recogerse al perder
|
||||
# vida sin exigir una segunda senal body_entered ni salir del solapamiento.
|
||||
var heal_pickup: Pickup = PICKUP_SCENE.instantiate() as Pickup
|
||||
heal_pickup.pickup_data = load("res://pickups/data/beer.tres") as PickupData
|
||||
heal_pickup.position = player.position
|
||||
@@ -122,8 +122,8 @@ func _run() -> void:
|
||||
return
|
||||
expected_ids[data.id] = true
|
||||
|
||||
# Simulate a missed signal for station 01. The polling of is_dead must
|
||||
# still register its KO and create the guaranteed drop.
|
||||
# Simular la perdida de una senal de la estacion 01. Consultar is_dead debe
|
||||
# permitir registrar la derrota y crear la recompensa garantizada.
|
||||
var lab_callback: Callable = Callable(level, "_on_station_enemy_died")
|
||||
enemies[0].disconnect(&"died", lab_callback)
|
||||
for enemy in enemies:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Engine-independent checks. Run: python -m unittest discover -s tests -v."""
|
||||
"""Pruebas sin motor: python -m unittest discover -s tests -v."""
|
||||
from pathlib import Path
|
||||
import math
|
||||
import re
|
||||
@@ -45,8 +45,8 @@ class PixelCombatResourceTests(unittest.TestCase):
|
||||
self.assertTrue((ROOT / path).is_file(), path)
|
||||
|
||||
def test_pulse_rounding_preserves_the_damage_budget(self):
|
||||
# Mathematical invariant used by the GDScript cumulative damage formula.
|
||||
# Runtime behaviour is covered separately by test_pixel_combat_runtime.gd.
|
||||
# Invariante matematica de la formula de dano acumulado de GDScript.
|
||||
# test_pixel_combat_runtime.gd comprueba por separado el comportamiento real.
|
||||
for total in range(1, 101):
|
||||
for count in range(1, 9):
|
||||
dealt = 0
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
extends SceneTree
|
||||
|
||||
## Run after importing assets:
|
||||
## Ejecutar despues de importar los recursos:
|
||||
## godot --headless --path . --script res://tests/test_pixel_combat_runtime.gd
|
||||
## Tests actual scene instantiation, pulse damage, death lifecycle and respawn.
|
||||
## Comprueba instanciacion real, dano por pulsos, ciclo de muerte y reaparicion.
|
||||
|
||||
var _failures: int = 0
|
||||
var _death_signals: int = 0
|
||||
@@ -38,7 +38,7 @@ func _run() -> void:
|
||||
_check(sprite.sprite_frames.get_frame_texture(animation, index) != null,
|
||||
"Missing texture in " + str(animation))
|
||||
|
||||
# Keep positions fixed, so pulse falloff and screen clipping are deterministic.
|
||||
# Mantener posiciones fijas para que la atenuacion y el recorte sean deterministas.
|
||||
player.set_physics_process(false)
|
||||
for node: Node in get_nodes_in_group("enemy"):
|
||||
node.set_physics_process(false)
|
||||
@@ -104,7 +104,7 @@ func _run() -> void:
|
||||
_check(is_zero_approx(enemy_visual.rotation) and is_equal_approx(enemy_visual.self_modulate.a, 1.0),
|
||||
"Respawn must restore the sprite transform and opacity")
|
||||
|
||||
# Shape query uses the new landing position, with combat shapes restored.
|
||||
# La consulta de forma usa la posicion de aterrizaje y las colisiones restauradas.
|
||||
enemy.global_position = player.global_position + Vector2(30, 0)
|
||||
enemy.set("max_health", 50)
|
||||
enemy.set("current_health", 50)
|
||||
@@ -115,7 +115,7 @@ func _run() -> void:
|
||||
player.call("_ground_pound_impact")
|
||||
_check(int(enemy.get("current_health")) == 38, "High ground pound must deal exactly 12 damage")
|
||||
|
||||
# Exercise effect processing/cleanup, not just resource loading.
|
||||
# Probar el procesamiento y la limpieza de efectos, no solo la carga de recursos.
|
||||
await create_timer(0.8).timeout
|
||||
if _failures == 0:
|
||||
print("OK PIXEL COMBAT: animations, solo pulses, recoil, death, rewards, respawn and ground pound")
|
||||
|
||||
Reference in new issue
Block a user