added workaround for EventHandler bug in which the brwoser's default prompt is used

This commit is contained in:
Patryk Hegenberg 2023-01-07 17:32:31 +01:00
parent 6a38767426
commit fa41049853

View file

@ -1,5 +1,6 @@
(function (w) { (function (w) {
let count = 1; let count = 1;
let clickCount = 0;
// game title // game title
const gametitle = "The Math Wizard"; const gametitle = "The Math Wizard";
@ -477,8 +478,8 @@
path.shift(); path.shift();
if (path.length <= 1) { if (path.length <= 1) {
Game.playerAllowedToMove = false; //Game.playerAllowedToMove = false;
Game.engine.lock(); //Game.engine.lock();
combat(m, p); combat(m, p);
} else { } else {
drawTile(Game, m._x + "," + m._y, m); drawTile(Game, m._x + "," + m._y, m);
@ -539,9 +540,9 @@
sfx["hit"].play(); sfx["hit"].play();
if (checkDeath(hitter)) { if (checkDeath(hitter)) {
Game.player.stats.xp += 1; Game.player.stats.xp += 1;
showScreen("game"); //showScreen("game");
Game.playerAllowedToMove = true; //Game.playerAllowedToMove = true;
Game.engine.unlock(); //Game.engine.unlock();
} else { } else {
combat(hitter, receiver); combat(hitter, receiver);
} }
@ -585,12 +586,18 @@
} }
document.getElementById("answer1").addEventListener("click", async() => { document.getElementById("answer1").addEventListener("click", async() => {
checkSolution(document.getElementById("answer1").innerText, answerValue, hitter, receiver); checkSolution(document.getElementById("answer1").innerText, answerValue, hitter, receiver);
clickCount += 1;
console.log(clickCount);
}, {once: true}); }, {once: true});
document.getElementById("answer2").addEventListener("click", async() => { document.getElementById("answer2").addEventListener("click", async() => {
checkSolution(document.getElementById("answer2").innerText, answerValue, hitter, receiver); checkSolution(document.getElementById("answer2").innerText, answerValue, hitter, receiver);
clickCount += 1;
console.log(clickCount);
}, {once: true}); }, {once: true});
document.getElementById("answer3").addEventListener("click", async() => { document.getElementById("answer3").addEventListener("click", async() => {
checkSolution(document.getElementById("answer3").innerText, answerValue, hitter, receiver); checkSolution(document.getElementById("answer3").innerText, answerValue, hitter, receiver);
clickCount += 1;
console.log(clickCount);
}, {once: true}); }, {once: true});
} }
@ -599,9 +606,11 @@
Math.floor(Math.random() * (max - min)) + min; Math.floor(Math.random() * (max - min)) + min;
let [num1, num2] = [randomValue(1, 10), randomValue(1, 10)]; let [num1, num2] = [randomValue(1, 10), randomValue(1, 10)];
const answerValue = eval(`${num1} * ${num2}`); const answerValue = eval(`${num1} * ${num2}`);
document.getElementById("question").innerHTML = `${num1} * ${num2} = ? `; test = prompt(`${num1} * ${num2} = ?`);
setupButtons(answerValue, hitter, receiver); checkSolution(test, answerValue, hitter, receiver);
showScreen("combat"); //document.getElementById("question").innerHTML = `${num1} * ${num2} = ? `;
//setupButtons(answerValue, hitter, receiver);
//showScreen("combat");
checkDeath(receiver); checkDeath(receiver);
renderStats(Game.player.stats); renderStats(Game.player.stats);
} }