Class: RubyHoldem::Dealer
- Inherits:
-
Object
- Object
- RubyHoldem::Dealer
- Defined in:
- lib/ruby_holdem/dealer.rb
Instance Attribute Summary collapse
-
#community_cards ⇒ Object
readonly
Returns the value of attribute community_cards.
Instance Method Summary collapse
- #deal_community_cards(stage) ⇒ Object
- #deal_hole_cards(players) ⇒ Object
-
#initialize ⇒ Dealer
constructor
A new instance of Dealer.
Constructor Details
#initialize ⇒ Dealer
Returns a new instance of Dealer.
5 6 7 8 9 |
# File 'lib/ruby_holdem/dealer.rb', line 5 def initialize @deck = Deck.new @deck.shuffle @community_cards = [] end |
Instance Attribute Details
#community_cards ⇒ Object (readonly)
Returns the value of attribute community_cards.
3 4 5 |
# File 'lib/ruby_holdem/dealer.rb', line 3 def community_cards @community_cards end |
Instance Method Details
#deal_community_cards(stage) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# 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) ⇒ Object
11 12 13 14 15 16 |
# 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 |