This commit is contained in:
Auric Vente 2024-07-27 05:25:31 -06:00
parent 91ab4d23f1
commit ea2d14256c
1 changed files with 4 additions and 9 deletions

View File

@ -114,9 +114,7 @@ class Ants:
Ants.populate(Config.default_population) Ants.populate(Config.default_population)
@staticmethod @staticmethod
def hatch( def hatch(num: int = 1, ignore: list[str] | None = None) -> None:
num: int = 1, on_change: bool = True, ignore: list[str] | None = None
) -> None:
from .game import Game from .game import Game
for _ in range(num): for _ in range(num):
@ -125,13 +123,13 @@ class Ants:
Ants.ants.append(ant) Ants.ants.append(ant)
Game.update(ant) Game.update(ant)
if on_change: Ants.on_change()
Ants.on_change()
@staticmethod @staticmethod
def on_change() -> None: def on_change() -> None:
from .game import Game from .game import Game
Ants.get_top()
Game.info() Game.info()
Ants.save() Ants.save()
@ -183,7 +181,6 @@ class Ants:
ant.method = method ant.method = method
ant.updated = Utils.now() ant.updated = Utils.now()
Ants.get_top()
Game.update(ant) Game.update(ant)
Ants.on_change() Ants.on_change()
@ -306,9 +303,7 @@ class Ants:
Ants.ants.append(ant) Ants.ants.append(ant)
Game.update(ant) Game.update(ant)
Ants.hatch(on_change=False, ignore=[ant_1.name, ant_2.name]) Ants.hatch(ignore=[ant_1.name, ant_2.name])
Ants.get_top()
Ants.on_change()
return True return True
@staticmethod @staticmethod