add a button to start a new game
This commit is contained in:
parent
2b9755e7e7
commit
a31d971291
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
|
Reference in New Issue