Skip to content

Commit

Permalink
adjusted the function attack local storage and now it properly reflec…
Browse files Browse the repository at this point in the history
…ts the changes in health when being attacked
  • Loading branch information
Dorstener committed Apr 29, 2024
1 parent 01008fd commit 504ac14
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,14 @@ function attack() {
text.innerText = "The " + monsters[fighting].name + " attacks.";
let actualWeapon = localStorage.getItem("Current Weapon");
text.innerText += " You attack it with your " + weapons[actualWeapon].name + ".";
health -= getMonsterAttackValue(monsters[fighting].level);
let actualHealth = localStorage.getItem("Health");
actualHealth -= getMonsterAttackValue(monsters[fighting].level);
if (isMonsterHit()) {
monsterHealth -= weapons[actualWeapon].power + Math.floor(Math.random() * xp) + 1;
} else {
text.innerText += " You miss.";
};
let actualHealth = localStorage.getItem("Health");

healthText.innerText = actualHealth;
monsterHealthText.innerText = monsterHealth;
if (actualHealth <= 0) {
Expand Down

0 comments on commit 504ac14

Please sign in to comment.