From 29a258cc73cda8833590bcf0322b351832f3cf23 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Fri, 22 Jan 2021 20:14:19 +0100 Subject: [PATCH] my solution to the battlelog --- prj-monster-01-starting-setup/app.js | 22 +++++++++++++++++++--- prj-monster-01-starting-setup/index.html | 4 +++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/prj-monster-01-starting-setup/app.js b/prj-monster-01-starting-setup/app.js index 03a5400..123faa0 100644 --- a/prj-monster-01-starting-setup/app.js +++ b/prj-monster-01-starting-setup/app.js @@ -77,12 +77,18 @@ const app = Vue.createApp({ }, attackMonster() { this.currentRound++; - this.monsterHealth -= getRandomValue(5, 12); + const attackValue = getRandomValue(5, 12); + this.monsterHealth -= attackValue; + this.addToBattleLog("You deal " + attackValue + " damage."); this.attackPlayer(); }, specialAttackMonster() { this.currentRound++; - this.monsterHealth -= getRandomValue(10, 25); + const attackValue = getRandomValue(10, 25); + this.monsterHealth -= attackValue; + this.addToBattleLog( + "Your special attack deals " + attackValue + " damage." + ); this.attackPlayer(); }, healPlayer() { @@ -93,13 +99,23 @@ const app = Vue.createApp({ } else { this.playerHealth += healValue; } + this.addToBattleLog( + "You heal yourself with " + healValue + " heal points." + ); this.attackPlayer(); }, surrender() { this.winner = "monster"; }, attackPlayer() { - this.playerHealth -= getRandomValue(8, 15); + const attackValue = getRandomValue(8, 15); + this.addToBattleLog( + "The monster deals " + attackValue + " damage." + ); + this.playerHealth -= attackValue; + }, + addToBattleLog(input) { + this.battleLog.push(input); }, }, }); diff --git a/prj-monster-01-starting-setup/index.html b/prj-monster-01-starting-setup/index.html index b011837..f5a69a6 100644 --- a/prj-monster-01-starting-setup/index.html +++ b/prj-monster-01-starting-setup/index.html @@ -43,7 +43,9 @@

Battle Log

- +