Add non-regression test states and Bluetooth diagnostic script
- Introduced a new JSON file containing non-regression test states with detailed unit information, including positions, ages, and movement directions across multiple frames. - Added a shell script for Bluetooth diagnostics that checks system information, Bluetooth binaries, running processes, D-Bus status, Bluetooth controller details, and audio stack status, providing a comprehensive overview for troubleshooting.
This commit is contained in:
+6
-6
@@ -36,7 +36,7 @@ class Bomb(Unit):
|
||||
n = 1
|
||||
if n < 0:
|
||||
n = 0
|
||||
image = self.game.bomb_assets[n]
|
||||
image = self.game.graphics.bomb_assets[n]
|
||||
image_size = self.game.render_engine.get_image_size(image)
|
||||
self.rat_image = image
|
||||
partial_x, partial_y = 0, 0
|
||||
@@ -70,7 +70,7 @@ class Timer(Bomb):
|
||||
print(f"Unit {target_unit.id} already dead")
|
||||
|
||||
# Bomb-specific behavior: create explosion
|
||||
self.game.spawn_unit(Explosion, target_unit.position)
|
||||
self.game.unit_manager.spawn_unit(Explosion, target_unit.position)
|
||||
|
||||
# Collect all explosion positions using vectorized approach
|
||||
explosion_positions = []
|
||||
@@ -94,7 +94,7 @@ class Timer(Bomb):
|
||||
|
||||
# Create all explosions at once
|
||||
for pos in explosion_positions:
|
||||
self.game.spawn_unit(Explosion, pos)
|
||||
self.game.unit_manager.spawn_unit(Explosion, pos)
|
||||
|
||||
# Use optimized collision system to get all rats in explosion area
|
||||
# This replaces the nested loop with a single vectorized operation
|
||||
@@ -105,7 +105,7 @@ class Timer(Bomb):
|
||||
|
||||
# Kill all victims with score multiplier
|
||||
for victim_id in victim_ids:
|
||||
victim = self.game.get_unit_by_id(victim_id)
|
||||
victim = self.game.unit_manager.get_unit_by_id(victim_id)
|
||||
if victim and victim.id in self.game.units:
|
||||
# Determine position based on partial_move
|
||||
victim_pos = victim.position if victim.partial_move >= 0.5 else victim.position_before
|
||||
@@ -128,7 +128,7 @@ class Explosion(Bomb):
|
||||
self.die()
|
||||
|
||||
def draw(self):
|
||||
image = self.game.assets["BMP_EXPLOSION"]
|
||||
image = self.game.graphics.assets["BMP_EXPLOSION"]
|
||||
image_size = self.game.render_engine.get_image_size(image)
|
||||
partial_x, partial_y = 0, 0
|
||||
|
||||
@@ -186,7 +186,7 @@ class NuclearBomb(Unit):
|
||||
|
||||
def draw(self):
|
||||
"""Draw nuclear bomb on position"""
|
||||
image = self.game.assets["BMP_NUCLEAR"]
|
||||
image = self.game.graphics.assets["BMP_NUCLEAR"]
|
||||
image_size = self.game.render_engine.get_image_size(image)
|
||||
|
||||
x_pos = self.position[0] * self.game.cell_size + (self.game.cell_size - image_size[0]) // 2
|
||||
|
||||
+5
-5
@@ -32,7 +32,7 @@ class Gas(Unit):
|
||||
)
|
||||
|
||||
for victim_id in victim_ids:
|
||||
victim = self.game.get_unit_by_id(victim_id)
|
||||
victim = self.game.unit_manager.get_unit_by_id(victim_id)
|
||||
if victim and isinstance(victim, Rat):
|
||||
if victim.partial_move > 0.5:
|
||||
victim.gassed += 1
|
||||
@@ -43,14 +43,14 @@ class Gas(Unit):
|
||||
)
|
||||
|
||||
for victim_id in victim_ids_before:
|
||||
victim = self.game.get_unit_by_id(victim_id)
|
||||
victim = self.game.unit_manager.get_unit_by_id(victim_id)
|
||||
if victim and isinstance(victim, Rat):
|
||||
if victim.partial_move < 0.5:
|
||||
victim.gassed += 1
|
||||
|
||||
if self.age % self.speed:
|
||||
return
|
||||
parent = self.game.get_unit_by_id(self.parent_id)
|
||||
parent = self.game.unit_manager.get_unit_by_id(self.parent_id)
|
||||
if (parent) or self.parent_id is None:
|
||||
print(f"Gas at {self.position} is spreading")
|
||||
# Spread gas to adjacent cells
|
||||
@@ -61,7 +61,7 @@ class Gas(Unit):
|
||||
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)):
|
||||
print(f"Spreading gas from {self.position} to ({new_x}, {new_y})")
|
||||
self.game.spawn_unit(Gas, (new_x, new_y), parent_id=self.parent_id if self.parent_id else self.id)
|
||||
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):
|
||||
pass
|
||||
|
||||
@@ -72,7 +72,7 @@ class Gas(Unit):
|
||||
|
||||
|
||||
def draw(self):
|
||||
image = self.game.assets["BMP_GAS"]
|
||||
image = self.game.graphics.assets["BMP_GAS"]
|
||||
image_size = self.game.render_engine.get_image_size(image)
|
||||
self.rat_image = image
|
||||
partial_x, partial_y = 0, 0
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ class Mine(Unit):
|
||||
)
|
||||
|
||||
for victim_id in victim_ids:
|
||||
rat_unit = self.game.get_unit_by_id(victim_id)
|
||||
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
|
||||
# Mine explodes and kills the rat
|
||||
self.explode(rat_unit)
|
||||
@@ -49,7 +49,7 @@ class Mine(Unit):
|
||||
return
|
||||
|
||||
# Use mine asset
|
||||
image = self.game.assets["BMP_POISON"]
|
||||
image = self.game.graphics.assets["BMP_POISON"]
|
||||
image_size = self.game.render_engine.get_image_size(image)
|
||||
|
||||
# Center the mine in the cell
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ class Point(Unit):
|
||||
|
||||
|
||||
def draw(self):
|
||||
image = self.game.assets[f"BMP_BONUS_{self.value}"]
|
||||
image = self.game.graphics.assets[f"BMP_BONUS_{self.value}"]
|
||||
image_size = self.game.render_engine.get_image_size(image)
|
||||
self.rat_image = image
|
||||
partial_x, partial_y = 0, 0
|
||||
|
||||
+10
-10
@@ -93,7 +93,7 @@ class Rat(Unit):
|
||||
sex = self.sex if self.age > AGE_THRESHOLD else "BABY"
|
||||
|
||||
# Get cached image size instead of calling get_image_size()
|
||||
image_size = self.game.rat_image_sizes[sex][self.direction]
|
||||
image_size = self.game.graphics.rat_image_sizes[sex][self.direction]
|
||||
|
||||
# Calculate partial movement offset
|
||||
if self.direction in ["UP", "DOWN"]:
|
||||
@@ -130,7 +130,7 @@ class Rat(Unit):
|
||||
|
||||
# Process each collision
|
||||
for _, other_id in collisions:
|
||||
other_unit = self.game.get_unit_by_id(other_id)
|
||||
other_unit = self.game.unit_manager.get_unit_by_id(other_id)
|
||||
|
||||
# Skip if not another Rat
|
||||
if not isinstance(other_unit, Rat):
|
||||
@@ -164,17 +164,17 @@ class Rat(Unit):
|
||||
|
||||
# Rat-specific behavior: spawn points
|
||||
if score not in [None, 0]:
|
||||
self.game.add_point(score)
|
||||
self.game.spawn_unit(Point, death_position, value=score)
|
||||
self.game.scoring.add_point(score)
|
||||
self.game.unit_manager.spawn_unit(Point, death_position, value=score)
|
||||
|
||||
# Add blood stain directly to background
|
||||
self.game.add_blood_stain(death_position)
|
||||
self.game.graphics.add_blood_stain(death_position)
|
||||
|
||||
def draw(self):
|
||||
"""Optimized draw using pre-calculated positions from move()"""
|
||||
sex = self.sex if self.age > AGE_THRESHOLD else "BABY"
|
||||
image = self.game.rat_assets_textures[sex][self.direction]
|
||||
image_size = self.game.rat_image_sizes[sex][self.direction]
|
||||
image = self.game.graphics.rat_assets_textures[sex][self.direction]
|
||||
image_size = self.game.graphics.rat_image_sizes[sex][self.direction]
|
||||
|
||||
# Calculate render position if not yet set (first frame)
|
||||
if not hasattr(self, 'render_x'):
|
||||
@@ -275,7 +275,7 @@ class Rat(Unit):
|
||||
"""Calculate render position and bbox (used when render_x not yet set)"""
|
||||
sex = self.sex if self.age > AGE_THRESHOLD else "BABY"
|
||||
image_size = self.game.render_engine.get_image_size(
|
||||
self.game.rat_assets_textures[sex][self.direction]
|
||||
self.game.graphics.rat_assets_textures[sex][self.direction]
|
||||
)
|
||||
|
||||
partial_x, partial_y = 0, 0
|
||||
@@ -314,7 +314,7 @@ class Female(Rat):
|
||||
self.babies -= 1
|
||||
self.stop = 20
|
||||
if self.partial_move > 0.2:
|
||||
self.game.spawn_rat(self.position)
|
||||
self.game.unit_manager.spawn_rat(self.position)
|
||||
else:
|
||||
self.game.spawn_rat(self.position_before)
|
||||
self.game.unit_manager.spawn_rat(self.position_before)
|
||||
self.game.render_engine.play_sound("BIRTH.WAV")
|
||||
Reference in New Issue
Block a user