class BitPoker::Round

Model of a BitPoker round @author Mckomo

Constants

STATE_CARD_DEAL
STATE_FINISHED
STATE_FIRST_BETTING
STATE_FIRST_CALL
STATE_FIRST_CALLED
STATE_FOLDED
STATE_POINTS_DISTRIBUTION
STATE_RULES_INTRODUCTION
STATE_SECOND_BETTING
STATE_SECOND_CALL
STATE_SECOND_CALLED
STATE_SHOWDOWN

Attributes

bets[RW]
bots[R]
cards[RW]
score[RW]
state[RW]

Public Class Methods

new( bots ) click to toggle source

Contractor of a round object

@param [Array] Array with two bots that participate in the round @return [Round]

# File lib/bitpoker/round.rb, line 27
def initialize( bots )
   @bots = bots               # Bind bots to the round
   @score = [0, 0]            # Init with clear score table
   @state = STATE_RULES_INTRODUCTION   # Start with card deal
end

Public Instance Methods

bets_even?() click to toggle source

Whether bets are even

@return [Mixed] True of false

# File lib/bitpoker/round.rb, line 43
def bets_even?
   @bets[0] == @bets[1]
end
draw?() click to toggle source

Whether it is a draw

@return [Mixed] True of false

# File lib/bitpoker/round.rb, line 92
def draw?
   @cards[0] == @cards[1]
end
higher_bid() click to toggle source

Return higher bid

@return [Integer]

# File lib/bitpoker/round.rb, line 50
def higher_bid
   @bets.max
end
higher_bidder() click to toggle source

Return higher bidder

@return [BotInterface]

# File lib/bitpoker/round.rb, line 78
def higher_bidder
   @bots[higher_bidder_index]
end
higher_bidder_index() click to toggle source

Return index of higher bidder

@return [Integer] 0 or 1

# File lib/bitpoker/round.rb, line 64
def higher_bidder_index
   @bets.index( higher_bid )
end
loser_index() click to toggle source

Return index of the round loser

@return [Integer] 0 or 1

# File lib/bitpoker/round.rb, line 106
def loser_index
   draw? ? nil : @cards.index( @cards.min )
end
lower_bid() click to toggle source

Return lower bid

@return [Integer]

# File lib/bitpoker/round.rb, line 57
def lower_bid
   @bets.min
end
lower_bidder() click to toggle source

Return lower bidder

@return [BotInterface]

# File lib/bitpoker/round.rb, line 85
def lower_bidder
   @bots[lower_bidder_index]
end
lower_bidder_index() click to toggle source

Return index of lower bidder

@return [Integer] 0 or 1

# File lib/bitpoker/round.rb, line 71
def lower_bidder_index
   @bets.index( lower_bid )
end
stake() click to toggle source

Value of a stake

@return [Integer]

# File lib/bitpoker/round.rb, line 36
def stake
   higher_bid
end
winner_index() click to toggle source

Return index of the round winner

@return [Integer] 0 or 1

# File lib/bitpoker/round.rb, line 99
def winner_index
   draw? ? nil : @cards.index( @cards.max )
end