update logic for end game

This commit is contained in:
Kostya
2024-01-25 19:37:55 +03:00
parent cb20c9987f
commit bd78f21615

View File

@@ -132,7 +132,7 @@
</div> </div>
<div class="start-game" v-if="ValidationPlay.endGame === true"> <div class="start-game" v-if="ValidationPlay.endGame === true">
<h2>Вы подорвались! Игра закончена</h2> <h2>Вы подорвались! Игра закончена</h2>
<a href="#" @click="updatePage()">Продолжить</a> <!-- <a href="#" @click="updatePage()">Продолжить</a>-->
</div> </div>
</template> </template>
@@ -212,6 +212,7 @@ export default {
}, },
flippedCards: { flippedCards: {
async handler(value) { async handler(value) {
if (value.length < 1 || this.ValidationPlay.endGame === true) return
const maxCircles = 25 - this.amountCrystals const maxCircles = 25 - this.amountCrystals
if (this.gamesCircle < maxCircles && this.gameStart !== false) { if (this.gamesCircle < maxCircles && this.gameStart !== false) {
@@ -252,7 +253,7 @@ export default {
.then(response => { .then(response => {
AnswerServer = response AnswerServer = response
this.winningAmount = response.Item1.WinningMoney this.winningAmount = response.Item1.WinningMoney
console.log(response) console.log(response.Item1.WinningMoney)
}) })
} }
catch (e) { catch (e) {
@@ -264,7 +265,10 @@ export default {
this.gamesCircle = this.gamesCircle + 1 this.gamesCircle = this.gamesCircle + 1
this.offEventPointers = true this.offEventPointers = true
if (AnswerServer === 'You dead') { if (AnswerServer === 'You dead') {
this.ValidationPlay.endGame = true this.offEventPointers = false
this.gameStart = false
this.winningAmount = 0
this.flippedCards = []
} }
} }
@@ -336,9 +340,9 @@ export default {
console.error(e) console.error(e)
} }
}, },
updatePage() { // updatePage() {
window.location.reload() // window.location.reload()
}, // },
async claimWinningAmount() { async claimWinningAmount() {
if (this.winningAmount >= 1) { if (this.winningAmount >= 1) {
try { try {
@@ -371,8 +375,9 @@ export default {
}, },
flipCard(index) { flipCard(index) {
if (this.flippedCards.includes(index)) { if (this.flippedCards.includes(index)) {
this.flippedCards.splice(this.flippedCards.indexOf(index), 1); // this.flippedCards.splice(this.flippedCards.indexOf(index), 1);
console.log(index, this.flippedCards) // console.log(index, this.flippedCards)
return
} else { } else {
this.flippedCards.push(index); this.flippedCards.push(index);
} }