This commit is contained in:
Auric Vente 2024-07-21 21:44:12 -06:00
parent 0ea97aa03d
commit 5b26219652
3 changed files with 13 additions and 7 deletions

View File

@ -211,7 +211,7 @@ class Ants:
return top, top_score return top, top_score
@staticmethod @staticmethod
def merge(ant_1: Ant | None = None) -> None: def merge(ant_1: Ant | None = None) -> bool:
from .game import Game from .game import Game
def split(ant: Ant) -> list[str]: def split(ant: Ant) -> list[str]:
@ -232,12 +232,12 @@ class Ants:
ant_1 = Ants.random_ant() ant_1 = Ants.random_ant()
if not ant_1: if not ant_1:
return return False
ant_2 = Ants.random_ant([ant_1]) ant_2 = Ants.random_ant([ant_1])
if not ant_2: if not ant_2:
return return False
words_1 = split(ant_1) words_1 = split(ant_1)
words_2 = split(ant_2) words_2 = split(ant_2)
@ -252,13 +252,15 @@ class Ants:
name = f"{combo[0]} {combo[1]}" name = f"{combo[0]} {combo[1]}"
if (name == ant_1.name) or (name == ant_2.name): if (name == ant_1.name) or (name == ant_2.name):
name = ""
continue continue
if (name in names) or (name in Utils.names): if (name in names) or (name in Utils.names):
name = ""
continue continue
if not name: if not name:
return return False
Ants.set_terminated(ant_1) Ants.set_terminated(ant_1)
Ants.set_terminated(ant_2) Ants.set_terminated(ant_2)
@ -275,6 +277,7 @@ class Ants:
Ants.ants.append(ant) Ants.ants.append(ant)
Game.add_update(ant) Game.add_update(ant)
Ants.hatch() Ants.hatch()
return True
@staticmethod @staticmethod
def clear() -> None: def clear() -> None:

View File

@ -180,8 +180,11 @@ class Game:
Game.last_update = num Game.last_update = num
if num == Method.merge: if num == Method.merge:
Ants.merge() if Ants.merge():
return return
# If merge failed
num = max_num
status = "" status = ""
method = "normal" method = "normal"

View File

@ -1,5 +1,5 @@
{ {
"version": "1.0.0", "version": "1.1.0",
"title": "Cromulant", "title": "Cromulant",
"program": "cromulant", "program": "cromulant",
"author": "madprops", "author": "madprops",