From 02ffa3e0d5af8ba63a6f5aff7911adea0d247e6f Mon Sep 17 00:00:00 2001 From: Cristiano Magro <cristiano.magro@vola.it> Date: Fri, 27 Dec 2024 00:09:09 +0100 Subject: [PATCH] implement player health --- 04 - monster slayer game/prj-monster-01-starting-setup/app.js | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/04 - monster slayer game/prj-monster-01-starting-setup/app.js b/04 - monster slayer game/prj-monster-01-starting-setup/app.js index d7283b0..8c7319a 100644 --- a/04 - monster slayer game/prj-monster-01-starting-setup/app.js +++ b/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(); + }, }, }); -- Gitblit v1.8.0