Add comprehensive test suite for game mechanics and level handling

- Introduced `test_final_level_flow.py` to validate final level transitions and game end scenarios.
- Created `test_game_over_flow.py` to ensure game over conditions trigger correctly based on rat counts.
- Implemented `test_keybindings.py` to verify keybinding configurations and their context-specific actions.
- Developed `test_level_editor.py` to assess level editor functionalities and layout computations.
- Added `test_level_io.py` for testing level data serialization and deserialization.
- Established `test_loop_logic_parity.py` to ensure consistent game state across multiple simulation runs.
- Created `test_non_regression.py` to simulate game behavior and capture states for future verification.
- Implemented `test_verify.py` to compare current game states against a golden master for regression detection.
This commit is contained in:
2026-05-19 22:18:43 +02:00
parent 486cd6b7c5
commit c7ed24483d
53 changed files with 10169 additions and 3886 deletions
+3 -3
View File
@@ -1,10 +1,10 @@
from .unit import Unit
from .unit import Unit, UnitType
from .bomb import Explosion
from engine.collision_system import CollisionLayer
class Mine(Unit):
def __init__(self, game, position=(0,0), id=None):
super().__init__(game, position, id, collision_layer=CollisionLayer.MINE)
super().__init__(game, position, id, collision_layer=CollisionLayer.MINE, unit_type=UnitType.MINE)
self.speed = 1.0 # Mine doesn't move but needs speed for consistency
self.armed = True # Mine is active and ready to explode
@@ -24,7 +24,7 @@ class Mine(Unit):
for victim_id in victim_ids:
rat_unit = self.game.unit_manager.get_unit_by_id(victim_id)
if rat_unit and hasattr(rat_unit, 'sex'): # Check if it's a rat
if rat_unit and rat_unit.type in [UnitType.RAT_MALE, UnitType.RAT_FEMALE]:
# Mine explodes and kills the rat
self.explode(rat_unit)
break