mejoras en jugabilidad
This commit is contained in:
1 parent
d983bc2e69
commit
ec7e35ddf6
40 files changed
+856
-538
No files matched your search
@@ -31,7 +31,7 @@ class BandResourceTests(unittest.TestCase):
|
||||
def test_base_stats_remain_shared(self):
|
||||
for role in ROLES:
|
||||
data = source(f'player/characters/{role}.tres')
|
||||
for stat in ('max_health = 50', 'move_speed = 390.0', 'jump_velocity = -600.0', 'basic_attack_damage = 5'):
|
||||
for stat in ('max_health = 30', 'move_speed = 390.0', 'jump_velocity = -600.0', 'basic_attack_damage = 5'):
|
||||
self.assertIn(stat, data)
|
||||
player = source('player/player.gd')
|
||||
for stat in ('special_charge_per_kill: int = 10', 'special_min_use_charge: int = 25',
|
||||
|
||||
@@ -47,7 +47,7 @@ func _test_safe_start() -> void:
|
||||
for node: Node in enemies.get_children():
|
||||
node.set("is_awake", true)
|
||||
await _frames(90)
|
||||
_check(int(_player.get("current_health")) == 50, "No damage at the starting point")
|
||||
_check(int(_player.get("current_health")) == 30, "No damage at the starting point")
|
||||
for node: Node in enemies.get_children():
|
||||
_check(not bool(node.get("_is_pursuing")), "Spawn aggro: " + str(node.name))
|
||||
|
||||
@@ -61,7 +61,8 @@ func _test_chasing_and_return() -> void:
|
||||
_player.position.x = 2000.0
|
||||
await _advance(120)
|
||||
_check(not bool(_enemy.get("_is_pursuing")), "Lose target outside the leash")
|
||||
_check(absf(_enemy.position.x - 100.0) < 12.0, "Return towards spawn, do not teleport")
|
||||
_check(absf(_enemy.position.x - 100.0) <= float(_enemy.get("patrol_range")) + 24.0,
|
||||
"Return to the patrol zone instead of chasing forever")
|
||||
|
||||
|
||||
func _test_jumping() -> void:
|
||||
@@ -128,26 +129,30 @@ func _test_damage_and_push() -> void:
|
||||
# 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(int(_player.get("current_health")) == 24, "Guard hit must deal six HP")
|
||||
_check(is_equal_approx(_player.velocity.x, 558.0), "Guard must push away with 1.8x horizontal impulse")
|
||||
_check(_player.velocity.y < -270.0, "Guard also has a slightly stronger upward impulse")
|
||||
_player.set("invulnerability_timer", 0.0)
|
||||
_enemy.call("_update_attack_damage")
|
||||
_check(int(_player.get("current_health")) == 44, "One sweep must not hit twice")
|
||||
_check(int(_player.get("current_health")) == 24, "One sweep must not hit twice")
|
||||
|
||||
_player.call("take_damage", 2, _enemy.global_position)
|
||||
_check(int(_player.get("current_health")) == 42, "Old two-argument damage callers still work")
|
||||
_check(int(_player.get("current_health")) == 22, "Old two-argument damage callers still work")
|
||||
_check(is_equal_approx(_player.velocity.x, 310.0), "Default impulse remains unchanged")
|
||||
_player.set("invulnerability_timer", 0.0)
|
||||
_player.set("_shield_hits", 1)
|
||||
_player.velocity = Vector2.ZERO
|
||||
_player.call("take_damage", 6, _enemy.global_position, 1.8)
|
||||
_check(int(_player.get("current_health")) == 42 and _player.velocity == Vector2.ZERO,
|
||||
_check(int(_player.get("current_health")) == 22 and _player.velocity == Vector2.ZERO,
|
||||
"A shield must block both damage and impulse")
|
||||
|
||||
_enemy.set("_jump_in_progress", true)
|
||||
_enemy.call("take_damage", 1, _player.global_position)
|
||||
_check(not bool(_enemy.get("_jump_in_progress")), "Hit must cancel jump steering, preserving knockback")
|
||||
_check(float(_enemy.get("stagger_resistance_timer")) > 0.0, "An accepted hit starts stagger resistance")
|
||||
_enemy.set("attack_state", 1) # WINDUP
|
||||
_enemy.call("take_damage", 1, _player.global_position)
|
||||
_check(int(_enemy.get("attack_state")) == 1, "Repeated punch must not cancel the enemy forever")
|
||||
_enemy.call("take_damage", 100, _player.global_position)
|
||||
_check(bool(_enemy.get("is_dead")) and _enemy.visible, "Retain the delayed death animation")
|
||||
_enemy.call("_respawn")
|
||||
@@ -155,6 +160,7 @@ func _test_damage_and_push() -> void:
|
||||
_check(not bool(_enemy.get("_is_pursuing")) and not bool(_enemy.get("_jump_in_progress")),
|
||||
"Respawn must reset pursuit and jump state")
|
||||
_check(is_zero_approx(float(_enemy.get("_jump_cooldown_timer"))), "Respawn must reset the jump cooldown")
|
||||
_check(is_zero_approx(float(_enemy.get("stagger_resistance_timer"))), "Respawn must reset stagger resistance")
|
||||
|
||||
|
||||
func _arena(variant: String, floors: Array[Rect2], enemy_position: Vector2,
|
||||
|
||||
@@ -28,8 +28,8 @@ class EnemyProfileTests(unittest.TestCase):
|
||||
def test_only_two_agile_variants_jump(self):
|
||||
jumpers = {name for name, p in self.profiles.items() if p.get('can_jump', False)}
|
||||
self.assertEqual(jumpers, {'pogo_fan', 'rival_guitarist'})
|
||||
hoppers = {name for name, p in self.profiles.items() if p.get('hop_while_chasing', False)}
|
||||
self.assertEqual(hoppers, {'pogo_fan'})
|
||||
for name, p in self.profiles.items():
|
||||
self.assertFalse(p.get('hop_while_chasing', False), name)
|
||||
|
||||
def test_chase_is_longer_but_not_unlimited(self):
|
||||
for name, p in self.profiles.items():
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
"""Contratos de la base jugable. No sustituyen las pruebas en Godot/Android."""
|
||||
from pathlib import Path
|
||||
import re
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def read(path):
|
||||
return (ROOT / path).read_text(encoding="utf-8")
|
||||
|
||||
|
||||
class GameplayBaseTests(unittest.TestCase):
|
||||
def test_player_balance(self):
|
||||
player = read("player/player.gd")
|
||||
self.assertIn('punch_cooldown: float = 0.60', player)
|
||||
self.assertIn('ground_pound_cooldown: float = 7.0', player)
|
||||
self.assertIn('ground_pound_cooldown_timer > 0.0', player)
|
||||
self.assertIn('ground_pound_cooldown_timer = ground_pound_cooldown', player)
|
||||
self.assertIn('ground_pound_cooldown_timer - delta', player)
|
||||
self.assertIn('punch_timer > 0.0', player)
|
||||
for name in ('guitarist', 'drummer', 'bassist', 'singer'):
|
||||
self.assertIn('max_health = 30', read(f'player/characters/{name}.tres'))
|
||||
|
||||
def test_heal_balance(self):
|
||||
for name, value in [('bocata_roadie', 8), ('beer', 10),
|
||||
('pizza_post_bolo', 15), ('tupper_bateria', 20)]:
|
||||
self.assertIn(f'value = {value}.0', read(f'pickups/data/{name}.tres'))
|
||||
|
||||
def test_radii_are_world_based_and_punch_respects_walls(self):
|
||||
code = read('player/player.gd')
|
||||
self.assertIn('special_radius: float = 290.0', code)
|
||||
self.assertIn('distance / radius', code)
|
||||
self.assertIn('if distance > radius:', code)
|
||||
self.assertNotIn('get_visible_rect()', code)
|
||||
self.assertIn('_damage_target(area, get_basic_attack_damage(), punch_hit_targets, true)', code)
|
||||
self.assertIn('PhysicsRayQueryParameters2D.create(', code)
|
||||
|
||||
def test_enemies_have_profiles_and_do_not_stun_lock(self):
|
||||
code = read('enemies/walker/walker.gd')
|
||||
self.assertIn('stagger_resistance_timer > 0.0', code)
|
||||
self.assertIn('func _update_patrol(delta: float)', code)
|
||||
self.assertIn('preferred_distance > 0.0', code)
|
||||
self.assertNotIn('wants_hop:', code)
|
||||
self.assertIn('patrol_range = 65.0', read('enemies/variants/roadie.tscn'))
|
||||
self.assertIn('preferred_distance = 130.0', read('enemies/variants/feedback_tech.tscn'))
|
||||
self.assertNotIn('hop_while_chasing = true', read('enemies/variants/pogo_fan.tscn'))
|
||||
|
||||
def test_editor_level_components_are_packaged(self):
|
||||
for name in ('kill_gate', 'boss_victory'):
|
||||
script = read(f'world/triggers/{name}.gd')
|
||||
scene = read(f'world/triggers/{name}.tscn')
|
||||
self.assertIn('@tool', script)
|
||||
self.assertIn(f'path="res://world/triggers/{name}.gd"', scene)
|
||||
boss = read('bosses/spectral_death/spectral_death.gd')
|
||||
self.assertIn('arena_rect: Rect2', boss)
|
||||
self.assertIn('_arena_world = Rect2(to_global(arena_rect.position), arena_rect.size)', boss)
|
||||
self.assertNotIn('const FLOOR_Y:', boss)
|
||||
self.assertNotIn('const ARENA_LEFT:', boss)
|
||||
self.assertIn('script = ExtResource("level")', read('levels/level_02.tscn'))
|
||||
self.assertNotIn('level_02.gd', read('levels/level_02.tscn'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -68,9 +68,9 @@ class Level00ResourceTests(unittest.TestCase):
|
||||
self.assertIn('run/main_scene="res://game/main.tscn"', (ROOT / 'project.godot').read_text())
|
||||
self.assertIn('respawn_delay = 0.0', (ROOT / 'enemies/variants/roadie.tscn').read_text())
|
||||
|
||||
def test_50_hp_all_characters_and_12_point_ground_pound(self):
|
||||
def test_30_hp_all_characters_and_12_point_ground_pound(self):
|
||||
for data in (ROOT / "player/characters").glob("*.tres"):
|
||||
self.assertIn('max_health = 50', data.read_text(), data.name)
|
||||
self.assertIn('max_health = 30', data.read_text(), data.name)
|
||||
player = (ROOT / 'player/player.gd').read_text()
|
||||
self.assertIn('ground_pound_min_damage: int = 7', player)
|
||||
self.assertIn('ground_pound_max_damage: int = 12', player)
|
||||
|
||||
@@ -25,11 +25,11 @@ func _run() -> void:
|
||||
_fail("No se ha instanciado el jugador")
|
||||
return
|
||||
var character_data: CharacterData = player.get("character_data") as CharacterData
|
||||
if character_data == null or character_data.max_health != 50:
|
||||
_fail("El jugador no inicia con los datos de 50 HP")
|
||||
if character_data == null or character_data.max_health != 30:
|
||||
_fail("El jugador no inicia con los datos de 30 HP")
|
||||
return
|
||||
if int(player.get("current_health")) != 50:
|
||||
_fail("La vida inicial real no es 50")
|
||||
if int(player.get("current_health")) != 30:
|
||||
_fail("La vida inicial real no es 30")
|
||||
return
|
||||
if int(player.get("ground_pound_min_damage")) != 7 or int(player.get("ground_pound_max_damage")) != 12:
|
||||
_fail("El ground pound no esta configurado entre 7 y 12")
|
||||
@@ -75,7 +75,7 @@ func _run() -> void:
|
||||
_fail("Faltan las barreras de inicio y final")
|
||||
return
|
||||
|
||||
print("OK LEVEL00: escena, 50 HP, pound 7-12, 29 enemigos, 14 pickups, 4 parallax, calles, plataformas y barreras")
|
||||
print("OK LEVEL00: escena, 30 HP, pound 7-12, 29 enemigos, 14 pickups, 4 parallax, calles, plataformas y barreras")
|
||||
quit(0)
|
||||
|
||||
|
||||
|
||||
@@ -42,16 +42,24 @@ class Level02VisualResourceTests(unittest.TestCase):
|
||||
self.assertIn('"double_sweep", "scythe", "runes", "dash", "rest"', BOSS_CODE)
|
||||
self.assertIn('current_health = PHASE_HEALTH', BOSS_CODE)
|
||||
|
||||
def test_gate_keeps_the_original_kill_requirement_and_opens_visibly(self):
|
||||
level_code = (ROOT / "levels/level_02.gd").read_text()
|
||||
self.assertIn('remaining == 0', level_code)
|
||||
self.assertIn('has de derrotar a todos los mal nacidos para poder atravesar esta puerta!', level_code)
|
||||
self.assertIn('gate_visual.fully_open.connect(', level_code)
|
||||
self.assertIn('gate_visual.set_unlocked(_gate_open)', level_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('fully_open.emit()', GATE_CODE)
|
||||
self.assertIn('name="Visual" type="Node2D"', LEVEL)
|
||||
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__":
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
extends SceneTree
|
||||
|
||||
## Pruebas de motor: puerta configurable, victoria por senal y arena relativa al jefe.
|
||||
## godot --headless --path . --script res://tests/test_level_components_runtime.gd
|
||||
|
||||
class DummyActor:
|
||||
extends Node2D
|
||||
signal died
|
||||
var is_dead: bool = false
|
||||
|
||||
var _failures: int = 0
|
||||
var _victories: int = 0
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
preload("res://tests/runtime_test_profile.gd").prepare(self)
|
||||
await _test_gate()
|
||||
await _test_boss_victory()
|
||||
await _test_movable_arena()
|
||||
print("LEVEL COMPONENTS: %d failures" % _failures)
|
||||
quit(0 if _failures == 0 else 1)
|
||||
|
||||
|
||||
func _test_gate() -> void:
|
||||
var world := Node2D.new()
|
||||
root.add_child(world)
|
||||
var enemies := Node2D.new()
|
||||
enemies.name = "Enemies"
|
||||
world.add_child(enemies)
|
||||
var foe := DummyActor.new()
|
||||
enemies.add_child(foe)
|
||||
var gate := preload("res://world/triggers/kill_gate.tscn").instantiate() as StaticBody2D
|
||||
gate.set("enemies_root_path", NodePath("../Enemies"))
|
||||
world.add_child(gate)
|
||||
await process_frame
|
||||
_check(int(gate.get("remaining")) == 1, "Gate counts configured enemies")
|
||||
foe.died.emit()
|
||||
_check(int(gate.get("remaining")) == 0, "Gate tracks enemy death")
|
||||
gate.get_node("Visual").call("_process", 1.3)
|
||||
await process_frame
|
||||
await physics_frame
|
||||
_check((gate.get_node("CollisionShape2D") as CollisionShape2D).disabled,
|
||||
"Gate collision is removed after full visual opening")
|
||||
world.queue_free()
|
||||
await process_frame
|
||||
|
||||
|
||||
func _test_boss_victory() -> void:
|
||||
var level := LevelRoot.new()
|
||||
level.enable_level_menu = false
|
||||
var player := DummyActor.new()
|
||||
player.name = "Player"
|
||||
level.add_child(player)
|
||||
var boss := DummyActor.new()
|
||||
boss.name = "Boss"
|
||||
level.add_child(boss)
|
||||
var victory := preload("res://world/triggers/boss_victory.tscn").instantiate()
|
||||
victory.set("boss_path", NodePath("../Boss"))
|
||||
victory.set("completion_delay", 0.0)
|
||||
level.add_child(victory)
|
||||
level.level_completed.connect(_on_level_completed)
|
||||
root.add_child(level)
|
||||
await process_frame
|
||||
boss.died.emit()
|
||||
await create_timer(0.06).timeout
|
||||
_check(_victories == 1, "Boss victory finishes exactly once")
|
||||
boss.died.emit()
|
||||
await create_timer(0.06).timeout
|
||||
_check(_victories == 1, "Duplicate boss signal cannot finish twice")
|
||||
level.queue_free()
|
||||
await process_frame
|
||||
|
||||
|
||||
func _test_movable_arena() -> void:
|
||||
var boss := preload("res://bosses/spectral_death/spectral_death.tscn").instantiate() as Node2D
|
||||
boss.position = Vector2(2400, 800)
|
||||
root.add_child(boss)
|
||||
await process_frame
|
||||
var rect: Rect2 = boss.get("_arena_world")
|
||||
_check(is_equal_approx(rect.position.x, 1810.0) and is_equal_approx(rect.end.y, 920.0),
|
||||
"Boss arena follows its initial placement, not hardcoded world coordinates")
|
||||
boss.queue_free()
|
||||
await process_frame
|
||||
|
||||
|
||||
func _on_level_completed() -> void:
|
||||
_victories += 1
|
||||
|
||||
|
||||
func _check(condition: bool, message: String) -> void:
|
||||
if condition:
|
||||
return
|
||||
_failures += 1
|
||||
push_error(message)
|
||||
@@ -65,7 +65,7 @@ func _run() -> void:
|
||||
_player.set("current_health", 20)
|
||||
await create_timer(0.1).timeout
|
||||
_check(not is_instance_valid(heal), "La cura solapada se reintenta sin salir y entrar")
|
||||
_check(int(_player.get("current_health")) == 50, "Debe curar hasta el maximo, no sobrepasarlo")
|
||||
_check(int(_player.get("current_health")) == 30, "Debe curar hasta el maximo, no sobrepasarlo")
|
||||
|
||||
_test_damage_rules()
|
||||
await _test_rejected_damage_stays_in_world()
|
||||
|
||||
@@ -116,6 +116,18 @@ func _run() -> void:
|
||||
player.call("_ground_pound_impact")
|
||||
_check(int(enemy.get("current_health")) == 38, "High ground pound must deal exactly 12 damage")
|
||||
|
||||
# El cooldown de 7s empieza al lanzarse, no al aterrizar; no bloquea el punetazo.
|
||||
player.call("_start_ground_pound")
|
||||
_check(is_equal_approx(float(player.get("ground_pound_cooldown_timer")), 7.0),
|
||||
"Ground Pound starts its own seven-second cooldown")
|
||||
player.set("ground_pound_active", false)
|
||||
player.call("_start_ground_pound")
|
||||
_check(not bool(player.get("ground_pound_active")), "Cannot repeat Ground Pound during cooldown")
|
||||
player.call("_update_timers", 7.0)
|
||||
player.call("_start_ground_pound")
|
||||
_check(bool(player.get("ground_pound_active")), "Ground Pound works again after cooldown")
|
||||
player.set("ground_pound_active", false)
|
||||
|
||||
# Probar el procesamiento y la limpieza de efectos, no solo la carga de recursos.
|
||||
await create_timer(0.8).timeout
|
||||
if _failures == 0:
|
||||
|
||||
@@ -70,12 +70,12 @@ func _run() -> void:
|
||||
_close_level()
|
||||
_new_level()
|
||||
var data: CharacterData = _player.get("character_data") as CharacterData
|
||||
_check(data.max_health == 50 and data.basic_attack_damage == 5, "Los datos compartidos no se mutan")
|
||||
_check(int(_player.call("get_max_health")) == 60, "Se aplica vida maxima adicional")
|
||||
_check(data.max_health == 30 and data.basic_attack_damage == 5, "Los datos compartidos no se mutan")
|
||||
_check(int(_player.call("get_max_health")) == 40, "Se aplica vida maxima adicional")
|
||||
_check(int(_player.call("get_basic_attack_damage")) == 6, "Se aplica dano base adicional")
|
||||
_player.set("current_health", 10)
|
||||
_player.call("collect_pickup", load("res://pickups/data/beer.tres"))
|
||||
_check(int(_player.get("current_health")) <= 60, "La cura respeta el maximo efectivo")
|
||||
_check(int(_player.get("current_health")) <= 40, "La cura respeta el maximo efectivo")
|
||||
_close_level()
|
||||
|
||||
# Reabrir el archivo demuestra el contrato de carga, no solo el estado de la misma instancia.
|
||||
|
||||
Reference in new issue
Block a user