add a function to heal the player
This commit is contained in:
parent
3ffbadeb3a
commit
12a907e630
|
@ -35,12 +35,19 @@ const app = Vue.createApp({
|
||||||
this.monsterHealth -= getRandomValue(10, 25);
|
this.monsterHealth -= getRandomValue(10, 25);
|
||||||
this.attackPlayer();
|
this.attackPlayer();
|
||||||
},
|
},
|
||||||
|
healPlayer() {
|
||||||
|
this.currentRound++;
|
||||||
|
const healValue = getRandomValue(8, 20);
|
||||||
|
if (this.playerHealth + healValue > 100) {
|
||||||
|
this.playerHealth = 100;
|
||||||
|
} else {
|
||||||
|
this.playerHealth += healValue;
|
||||||
|
}
|
||||||
this.attackPlayer();
|
this.attackPlayer();
|
||||||
},
|
},
|
||||||
healPlayer() {},
|
|
||||||
surrender() {},
|
surrender() {},
|
||||||
attackPlayer() {
|
attackPlayer() {
|
||||||
this.playerHealth -= attackValue(8, 15);
|
this.playerHealth -= getRandomValue(8, 15);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<section id="controls">
|
<section id="controls">
|
||||||
<button @click="attackMonster">ATTACK</button>
|
<button @click="attackMonster">ATTACK</button>
|
||||||
<button :disabled="specialAttackAllowed" @click="specialAttackMonster">SPECIAL ATTACK</button>
|
<button :disabled="specialAttackAllowed" @click="specialAttackMonster">SPECIAL ATTACK</button>
|
||||||
<button>HEAL</button>
|
<button @click="healPlayer">HEAL</button>
|
||||||
<button>SURRENDER</button>
|
<button>SURRENDER</button>
|
||||||
</section>
|
</section>
|
||||||
<section id="log" class="container">
|
<section id="log" class="container">
|
||||||
|
|
Reference in New Issue