updates and cleanup.

This commit is contained in:
2026-09-24 18:49:34 +01:00
parent 1e27d7629f
commit 8823fa808a
9 changed files with 115 additions and 71 deletions
+4
View File
@@ -18,4 +18,8 @@ document.addEventListener("DOMContentLoaded", () => {
*/
window.game = new GameController();
window.game.init();
document.getElementById("reset-button").addEventListener("click", () => {
window.game.reset();
});
});
+1
View File
@@ -147,6 +147,7 @@ export default class GameController {
* @param {number} tries - Number of times the game has been reset
*/
async reset(tries = 0) {
this.bus.emit("clear_save");
this._clearGameState();
this._generateNewSeed();
await this.start(tries);
+10
View File
@@ -39,6 +39,8 @@ export default class Saver {
this.bus.on("load_save", this.load.bind(this));
/** @listens EventBus#delete_save */
this.bus.on("delete_save", this.deleteSave.bind(this));
/** @listens EventBus#clear_save */
this.bus.on("clear_save", this.clearSave.bind(this));
/** @listens EventBus#start_autosaver */
this.bus.on("start_autosaver", this.startAutosaver.bind(this));
/** @listens EventBus#stop_autosaver */
@@ -154,6 +156,14 @@ export default class Saver {
this.delete_save = true;
this.stopAutosaver();
}
/**
* @function clearSave
* @description clears the save
*/
clearSave() {
localStorage.removeItem("save");
this.delete_save = false;
}
/**
* @function loadFromFile
* @description Loads the game data from a file