add a special attack

This commit is contained in:
Andreas Zweili 2021-01-21 12:28:31 +01:00
parent 7eaa708046
commit 6f3f20e1b4
2 changed files with 11 additions and 2 deletions

View File

@ -10,6 +10,7 @@ const app = Vue.createApp({
playerHealth: 100, playerHealth: 100,
monsterHealth: 100, monsterHealth: 100,
battleLog: [], battleLog: [],
currentRound: 0,
}; };
}, },
computed: { computed: {
@ -19,13 +20,21 @@ const app = Vue.createApp({
playerBarStyles() { playerBarStyles() {
return { width: this.playerHealth + "%" }; return { width: this.playerHealth + "%" };
}, },
specialAttackAllowed() {
return this.currentRound % 3 !== 0;
},
}, },
methods: { methods: {
attackMonster() { attackMonster() {
this.currentRound++;
this.monsterHealth -= attackValue(5, 12); this.monsterHealth -= attackValue(5, 12);
this.attackPlayer(); this.attackPlayer();
}, },
specialAttackMonster() {}, specialAttackMonster() {
this.currentRound++;
this.monsterHealth -= attackValue(10, 25);
this.attackPlayer();
},
healPlayer() {}, healPlayer() {},
surrender() {}, surrender() {},
attackPlayer() { attackPlayer() {

View File

@ -30,7 +30,7 @@
</section> </section>
<section id="controls"> <section id="controls">
<button @click="attackMonster">ATTACK</button> <button @click="attackMonster">ATTACK</button>
<button>SPECIAL ATTACK</button> <button :disabled="specialAttackAllowed" @click="specialAttackMonster">SPECIAL ATTACK</button>
<button>HEAL</button> <button>HEAL</button>
<button>SURRENDER</button> <button>SURRENDER</button>
</section> </section>