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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user