Cristiano Magro
2024-12-27 02ffa3e0d5af8ba63a6f5aff7911adea0d247e6f
implement player health
2 files modified
12 ■■■■■ changed files
04 - monster slayer game/prj-monster-01-starting-setup/app.js 10 ●●●●● patch | view | raw | blame | history
04 - monster slayer game/prj-monster-01-starting-setup/index.html 2 ●●● patch | view | raw | blame | history
04 - monster slayer game/prj-monster-01-starting-setup/app.js
@@ -39,6 +39,16 @@
      this.monsterHealth -= attackValue;
      this.attackPlayer();
    },
    healPlayer() {
      this.currentRound++;
      const healValue = getRandomValue(8, 20);
      if (this.playerHealth + healValue > 100) {
        this.playerHealth = 100;
      } else {
        this.playerHealth += healValue;
      }
      this.attackPlayer();
    },
  },
});
04 - monster slayer game/prj-monster-01-starting-setup/index.html
@@ -34,7 +34,7 @@
        <button @click="specialAttackMonster" :disabled="mayUseSpecialAttack">
          SPECIAL ATTACK
        </button>
        <button>HEAL</button>
        <button @click="healPlayer">HEAL</button>
        <button>SURRENDER</button>
      </section>
      <section id="log" class="container">