From 9a2c1bdcc5c97167a59fd3cbe641411e7ebd8319 Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Sun, 21 Jul 2024 10:47:34 -0600 Subject: [PATCH] Mods --- cromulant/ants.py | 6 ++++++ cromulant/config.py | 1 + cromulant/game.py | 9 ++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cromulant/ants.py b/cromulant/ants.py index aac185b..f7bde8d 100644 --- a/cromulant/ants.py +++ b/cromulant/ants.py @@ -90,6 +90,12 @@ class Ants: @staticmethod def prepare() -> None: Ants.get() + Ants.check() + + @staticmethod + def check() -> None: + if not Ants.ants: + Ants.populate(Config.default_population) @staticmethod def hatch(num: int = 1, on_change: bool = True) -> None: diff --git a/cromulant/config.py b/cromulant/config.py index 7123d94..1be0447 100644 --- a/cromulant/config.py +++ b/cromulant/config.py @@ -53,6 +53,7 @@ class Config: countries_json: Path filter_width: int = 150 filter_debouncer_delay: int = 200 + default_population: int = 100 @staticmethod def prepare() -> None: diff --git a/cromulant/game.py b/cromulant/game.py index 4a0e118..36016cf 100644 --- a/cromulant/game.py +++ b/cromulant/game.py @@ -287,8 +287,15 @@ class Game: @staticmethod def restart() -> None: opts = ["25", "50", "100", "250"] + defindex = 0 + + for i, opt in enumerate(opts): + if int(opt) == Config.default_population: + defindex = i + break + opts = [f"{opt} ants" for opt in opts] - size = Window.prompt_combobox("Size of the population", opts, 2) + size = Window.prompt_combobox("Size of the population", opts, defindex) if not size: return