Aggiungi la funzione count_rats per contare i ratti e aggiorna la logica di gioco; modifica la risoluzione nel file .env e gestisci eccezioni nel metodo pop di Timer
This commit is contained in:
@@ -32,6 +32,13 @@ class MiceMaze(controls.KeyBindings):
|
||||
for _ in range(5):
|
||||
self.new_rat()
|
||||
|
||||
def count_rats(self):
|
||||
count = 0
|
||||
for unit in self.units.values():
|
||||
if isinstance(unit, rat.Rat):
|
||||
count += 1
|
||||
return count
|
||||
|
||||
def new_rat(self, position=None):
|
||||
if position is None:
|
||||
position = self.choose_start()
|
||||
@@ -69,7 +76,7 @@ class MiceMaze(controls.KeyBindings):
|
||||
|
||||
|
||||
return True
|
||||
if len(self.units) >= 150:
|
||||
if self.count_rats() > 200:
|
||||
self.stop_sound()
|
||||
self.play_sound("WEWIN.WAV")
|
||||
self.game_end = (True, False)
|
||||
@@ -107,7 +114,7 @@ class MiceMaze(controls.KeyBindings):
|
||||
unit.move()
|
||||
unit.collisions()
|
||||
unit.draw()
|
||||
self.engine.update_status(f"Mice: {len(self.units)} - Points: {self.points}")
|
||||
self.engine.update_status(f"Mice: {self.count_rats()} - Points: {self.points}")
|
||||
self.scroll()
|
||||
self.engine.new_cycle(50, self.update_maze)
|
||||
|
||||
|
||||
@@ -7,3 +7,5 @@
|
||||
2024-12-23 01:32:09.317053 - 25
|
||||
2024-12-23 01:34:24.777185 - 25
|
||||
2024-12-23 01:37:35.727860 - 25
|
||||
2024-12-23 17:12:37.473315 - 80
|
||||
2024-12-23 17:15:08.337754 - 50
|
||||
|
||||
+4
-1
@@ -59,7 +59,10 @@ class Timer(Bomb):
|
||||
if not unit:
|
||||
unit = self
|
||||
self.game.play_sound("BOMB.WAV")
|
||||
self.game.units.pop(unit.id)
|
||||
try:
|
||||
self.game.units.pop(unit.id)
|
||||
except:
|
||||
print(f"Unit {unit.id} already dead")
|
||||
self.game.spawn_unit(Explosion, unit.position)
|
||||
for direction in ["N", "S", "E", "W"]:
|
||||
x, y = unit.position
|
||||
|
||||
Reference in New Issue
Block a user