add a button to start a new game

This commit is contained in:
Andreas Zweili 2021-01-22 20:01:25 +01:00
parent 2b9755e7e7
commit a31d971291
2 changed files with 7 additions and 0 deletions

View File

@ -69,6 +69,12 @@ const app = Vue.createApp({
},
},
methods: {
restartGame() {
this.playerHealth = 100;
this.monsterHealth = 100;
this.winner = null;
this.currentRound = 0;
},
attackMonster() {
this.currentRound++;
this.monsterHealth -= getRandomValue(5, 12);

View File

@ -27,6 +27,7 @@
<h3 v-if="monsterWon">You lost!</h3>
<h3 v-if="playerWon">You won!</h3>
<h3 v-if="draw">It's a draw'!</h3>
<button @click="restartGame">Start a new game</button>
</section>
<section id="player" class="container">
<h2>Your Health</h2>