This commit is contained in:
Auric Vente 2024-07-21 21:51:29 -06:00
parent 5b26219652
commit 0738b34652
2 changed files with 16 additions and 8 deletions

View File

@ -247,18 +247,20 @@ class Ants:
name = "" name = ""
names = Ants.get_names() names = Ants.get_names()
combinations = list(itertools.product(words_1, words_2)) combinations = list(itertools.product(words_1, words_2))
random.shuffle(combinations)
for combo in combinations: for combo in combinations:
name = f"{combo[0]} {combo[1]}" possible = f"{combo[0]} {combo[1]}"
if (name == ant_1.name) or (name == ant_2.name): if (possible == ant_1.name) or (possible == ant_2.name):
name = ""
continue continue
if (name in names) or (name in Utils.names): if (possible in names) or (possible in Utils.names):
name = ""
continue continue
name = possible
break
if not name: if not name:
return False return False
@ -285,9 +287,6 @@ class Ants:
@staticmethod @staticmethod
def terminate(ant: Ant) -> None: def terminate(ant: Ant) -> None:
if ant.method == "terminated":
return
Ants.hatch(on_change=False) Ants.hatch(on_change=False)
Ants.set_terminated(ant) Ants.set_terminated(ant)
Ants.on_change() Ants.on_change()

View File

@ -318,9 +318,18 @@ class Game:
@staticmethod @staticmethod
def image_action(event: QMouseEvent, ant: Ant) -> None: def image_action(event: QMouseEvent, ant: Ant) -> None:
def is_terminated() -> bool:
return ant.method == "terminated"
if event.button() == Qt.LeftButton: if event.button() == Qt.LeftButton:
if is_terminated():
return
Ants.terminate(ant) Ants.terminate(ant)
elif event.button() == Qt.MiddleButton: elif event.button() == Qt.MiddleButton:
if is_terminated():
return
Ants.merge(ant) Ants.merge(ant)
else: else:
Game.toggle_song() Game.toggle_song()