choose a random card when it is face down

This commit is contained in:
Giulio 2022-03-22 12:42:20 +01:00
parent ab5a684822
commit 2cda50e825

View File

@ -316,9 +316,16 @@ export default {
this.hasToChoose = true
},
chooseCard(card) {
this.$socket.emit('choose', this.chooseCards.indexOf(card))
let index = this.chooseCards.indexOf(card)
if (!this.debug_mode) {
let pl = this.players.filter(x=>x.name === this.target_p)[0]
if (index < pl.ncards) {
index = Math.floor(Math.random() * pl.ncards)
}
}
this.$socket.emit('choose', index)
if (Vue.config.devtools)
console.log(card + ' ' + this.chooseCards.indexOf(card))
console.log(card + ' ' + index)
this.chooseCards = []
this.hasToChoose = false
this.target_p = ''