← poker-tutor
import Foundation
/// How much a player may bet or raise. The engine is the only place the three are told apart:
/// bots, the coach and the screens read `LegalActions` and never re-implement the rule.
public enum BettingStructure: String, Sendable, Codable, CaseIterable {
/// Any amount from the minimum raise up to the whole stack. Tournaments, and the cash tables
/// most people know.
case noLimit
/// Up to the size of the pot after the call. Pot-Limit Omaha's structure, and a hold'em cash
/// option.
case potLimit
/// Bets come in one size: the big blind before the flop and on it, twice that on the turn and
/// river, and a bet plus three raises caps a round unless only two players are left in it.
case fixedLimit
/// The one size a fixed-limit bet has on this street. Nil for the other structures, which
/// have no fixed size.
public func fixedBet(bigBlind: Int, street: Street) -> Int? {
guard self == .fixedLimit else { return nil }
switch street {
case .preflop, .flop: return bigBlind
case .turn, .river, .showdown: return bigBlind * 2
}
}
/// One bet and three raises. Lifted heads-up.
public static let fixedLimitCap = 4
public var name: String {
switch self {
case .noLimit: return "no-limit"
case .potLimit: return "pot-limit"
case .fixedLimit: return "fixed-limit"
}
}
}