This commit is contained in:
Auric Vente 2024-07-19 22:21:58 -06:00
parent 59b5c74846
commit 4ef0990516
3 changed files with 9 additions and 9 deletions

View File

@ -74,7 +74,7 @@ class Ants:
ant = Ant() ant = Ant()
ant.created = now ant.created = now
ant.updated = now ant.updated = now
ant.name = Utils.random_name() ant.name = Ants.random_name()
Ants.ants.append(ant) Ants.ants.append(ant)
image_path = Config.hatched_image_path image_path = Config.hatched_image_path
@ -180,3 +180,7 @@ class Ants:
return None return None
return max(Ants.ants, key=lambda a: a.triumph) return max(Ants.ants, key=lambda a: a.triumph)
@staticmethod
def random_name() -> str:
return Utils.random_name(Ants.get_names())

View File

@ -162,9 +162,8 @@ class Game:
elif num == 2: elif num == 2:
ant.hits += 1 ant.hits += 1
method = "hit" method = "hit"
elif (num == 3) and (num_ants > 1): elif num == 3:
other = Ants.get_other(ant) status = Utils.random_name([ant.name])
status = other.name
method = "thinking" method = "thinking"
elif num == 4: elif num == 4:
status = s.simple_sentence() status = s.simple_sentence()

View File

@ -86,11 +86,8 @@ class Utils:
return r, g, b return r, g, b
@staticmethod @staticmethod
def random_name() -> str: def random_name(ignore: list[str]) -> str:
from .ants import Ants filtered = [name for name in Utils.names if name not in ignore]
used = Ants.get_names()
filtered = [name for name in Utils.names if name not in used]
return random.choice(filtered) return random.choice(filtered)
@staticmethod @staticmethod