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.created = now
ant.updated = now
ant.name = Utils.random_name()
ant.name = Ants.random_name()
Ants.ants.append(ant)
image_path = Config.hatched_image_path
@ -180,3 +180,7 @@ class Ants:
return None
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:
ant.hits += 1
method = "hit"
elif (num == 3) and (num_ants > 1):
other = Ants.get_other(ant)
status = other.name
elif num == 3:
status = Utils.random_name([ant.name])
method = "thinking"
elif num == 4:
status = s.simple_sentence()

View File

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