| | |
| | | }, |
| | | computed: { |
| | | monsterBarStyle() { |
| | | if (this.monsterHealth < 0) { |
| | | return { width: "0%" }; |
| | | } |
| | | return { width: this.monsterHealth + "%" }; |
| | | }, |
| | | playerBarStyle() { |
| | | if (this.playerHealth < 0) { |
| | | return { width: "0%" }; |
| | | } |
| | | return { width: this.playerHealth + "%" }; |
| | | }, |
| | | mayUseSpecialAttack() { |
| | |
| | | }, |
| | | }, |
| | | watch: { |
| | | playerHealt(value) { |
| | | playerHealth(value) { |
| | | if (value <= 0 && this.monsterHealth <= 0) { |
| | | this.winner = "draw"; |
| | | } else if (value <= 0) { |
| | | this.winner = "moster"; |
| | | this.winner = "monster"; |
| | | } |
| | | }, |
| | | monsterHealth(value) { |
| | | if (value <= 0 && this.playerHealt <= 0) { |
| | | if (value <= 0 && this.playerHealth <= 0) { |
| | | this.winner = "draw"; |
| | | } else if (value <= 0) { |
| | | this.winner = "player"; |
| | |
| | | }, |
| | | }, |
| | | methods: { |
| | | startGame() { |
| | | this.playerHealth = 100; |
| | | this.monsterHealth = 100; |
| | | this.currentRound = 0; |
| | | this.winner = null; |
| | | }, |
| | | attackMonster() { |
| | | this.currentRound++; |
| | | const attackValue = getRandomValue(5, 12); |
| | |
| | | } |
| | | this.attackPlayer(); |
| | | }, |
| | | surrender(){ |
| | | this.winner = 'monster'; |
| | | } |
| | | }, |
| | | }); |
| | | |