updates and cleanup.
This commit is contained in:
@@ -18,4 +18,8 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
*/
|
||||
window.game = new GameController();
|
||||
window.game.init();
|
||||
|
||||
document.getElementById("reset-button").addEventListener("click", () => {
|
||||
window.game.reset();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user