Mods
This commit is contained in:
parent
9fcc9d31f8
commit
2b9eb8a4fd
|
@ -270,11 +270,13 @@ class Game:
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
Game.merge_charge += 1
|
if Game.merge_charge < Config.merge_goal:
|
||||||
|
Game.merge_charge += 1
|
||||||
|
|
||||||
if Game.merge_charge >= Config.merge_goal:
|
if Settings.merge:
|
||||||
nums.insert(0, Method.merge)
|
if Game.merge_charge >= Config.merge_goal:
|
||||||
weights.insert(0, 1)
|
nums.insert(0, Method.merge)
|
||||||
|
weights.insert(0, 1)
|
||||||
|
|
||||||
num = random.choices(nums, weights=weights, k=1)[0]
|
num = random.choices(nums, weights=weights, k=1)[0]
|
||||||
|
|
||||||
|
@ -467,10 +469,19 @@ class Game:
|
||||||
menu = QMenu(Window.root.widget())
|
menu = QMenu(Window.root.widget())
|
||||||
update = QAction("Update")
|
update = QAction("Update")
|
||||||
restart = QAction("Restart")
|
restart = QAction("Restart")
|
||||||
|
|
||||||
|
if Settings.merge:
|
||||||
|
merge = QAction("Merge: On")
|
||||||
|
else:
|
||||||
|
merge = QAction("Merge: Off")
|
||||||
|
|
||||||
update.triggered.connect(Game.force_update)
|
update.triggered.connect(Game.force_update)
|
||||||
restart.triggered.connect(Game.restart)
|
restart.triggered.connect(Game.restart)
|
||||||
|
merge.triggered.connect(Settings.toggle_merge)
|
||||||
|
|
||||||
menu.addAction(update)
|
menu.addAction(update)
|
||||||
menu.addAction(restart)
|
menu.addAction(restart)
|
||||||
|
menu.addAction(merge)
|
||||||
menu.exec_(QCursor.pos())
|
menu.exec_(QCursor.pos())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "1.2.0",
|
"version": "1.4.0",
|
||||||
"title": "Cromulant",
|
"title": "Cromulant",
|
||||||
"program": "cromulant",
|
"program": "cromulant",
|
||||||
"author": "madprops",
|
"author": "madprops",
|
||||||
|
|
|
@ -7,6 +7,7 @@ from .storage import Storage
|
||||||
class Settings:
|
class Settings:
|
||||||
speed: str
|
speed: str
|
||||||
mode: str
|
mode: str
|
||||||
|
merge: bool
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def prepare() -> None:
|
def prepare() -> None:
|
||||||
|
@ -20,11 +21,14 @@ class Settings:
|
||||||
mode = Settings.mode.capitalize()
|
mode = Settings.mode.capitalize()
|
||||||
Window.mode.setCurrentText(mode)
|
Window.mode.setCurrentText(mode)
|
||||||
|
|
||||||
|
Settings.merge = settings.get("merge", True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def save() -> None:
|
def save() -> None:
|
||||||
settings = {
|
settings = {
|
||||||
"speed": Settings.speed,
|
"speed": Settings.speed,
|
||||||
"mode": Settings.mode,
|
"mode": Settings.mode,
|
||||||
|
"merge": Settings.merge,
|
||||||
}
|
}
|
||||||
|
|
||||||
Storage.save_settings(settings)
|
Storage.save_settings(settings)
|
||||||
|
@ -38,3 +42,8 @@ class Settings:
|
||||||
def set_mode(mode: str) -> None:
|
def set_mode(mode: str) -> None:
|
||||||
Settings.mode = mode
|
Settings.mode = mode
|
||||||
Settings.save()
|
Settings.save()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def toggle_merge() -> None:
|
||||||
|
Settings.merge = not Settings.merge
|
||||||
|
Settings.save()
|
||||||
|
|
|
@ -224,7 +224,7 @@ class Window:
|
||||||
container = QHBoxLayout()
|
container = QHBoxLayout()
|
||||||
|
|
||||||
btn_menu = QPushButton("Menu")
|
btn_menu = QPushButton("Menu")
|
||||||
btn_menu.setToolTip("Restart with a new set of ants")
|
btn_menu.setToolTip("The main menu")
|
||||||
btn_menu.clicked.connect(Game.menu)
|
btn_menu.clicked.connect(Game.menu)
|
||||||
|
|
||||||
Window.speed = QComboBox()
|
Window.speed = QComboBox()
|
||||||
|
|
Loading…
Reference in New Issue