summaryrefslogtreecommitdiff
path: root/resources/js/game.js
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-08-26 23:20:37 +0200
committerDaniel Weipert <code@drogueronin.de>2023-08-26 23:20:37 +0200
commitb025d1655483aa13a29ab5594255460b48143a5a (patch)
tree1421476a3d0e7938dc1a86f56be800917caa07e1 /resources/js/game.js
parent36a5d5862c3744f899fe6a5712f81171af144795 (diff)
error handling
Diffstat (limited to 'resources/js/game.js')
-rw-r--r--resources/js/game.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/resources/js/game.js b/resources/js/game.js
index c64d744..c463ab8 100644
--- a/resources/js/game.js
+++ b/resources/js/game.js
@@ -179,7 +179,7 @@ const Game = {
else {
Game.playerIsChoosingNextMonster = true;
const monsterSelectionNode = UI.createPlayerDefeatedMonsterSelection();
- monsterSelectionNode.addEventListener('monster:selected', UI.createEventListener(() => Memory.saveToLocalStorage()));
+ monsterSelectionNode.addEventListener('monster:selected', UI.wrapCallback(() => Memory.saveToLocalStorage()));
UI.openPlayerDefeatedMonsterSelection(monsterSelectionNode);
}
}
@@ -570,7 +570,7 @@ const Game = {
else if (levelDifference <= -10) levelDifference = levelDifference / 10;
const opponentActiveMonster = Memory.state.opponent.activeMonster;
- Game.opponentActionTimeout = setTimeout(async () => {
+ Game.opponentActionTimeout = setTimeout(UI.wrapCallback(async () => {
if (opponentActiveMonster.hp <= 0) {
Game.opponentActionTimeout = null;
return;
@@ -592,7 +592,7 @@ const Game = {
}
Game.opponentActionTimeout = null;
- }, Math.max(levelDifference < 10 ? 500 : 50, Math.min(2000 - (speedDifference * 10) - (levelDifference * 100), 3000)));
+ }), Math.max(levelDifference < 10 ? 500 : 50, Math.min(2000 - (speedDifference * 10) - (levelDifference * 100), 3000)));
console.log(
'Opponent Attack Timeout',
Memory.state.opponent.activeMonster.stats.speed, Memory.state.player.activeMonster.stats.speed,
@@ -999,7 +999,7 @@ const Game = {
};
// Game click bindings
-UI.elements.nextTrainer.addEventListener('click', UI.createEventListener(Game.encounterTrainer));
-UI.elements.battleOpponent.addEventListener('click', UI.createEventListener(Game.battleClick));
-UI.elements.techniques.addEventListener('click', UI.createEventListener(Game.techniqueClick));
-UI.elements.menuCatch.addEventListener('click', UI.createEventListener(Game.catchMonster));
+UI.elements.nextTrainer.addEventListener('click', UI.wrapCallback(Game.encounterTrainer));
+UI.elements.battleOpponent.addEventListener('click', UI.wrapCallback(Game.battleClick));
+UI.elements.techniques.addEventListener('click', UI.wrapCallback(Game.techniqueClick));
+UI.elements.menuCatch.addEventListener('click', UI.wrapCallback(Game.catchMonster));