From c2e2303f05ac3a8a25157fd9dd7837fd3abe415c Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Sat, 20 Jul 2024 10:35:28 -0600 Subject: [PATCH] Mods --- cromulant/config.py | 4 +- cromulant/data/countries.json | 250 ++++++++++++++++++++++++++++++++++ cromulant/game.py | 7 +- cromulant/storage.py | 5 + cromulant/utils.py | 7 + 5 files changed, 271 insertions(+), 2 deletions(-) create mode 100644 cromulant/data/countries.json diff --git a/cromulant/config.py b/cromulant/config.py index e92bb3e..2c5a14a 100644 --- a/cromulant/config.py +++ b/cromulant/config.py @@ -52,6 +52,7 @@ class Config: input_border_color: str = "rgb(120, 120, 120)" input_caret_color: str = "rgb(18, 18, 18)" settings_json: Path + countries_json: Path @staticmethod def prepare() -> None: @@ -70,11 +71,12 @@ class Config: Config.settings_json.parent.mkdir(parents=True, exist_ok=True) Config.settings_json.write_text("{}") + Config.names_json = Config.here / "data" / "names.json" + Config.countries_json = Config.here / "data" / "countries.json" Config.icon_path = Config.here / "img" / "icon_1.jpg" Config.status_image_path = Config.here / "img" / "icon_2.jpg" Config.terminated_image_path = Config.here / "img" / "icon_3.jpg" Config.hatched_image_path = Config.here / "img" / "icon_4.jpg" - Config.names_json = Config.here / "data" / "names.json" Config.font_path = Config.here / "fonts" / "NotoSans-Regular.ttf" Config.emoji_font_path = Config.here / "fonts" / "NotoEmoji-Regular.ttf" Config.song_path = Config.here / "audio" / "March of the Cyber Ants.mp3" diff --git a/cromulant/data/countries.json b/cromulant/data/countries.json new file mode 100644 index 0000000..b42b5dc --- /dev/null +++ b/cromulant/data/countries.json @@ -0,0 +1,250 @@ +[ + "Afghanistan", + "Albania", + "Algeria", + "American Samoa", + "Andorra", + "Angola", + "Anguilla", + "Antarctica", + "Antigua and Barbuda", + "Argentina", + "Armenia", + "Aruba", + "Australia", + "Austria", + "Azerbaijan", + "Bahamas", + "Bahrain", + "Bangladesh", + "Barbados", + "Belarus", + "Belgium", + "Belize", + "Benin", + "Bermuda", + "Bhutan", + "Bolivia", + "Bosnia and Herzegovina", + "Botswana", + "Bouvet Island", + "Brazil", + "British Indian Ocean Territory", + "Brunei", + "Bulgaria", + "Burkina Faso", + "Burundi", + "Cambodia", + "Cameroon", + "Canada", + "Cape Verde", + "Cayman Islands", + "Central African Republic", + "Chad", + "Chile", + "China", + "Christmas Island", + "Cocos (Keeling) Islands", + "Colombia", + "Comoros", + "Congo", + "The Democratic Republic of Congo", + "Cook Islands", + "Costa Rica", + "Ivory Coast", + "Croatia", + "Cuba", + "Cyprus", + "Czech Republic", + "Denmark", + "Djibouti", + "Dominica", + "Dominican Republic", + "East Timor", + "Ecuador", + "Egypt", + "England", + "El Salvador", + "Equatorial Guinea", + "Eritrea", + "Estonia", + "Eswatini", + "Ethiopia", + "Falkland Islands", + "Faroe Islands", + "Fiji Islands", + "Finland", + "France", + "French Guiana", + "French Polynesia", + "French Southern territories", + "Gabon", + "Gambia", + "Georgia", + "Germany", + "Ghana", + "Gibraltar", + "Greece", + "Greenland", + "Grenada", + "Guadeloupe", + "Guam", + "Guatemala", + "Guernsey", + "Guinea", + "Guinea-Bissau", + "Guyana", + "Haiti", + "Heard Island and McDonald Islands", + "Holy See (Vatican City State)", + "Honduras", + "Hong Kong", + "Hungary", + "Iceland", + "India", + "Indonesia", + "Iran", + "Iraq", + "Ireland", + "Israel", + "Isle of Man", + "Italy", + "Jamaica", + "Japan", + "Jersey", + "Jordan", + "Kazakhstan", + "Kenya", + "Kiribati", + "Kuwait", + "Kyrgyzstan", + "Laos", + "Latvia", + "Lebanon", + "Lesotho", + "Liberia", + "Libya", + "Liechtenstein", + "Lithuania", + "Luxembourg", + "Macao", + "North Macedonia", + "Madagascar", + "Malawi", + "Malaysia", + "Maldives", + "Mali", + "Malta", + "Marshall Islands", + "Martinique", + "Mauritania", + "Mauritius", + "Mayotte", + "Mexico", + "Micronesia, Federated States of", + "Moldova", + "Monaco", + "Mongolia", + "Montserrat", + "Montenegro", + "Morocco", + "Mozambique", + "Myanmar", + "Namibia", + "Nauru", + "Nepal", + "Netherlands", + "Netherlands Antilles", + "New Caledonia", + "New Zealand", + "Nicaragua", + "Niger", + "Nigeria", + "Niue", + "Norfolk Island", + "North Korea", + "Northern Ireland", + "Northern Mariana Islands", + "Norway", + "Oman", + "Pakistan", + "Palau", + "Palestine", + "Panama", + "Papua New Guinea", + "Paraguay", + "Peru", + "Philippines", + "Pitcairn", + "Poland", + "Portugal", + "Puerto Rico", + "Qatar", + "Reunion", + "Romania", + "Russia", + "Rwanda", + "Saint Helena", + "Saint Kitts and Nevis", + "Saint Lucia", + "Saint Pierre and Miquelon", + "Saint Vincent and the Grenadines", + "Samoa", + "San Marino", + "Sao Tome and Principe", + "Saudi Arabia", + "Scotland", + "Senegal", + "Serbia", + "Seychelles", + "Sierra Leone", + "Singapore", + "Slovakia", + "Slovenia", + "Solomon Islands", + "Somalia", + "South Africa", + "South Georgia and the South Sandwich Islands", + "South Korea", + "South Sudan", + "Spain", + "Sri Lanka", + "Sudan", + "Suriname", + "Svalbard and Jan Mayen", + "Sweden", + "Switzerland", + "Syria", + "Tajikistan", + "Tanzania", + "Thailand", + "Timor-Leste", + "Togo", + "Tokelau", + "Tonga", + "Trinidad and Tobago", + "Tunisia", + "Turkey", + "Turkmenistan", + "Turks and Caicos Islands", + "Tuvalu", + "Uganda", + "Ukraine", + "United Arab Emirates", + "United Kingdom", + "United States", + "United States Minor Outlying Islands", + "Uruguay", + "Uzbekistan", + "Vanuatu", + "Venezuela", + "Vietnam", + "Virgin Islands, British", + "Virgin Islands, U.S.", + "Wales", + "Wallis and Futuna", + "Western Sahara", + "Yemen", + "Zambia", + "Zimbabwe" +] \ No newline at end of file diff --git a/cromulant/game.py b/cromulant/game.py index fa29d1a..9ccbef3 100644 --- a/cromulant/game.py +++ b/cromulant/game.py @@ -46,6 +46,8 @@ class Game: color = Config.hit_color elif ant.method == "thinking": status = f"Thinking about {status}" + elif ant.method == "travel": + status = f"Traveling to {status}" tooltip = "" tooltip += f"Updated: {Utils.to_date(ant.updated)}" @@ -178,7 +180,7 @@ class Game: ant.hits += 1 method = "hit" elif num == 3: - status = Utils.random_name([ant.name]) + status = Utils.random_name([]) method = "thinking" elif num == 4: status = s.simple_sentence() @@ -189,6 +191,9 @@ class Game: elif num == 7: status = Utils.random_emoji(3) method = "thinking" + elif num == 8: + status = Utils.random_country([]) + method = "travel" else: status = s.sentence() diff --git a/cromulant/storage.py b/cromulant/storage.py index 16debeb..9596cec 100644 --- a/cromulant/storage.py +++ b/cromulant/storage.py @@ -36,3 +36,8 @@ class Storage: def save_settings(settings: dict[str, Any]) -> None: with Config.settings_json.open("w") as file: json.dump(settings, file) + + @staticmethod + def get_countries() -> Any: + with Config.countries_json.open() as file: + return json.load(file) diff --git a/cromulant/utils.py b/cromulant/utils.py index 6e1db18..287bae0 100644 --- a/cromulant/utils.py +++ b/cromulant/utils.py @@ -14,10 +14,12 @@ from .storage import Storage class Utils: names: ClassVar[list[str]] = [] + countries: ClassVar[list[str]] = [] @staticmethod def prepare() -> None: Utils.names = Storage.get_names() + Utils.countries = Storage.get_countries() @staticmethod def now() -> float: @@ -132,3 +134,8 @@ class Utils: return "1 minute" return f"{minutes} minutes" + + @staticmethod + def random_country(ignore: list[str]) -> str: + filtered = [country for country in Utils.countries if country not in ignore] + return random.choice(filtered)