class RubyHoldem::Dealer

Attributes

community_cards[R]

Public Class Methods

new() click to toggle source
# File lib/ruby_holdem/dealer.rb, line 5
def initialize
  @deck = Deck.new
  @deck.shuffle
  @community_cards = []
end

Public Instance Methods

deal_community_cards(stage) click to toggle source
# File lib/ruby_holdem/dealer.rb, line 18
def deal_community_cards(stage)
  raise ArgumentError unless %w(pre_flop flop turn river show_down).include?(stage)

  if stage == 'flop'
    3.times { community_cards << @deck.deal }
  elsif %w(turn river).include?(stage)
    community_cards << @deck.deal
  end
end
deal_hole_cards(players) click to toggle source
# File lib/ruby_holdem/dealer.rb, line 11
def deal_hole_cards(players)
  raise ArgumentError unless players.map { |player| player.hole_cards.count == 0 }.all?
  players.each do |player|
    2.times { player.hole_cards << @deck.deal }
  end
end