Class: TexasHoldem::Game

Inherits:
Object
  • Object
show all
Defined in:
lib/texas-holdem/game.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_cardsObject (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

#playersObject (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

#winnerObject



18
19
20
# File 'lib/texas-holdem/game.rb', line 18

def winner
  players.max
end