updated styling for combat message and behavior if 2 possible answers are equal. in game.js

This commit is contained in:
Patryk Hegenberg 2023-01-12 19:45:17 +01:00
parent e3c39abf30
commit 5dbb48ca0e
3 changed files with 9 additions and 9 deletions

View file

@ -590,11 +590,11 @@
random2 += 1; random2 += 1;
} }
} }
else if (random1 < 1) { if (random1 < 1) {
random1 = 1; random1 = 1 + randomValue(0,2);
} }
else if (random2 < 1) { if (random2 < 1) {
random2 = 1; random2 = 1 + randomValue(0, 2);
} }
if (randomVar === 1) { if (randomVar === 1) {
document.getElementById("answer1").innerHTML = `${answerValue}`; document.getElementById("answer1").innerHTML = `${answerValue}`;
@ -642,12 +642,12 @@
const clicked = await setupButtons(answerValue); const clicked = await setupButtons(answerValue);
let fight = checkSolution(clicked, answerValue); let fight = checkSolution(clicked, answerValue);
if(fight) { if(fight) {
msg.push(`${Game.player.name} hit the monster.`); msg.push(`${Game.player.name} haut ${hitter.name}.`);
hitter.stats.hp -= 1; hitter.stats.hp -= 1;
sfx["hit"].play(); sfx["hit"].play();
} else { } else {
sfx["miss"].play(); sfx["miss"].play();
msg.push(`The monster hit ${Game.player.name}.`); msg.push(`${hitter.name} haut ${Game.player.name}.`);
Game.player.stats.hp -= 1; Game.player.stats.hp -= 1;
} }
if(msg) { if(msg) {
@ -817,7 +817,7 @@
return msgs return msgs
.concat( .concat(
m.split(" ").map(function (p) { m.split(" ").map(function (p) {
const match = p.match(/hit|miss/); const match = p.match(/haut|miss/);
return el("span", { className: match ? match[0] : "" }, [p, " "]); return el("span", { className: match ? match[0] : "" }, [p, " "]);
}) })
) )

View file

@ -323,7 +323,7 @@ a:hover {
flex-direction: column; flex-direction: column;
} }
#message .hit { #message .haut {
color: #C01256; color: #C01256;
} }