This commit is contained in:
Auric Vente 2024-07-22 08:09:49 -06:00
parent 9ceff213fb
commit 6fb7d02bd5
5 changed files with 84 additions and 12 deletions

View File

@ -54,7 +54,7 @@ class Config:
filter_width: int = 150
filter_debouncer_delay: int = 200
default_population: int = 100
merge_goal: int = 8
merge_goal: int = 10
manifest_path: Path
manifest: dict[str, str]

View File

@ -30,6 +30,7 @@ class Method:
sentence_1 = 6
sentence_2 = 7
sentence_3 = 8
sentence_4 = 9
class Game:
@ -196,19 +197,51 @@ class Game:
if not ant:
return
min_num = 0
max_num = 12
mode = Settings.mode
opts: list[int]
if mode == "all":
opts = [
Method.triumph,
Method.hit,
Method.travel,
Method.thinking_1,
Method.thinking_2,
Method.sentence_1,
Method.sentence_2,
Method.sentence_3,
Method.sentence_4,
Method.sentence_4 + 1,
Method.sentence_4 + 2,
Method.sentence_4 + 3,
]
elif mode == "score":
opts = [Method.triumph, Method.hit]
elif mode == "travel":
opts = [Method.travel]
elif mode == "thought":
opts = [Method.thinking_1, Method.thinking_2]
elif mode == "words":
opts = [
Method.sentence_1,
Method.sentence_2,
Method.sentence_3,
Method.sentence_4,
]
num = random.randint(min_num, max_num)
Game.merge_charge += 1
if num == Method.merge:
if Game.merge_charge >= Config.merge_goal:
if Ants.merge():
Game.merge_charge = 0
return
if Game.merge_charge >= Config.merge_goal:
opts.insert(0, Method.merge)
num = min_num
num = random.choice(opts)
if num == Method.merge:
if Ants.merge():
Game.merge_charge = 0
return
num = Method.sentence_4
status = ""
method = "normal"
@ -242,9 +275,12 @@ class Game:
elif num == Method.sentence_3:
status = Utils.rand_sentence.bare_bone_with_adjective()
else:
elif num >= Method.sentence_4:
status = Utils.rand_sentence.sentence()
else:
status = "???"
Ants.set_status(ant, status, method)
@staticmethod
@ -287,6 +323,16 @@ class Game:
Settings.set_speed(speed)
Game.start_loop()
@staticmethod
def update_mode() -> None:
mode = Window.mode.currentText().lower()
if mode == Settings.mode:
return
Settings.set_mode(mode)
Game.start_loop()
@staticmethod
def info() -> None:
text = []

View File

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

View File

@ -6,18 +6,25 @@ from .storage import Storage
class Settings:
speed: str
mode: str
@staticmethod
def prepare() -> None:
settings = Storage.get_settings()
Settings.speed = settings.get("speed", "normal")
speed = Settings.speed.capitalize()
Window.speed.setCurrentText(speed)
Settings.mode = settings.get("mode", "all")
mode = Settings.mode.capitalize()
Window.mode.setCurrentText(mode)
@staticmethod
def save() -> None:
settings = {
"speed": Settings.speed,
"mode": Settings.mode,
}
Storage.save_settings(settings)
@ -26,3 +33,8 @@ class Settings:
def set_speed(speed: str) -> None:
Settings.speed = speed
Settings.save()
@staticmethod
def set_mode(mode: str) -> None:
Settings.mode = mode
Settings.save()

View File

@ -87,6 +87,7 @@ class Window:
player: QMediaPlayer
audio: QAudioOutput
filter: QLineEdit
mode: QComboBox
@staticmethod
def prepare() -> None:
@ -236,6 +237,18 @@ class Window:
Window.speed.setCurrentIndex(1)
Window.speed.currentIndexChanged.connect(Game.update_speed)
Window.mode = QComboBox()
tooltip = "Game mode\n"
tooltip += "All: All kind of updates\n"
tooltip += "Score: Only triumph and hit updates\n"
tooltip += "Travel: Only travel updates\n"
tooltip += "Thought: Only thought updates\n"
tooltip += "Words: Only sentences"
Window.mode.setToolTip(tooltip)
Window.mode.addItems(["All", "Score", "Travel", "Thought", "Words"])
Window.mode.setCurrentIndex(1)
Window.mode.currentIndexChanged.connect(Game.update_mode)
Window.filter = FilterLineEdit()
Window.filter.setFixedWidth(Config.filter_width)
Window.filter.setPlaceholderText("Filter")
@ -244,6 +257,7 @@ class Window:
container.addWidget(btn_restart)
container.addWidget(Window.speed)
container.addWidget(Window.mode)
container.addWidget(Window.filter)
root.setLayout(container)