my solution to the battlelog
This commit is contained in:
parent
b8850474a8
commit
29a258cc73
|
@ -77,12 +77,18 @@ const app = Vue.createApp({
|
||||||
},
|
},
|
||||||
attackMonster() {
|
attackMonster() {
|
||||||
this.currentRound++;
|
this.currentRound++;
|
||||||
this.monsterHealth -= getRandomValue(5, 12);
|
const attackValue = getRandomValue(5, 12);
|
||||||
|
this.monsterHealth -= attackValue;
|
||||||
|
this.addToBattleLog("You deal " + attackValue + " damage.");
|
||||||
this.attackPlayer();
|
this.attackPlayer();
|
||||||
},
|
},
|
||||||
specialAttackMonster() {
|
specialAttackMonster() {
|
||||||
this.currentRound++;
|
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();
|
this.attackPlayer();
|
||||||
},
|
},
|
||||||
healPlayer() {
|
healPlayer() {
|
||||||
|
@ -93,13 +99,23 @@ const app = Vue.createApp({
|
||||||
} else {
|
} else {
|
||||||
this.playerHealth += healValue;
|
this.playerHealth += healValue;
|
||||||
}
|
}
|
||||||
|
this.addToBattleLog(
|
||||||
|
"You heal yourself with " + healValue + " heal points."
|
||||||
|
);
|
||||||
this.attackPlayer();
|
this.attackPlayer();
|
||||||
},
|
},
|
||||||
surrender() {
|
surrender() {
|
||||||
this.winner = "monster";
|
this.winner = "monster";
|
||||||
},
|
},
|
||||||
attackPlayer() {
|
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);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,7 +43,9 @@
|
||||||
</section>
|
</section>
|
||||||
<section id="log" class="container">
|
<section id="log" class="container">
|
||||||
<h2>Battle Log</h2>
|
<h2>Battle Log</h2>
|
||||||
<ul></ul>
|
<ul>
|
||||||
|
<li v-for=" item in battleLog" :key="item">{{ item }}</li>
|
||||||
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
Reference in New Issue