In Vue.js, I have developed a 'mini-game' that allows players to 'fight'. After someone 'dies', the game declares the winner and prompts if you want to play again. However, I am facing an issue where resetting the health of both the player and the monster back to 100 after choosing to play again doesn't work as expected. Despite having tried various solutions, including console logs for debugging, the issue persists.
checkWinner: function() {
if(this.mHp <= 0) {
if (confirm('You won! Play again?')) {
this.startGame();
} else {
this.gameIsActive = false;
}
return true;
} else if (this.pHp <= 0) {
if (confirm('You lost! Play again?')) {
this.startGame();
} else {
this.gameIsActive = false;
}
return true;
}
return false;
}
If anyone could provide some insights on why this reset functionality is not working, I would greatly appreciate it. Thank you in advance!