This commit is contained in:
Auric Vente
2024-07-19 20:17:07 -06:00
parent 959efe2d8e
commit ade8f9486c
3 changed files with 50 additions and 2 deletions

View File

@@ -65,6 +65,7 @@ class Ants:
from .game import Game
if len(Ants.ants) >= Config.max_ants:
Window.alert("Max ants reached\nTerminate some to hatch new ones")
return
now = Utils.now()
@@ -152,12 +153,20 @@ class Ants:
@staticmethod
def get_ants() -> None:
objs = Storage.get_ants()
changed = False
if len(objs) > Config.max_ants:
objs = objs[: Config.max_ants]
changed = True
for obj in objs:
ant = Ant()
ant.from_dict(obj)
Ants.ants.append(ant)
if changed:
Ants.save()
@staticmethod
def most_hits() -> Ant | None:
if not len(Ants.ants):