Class: TexasHoldem::Game
- Inherits:
-
Object
- Object
- TexasHoldem::Game
- Defined in:
- lib/texas-holdem/game.rb
Instance Attribute Summary collapse
-
#common_cards ⇒ Object
readonly
Returns the value of attribute common_cards.
-
#players ⇒ Object
readonly
Returns the value of attribute players.
Instance Method Summary collapse
-
#initialize(players_count, deck) ⇒ Game
constructor
A new instance of Game.
- #winner ⇒ Object
Constructor Details
#initialize(players_count, deck) ⇒ Game
Returns a new instance of Game.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/texas-holdem/game.rb', line 6 def initialize(players_count, deck) @players = [] @common_cards = deck.deal(5) players_count.times do |i| player_cards = deck.deal(2) puts "Player #{i} gets #{player_cards.map(&:to_s)}" players << PlayerHand.new(player_cards.concat(@common_cards)) end puts "Cards on table: #{@common_cards.map(&:to_s)}" puts "The winner is player #{@players.index(winner)} with combination #{winner.best_combination}" end |
Instance Attribute Details
#common_cards ⇒ Object (readonly)
Returns the value of attribute common_cards.
4 5 6 |
# File 'lib/texas-holdem/game.rb', line 4 def common_cards @common_cards end |
#players ⇒ Object (readonly)
Returns the value of attribute players.
4 5 6 |
# File 'lib/texas-holdem/game.rb', line 4 def players @players end |
Instance Method Details
#winner ⇒ Object
18 19 20 |
# File 'lib/texas-holdem/game.rb', line 18 def winner players.max end |