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:
+5
-6
@@ -1,5 +1,4 @@
|
||||
from .unit import Unit
|
||||
from .rat import Rat
|
||||
from .unit import Unit, UnitType
|
||||
from engine.collision_system import CollisionLayer
|
||||
import random
|
||||
|
||||
@@ -8,7 +7,7 @@ AGE_THRESHOLD = 200
|
||||
|
||||
class Gas(Unit):
|
||||
def __init__(self, game, position=(0,0), id=None, parent_id=None):
|
||||
super().__init__(game, position, id, collision_layer=CollisionLayer.GAS)
|
||||
super().__init__(game, position, id, collision_layer=CollisionLayer.GAS, unit_type=UnitType.GAS)
|
||||
self.parent_id = parent_id
|
||||
# Specific attributes for gas
|
||||
self.speed = 50
|
||||
@@ -33,7 +32,7 @@ class Gas(Unit):
|
||||
|
||||
for victim_id in victim_ids:
|
||||
victim = self.game.unit_manager.get_unit_by_id(victim_id)
|
||||
if victim and isinstance(victim, Rat):
|
||||
if victim and victim.type in [UnitType.RAT_MALE, UnitType.RAT_FEMALE]:
|
||||
if victim.partial_move > 0.5:
|
||||
victim.gassed += 1
|
||||
|
||||
@@ -44,7 +43,7 @@ class Gas(Unit):
|
||||
|
||||
for victim_id in victim_ids_before:
|
||||
victim = self.game.unit_manager.get_unit_by_id(victim_id)
|
||||
if victim and isinstance(victim, Rat):
|
||||
if victim and victim.type in [UnitType.RAT_MALE, UnitType.RAT_FEMALE]:
|
||||
if victim.partial_move < 0.5:
|
||||
victim.gassed += 1
|
||||
|
||||
@@ -59,7 +58,7 @@ class Gas(Unit):
|
||||
new_x = self.position[0] + dx
|
||||
new_y = self.position[1] + dy
|
||||
if not self.game.map.is_wall(new_x, new_y):
|
||||
if not any(isinstance(unit, Gas) for unit in self.game.units.values() if unit.position == (new_x, new_y)):
|
||||
if not any(unit.type == UnitType.GAS for unit in self.game.units.values() if unit.position == (new_x, new_y)):
|
||||
print(f"Spreading gas from {self.position} to ({new_x}, {new_y})")
|
||||
self.game.unit_manager.spawn_unit(Gas, (new_x, new_y), parent_id=self.parent_id if self.parent_id else self.id)
|
||||
def collisions(self):
|
||||
|
||||
Reference in New Issue
Block a user