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
+15 -2
View File
@@ -1,6 +1,16 @@
from abc import ABC, abstractmethod
import uuid
from enum import Enum, auto
class UnitType(Enum):
RAT_MALE = auto()
RAT_FEMALE = auto()
BOMB_TIMER = auto()
BOMB_NUCLEAR = auto()
GAS = auto()
MINE = auto()
POINT = auto()
EXPLOSION = auto()
class Unit(ABC):
"""
@@ -28,6 +38,8 @@ class Unit(ABC):
Number of ticks to remain stationary.
collision_layer : int
Collision layer for the optimized collision system.
type : UnitType
The specific type of the unit.
Methods
-------
@@ -40,7 +52,7 @@ class Unit(ABC):
die()
Remove unit from game and handle cleanup.
"""
def __init__(self, game, position=(0, 0), id=None, collision_layer=0):
def __init__(self, game, position=(0, 0), id=None, collision_layer=0, unit_type=None):
"""Initialize a unit with game reference and position."""
self.id = id if id else uuid.uuid4()
self.game = game
@@ -49,9 +61,10 @@ class Unit(ABC):
self.age = 0
self.speed = 1.0
self.partial_move = 0
self.bbox = (0, 0, 0, 0)
self.bbox = (0.0, 0.0, 0.0, 0.0) # Ensure it's a tuple of floats
self.stop = 0
self.collision_layer = collision_layer
self.type = unit_type if unit_type else UnitType.POINT # Default type
@abstractmethod
def move(self):