course solution for the battlelog
This commit is contained in:
parent
29a258cc73
commit
d95841d13c
|
@ -79,16 +79,14 @@ const app = Vue.createApp({
|
||||||
this.currentRound++;
|
this.currentRound++;
|
||||||
const attackValue = getRandomValue(5, 12);
|
const attackValue = getRandomValue(5, 12);
|
||||||
this.monsterHealth -= attackValue;
|
this.monsterHealth -= attackValue;
|
||||||
this.addToBattleLog("You deal " + attackValue + " damage.");
|
this.addToBattleLog("player", "attack", attackValue);
|
||||||
this.attackPlayer();
|
this.attackPlayer();
|
||||||
},
|
},
|
||||||
specialAttackMonster() {
|
specialAttackMonster() {
|
||||||
this.currentRound++;
|
this.currentRound++;
|
||||||
const attackValue = getRandomValue(10, 25);
|
const attackValue = getRandomValue(10, 25);
|
||||||
this.monsterHealth -= attackValue;
|
this.monsterHealth -= attackValue;
|
||||||
this.addToBattleLog(
|
this.addToBattleLog("player", "special attack", attackValue);
|
||||||
"Your special attack deals " + attackValue + " damage."
|
|
||||||
);
|
|
||||||
this.attackPlayer();
|
this.attackPlayer();
|
||||||
},
|
},
|
||||||
healPlayer() {
|
healPlayer() {
|
||||||
|
@ -99,9 +97,7 @@ const app = Vue.createApp({
|
||||||
} else {
|
} else {
|
||||||
this.playerHealth += healValue;
|
this.playerHealth += healValue;
|
||||||
}
|
}
|
||||||
this.addToBattleLog(
|
this.addToBattleLog("player", "heal", healValue);
|
||||||
"You heal yourself with " + healValue + " heal points."
|
|
||||||
);
|
|
||||||
this.attackPlayer();
|
this.attackPlayer();
|
||||||
},
|
},
|
||||||
surrender() {
|
surrender() {
|
||||||
|
@ -109,13 +105,15 @@ const app = Vue.createApp({
|
||||||
},
|
},
|
||||||
attackPlayer() {
|
attackPlayer() {
|
||||||
const attackValue = getRandomValue(8, 15);
|
const attackValue = getRandomValue(8, 15);
|
||||||
this.addToBattleLog(
|
this.addToBattleLog("monster", "attack", attackValue);
|
||||||
"The monster deals " + attackValue + " damage."
|
|
||||||
);
|
|
||||||
this.playerHealth -= attackValue;
|
this.playerHealth -= attackValue;
|
||||||
},
|
},
|
||||||
addToBattleLog(input) {
|
addToBattleLog(who, what, value) {
|
||||||
this.battleLog.push(input);
|
this.battleLog.unshift({
|
||||||
|
actionBy: who,
|
||||||
|
actionType: what,
|
||||||
|
actionValue: value,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -44,7 +44,8 @@
|
||||||
<section id="log" class="container">
|
<section id="log" class="container">
|
||||||
<h2>Battle Log</h2>
|
<h2>Battle Log</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for=" item in battleLog" :key="item">{{ item }}</li>
|
<li v-for="message in battleLog" :key="message">{{ message.actionBy }}, {{ message.actionType }}, {{
|
||||||
|
message.actionValue }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
Reference in New Issue