From 0738b346520be5680a26625711366bd4a87d073c Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Sun, 21 Jul 2024 21:51:29 -0600 Subject: [PATCH] Mods --- cromulant/ants.py | 15 +++++++-------- cromulant/game.py | 9 +++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) 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()