import Foundation import WebSocketKit final class BiddingPlayer { let name: String var socket: WebSocket? let cards: [PlayableCard] var isStillBidding = true var isAllowedToOfferWedding = true var offersWedding = false var wouldAcceptWedding = false init(player: DealingPlayer, cards: [PlayableCard]) { self.name = player.name self.socket = player.socket self.cards = cards } } extension BiddingPlayer: Player { var canOfferWedding: Bool { rawCards.canOfferWedding } var rawCards: [Card] { cards.map { $0.card } } var actions: [PlayerAction] { guard isStillBidding else { return [] } guard canOfferWedding, isAllowedToOfferWedding, !offersWedding else { return [.increaseOrMatchGame, .withdrawFromAuction] } return [.increaseOrMatchGame, .withdrawFromAuction, .offerWedding] } var playedCard: Card? { nil } }