diff --git a/cromulant/ants.py b/cromulant/ants.py index 8638b5a..5ae5e89 100644 --- a/cromulant/ants.py +++ b/cromulant/ants.py @@ -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() diff --git a/cromulant/game.py b/cromulant/game.py index 05ed246..1f2805e 100644 --- a/cromulant/game.py +++ b/cromulant/game.py @@ -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()