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 = ""
names = Ants.get_names()
combinations = list(itertools.product(words_1, words_2))
random.shuffle(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):
name = ""
if (possible == ant_1.name) or (possible == ant_2.name):
continue
if (name in names) or (name in Utils.names):
name = ""
if (possible in names) or (possible in Utils.names):
continue
name = possible
break
if not name:
return False
@ -285,9 +287,6 @@ class Ants:
@staticmethod
def terminate(ant: Ant) -> None:
if ant.method == "terminated":
return
Ants.hatch(on_change=False)
Ants.set_terminated(ant)
Ants.on_change()

View File

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