Fix bidding error

This commit is contained in:
Christoph Hagen 2021-12-21 16:06:59 +01:00
parent ef966b0aa3
commit 97ff9ddce4

View File

@ -131,7 +131,11 @@ final class BiddingTable: AbstractTable<BiddingPlayer> {
players.forEach { $0.isAllowedToOfferWedding = false } players.forEach { $0.isAllowedToOfferWedding = false }
} }
} }
selectNextBidder() if remainingBidders == 1 {
moveToGameSelection()
} else {
selectNextBidder()
}
return (.success, nil) return (.success, nil)
} }
@ -150,11 +154,7 @@ final class BiddingTable: AbstractTable<BiddingPlayer> {
if gameToOutbid != .none { if gameToOutbid != .none {
// Last player must play // Last player must play
player.isNextActor = false player.isNextActor = false
indexOfHighestBidder = players.firstIndex { $0.isStillBidding == true }! moveToGameSelection()
let highestPlayer = players[indexOfHighestBidder]
highestPlayer.isStillBidding = false
highestPlayer.selectsGame = true
highestPlayer.isNextActor = true
return (.success, nil) return (.success, nil)
} }
default: default:
@ -164,6 +164,14 @@ final class BiddingTable: AbstractTable<BiddingPlayer> {
return (.success, nil) return (.success, nil)
} }
private func moveToGameSelection() {
indexOfHighestBidder = players.firstIndex { $0.isStillBidding == true }!
let highestPlayer = players[indexOfHighestBidder]
highestPlayer.isStillBidding = false
highestPlayer.selectsGame = true
highestPlayer.isNextActor = true
}
override func cards(forPlayerAt index: Int) -> [PlayableCard] { override func cards(forPlayerAt index: Int) -> [PlayableCard] {
players[index].cards.unplayable players[index].cards.unplayable
} }