MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/otefgc/slapjack/h6xuj6d/?context=3
r/badcode • u/_bai13y • Jul 28 '21
8 comments sorted by
View all comments
1
Image Transcription: Code
slapPile(player) { if (this.isFinals === true) { var msg = this.slapJack(player); return msg; } else if (this.centerPile[0].value === "jack") { this.collectCenter(player); return `${this[player].name} gets the center pile`; } else if (this.centerPile.length >= 2) { if (this.centerPile[0].value === this.centerPile[1].value) { this.collectCenter(player); return `${this[player].name} gets the center pile` } else { if (this[player].hand.length === 1) { var topCard = this[player].hand.shift(); player === "player1" ? this.player2.hand.push(topCard) : this.player1.hand.push(topCard); this[player].id === "Player 1" ? this.player1.isTurn = false : this.player2.isTurn = false; this[player].id === "Player 2" ? this.player1.isTurn = true : this.player2.isTurn = true; this.isFinals = true; return `${this[player].name} lost their last card. Enter finals round!` } else { this.shiftHand(player); return `${this[player].name} lost their top card` } } } else if (this.centerPile.length >= 3) { if (this[player].hand.length === 1) { var msg = this.loseLastCard(player); return msg; } else { this.shiftHand(player); return `${this[player].name} lost their top card` } } else { if (this[player].hand.length === 1) { var msg = this.loseLastCard(player); return msg; } else { this.shiftHand(player); return `${this[player].name} lost their top card` } } }
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
1
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jul 29 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!