added logic for end-game if circles === maxcircles

This commit is contained in:
Kostya
2024-01-25 23:15:57 +03:00
parent 7ae4fcb79e
commit e11011bace

View File

@@ -132,7 +132,9 @@
</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>--> </div>
<div class="start-game" v-if="ValidationPlay.winGame === true">
<h2>Игра успешно закончена! Приз забран.</h2>
</div> </div>
</template> </template>
@@ -180,6 +182,7 @@ export default {
ValidationPlay: { ValidationPlay: {
startGame: false, startGame: false,
endGame: false, endGame: false,
winGame: false,
}, },
modules: [ Navigation ] modules: [ Navigation ]
} }
@@ -216,8 +219,9 @@ export default {
async handler(value) { async handler(value) {
if (value.length < 1 || this.ValidationPlay.endGame === true) return if (value.length < 1 || this.ValidationPlay.endGame === true) return
const maxCircles = 25 - this.amountCrystals const maxCircles = 25 - this.amountCrystals
console.log(maxCircles)
if (this.gamesCircle < maxCircles && this.gameStart !== false) { if (this.gameStart !== false) {
this.offEventPointers = false this.offEventPointers = false
let AnswerServer let AnswerServer
@@ -266,11 +270,12 @@ export default {
if (AnswerServer === 'You dead') { if (AnswerServer === 'You dead') {
this.offEventPointers = false this.offEventPointers = false
this.gameStart = false this.gameStart = false
this.gamesCircle = 0
this.winningAmount = 0 this.winningAmount = 0
this.flippedCards = [] this.flippedCards = []
const SoundCorrect = new Howl({ const SoundCorrect = new Howl({
src: ['/sounds/incorrect-sound.mp3'], src: ['/sounds/incorrect-sound.mp3'],
volume: 1.0 volume: 0.5
}) })
SoundCorrect.play() SoundCorrect.play()
@@ -283,17 +288,24 @@ export default {
} }
const SoundUncorrect = new Howl({ const SoundUncorrect = new Howl({
src: ['/sounds/correct-click.mp3'], src: ['/sounds/correct-click.mp3'],
volume: 1.0 volume: 0.5
}) })
SoundUncorrect.play() SoundUncorrect.play()
} }
else { if (this.gamesCircle === maxCircles) {
this.gameStart = false
this.offEventPointers = false this.offEventPointers = false
this.flippedCards = [] this.gameStart = false
this.gamesCircle = 0 this.gamesCircle = 0
// В будущем - вылазит уведомление, где написано игра закончена, "Продолжить" - клик и обновление страницы this.flippedCards = []
this.claimWinningAmount()
this.ValidationPlay.winGame = true
setTimeout(() => {
this.ValidationPlay.winGame = false
}, 1500)
} }
}, },
deep: true deep: true
@@ -365,6 +377,7 @@ export default {
this.offEventPointers = false this.offEventPointers = false
this.gameStart = false this.gameStart = false
this.flippedCards = [] this.flippedCards = []
this.gamesCircle = 0
await GetWinningAmount({ SearchToken: GetCookie('SearchToken'), AuthToken: GetCookie('AUTHTOKEN') }) await GetWinningAmount({ SearchToken: GetCookie('SearchToken'), AuthToken: GetCookie('AUTHTOKEN') })
this.winningAmount = 0 this.winningAmount = 0
} }