Class: RubyHoldem::Round
- Inherits:
-
Object
- Object
- RubyHoldem::Round
- Extended by:
- Forwardable
- Defined in:
- lib/ruby_holdem/round.rb,
lib/ruby_holdem/round/player.rb,
lib/ruby_holdem/round/move_factory.rb,
lib/ruby_holdem/round/move_history.rb,
lib/ruby_holdem/round/move_validator.rb,
lib/ruby_holdem/round/move_history_computations.rb
Defined Under Namespace
Classes: MoveFactory, MoveHistory, MoveHistoryComputations, MoveValidator, Player
Constant Summary collapse
- STAGES =
%w(pre_flop flop turn river show_down)
Instance Attribute Summary collapse
-
#big_blinds ⇒ Object
readonly
Returns the value of attribute big_blinds.
-
#players ⇒ Object
readonly
Returns the value of attribute players.
-
#pot_amount ⇒ Object
readonly
Returns the value of attribute pot_amount.
-
#small_blinds ⇒ Object
readonly
Returns the value of attribute small_blinds.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#initialize(players, small_blinds, big_blinds) ⇒ Round
constructor
A new instance of Round.
- #make_move(move_type, amount = nil) ⇒ Object
- #next_stage ⇒ Object
Constructor Details
#initialize(players, small_blinds, big_blinds) ⇒ Round
Returns a new instance of Round.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ruby_holdem/round.rb', line 29 def initialize(players, small_blinds, big_blinds) @small_blinds = small_blinds @big_blinds = big_blinds @pot_amount = 0 @players = players.map { |player| Player.new(player) } @move_history = MoveHistory.new @move_history_computations = MoveHistoryComputations.new(@players, @move_history) @dealer = Dealer.new @dealer.deal_hole_cards(@players) end |
Instance Attribute Details
#big_blinds ⇒ Object (readonly)
Returns the value of attribute big_blinds.
7 8 9 |
# File 'lib/ruby_holdem/round.rb', line 7 def big_blinds @big_blinds end |
#players ⇒ Object (readonly)
Returns the value of attribute players.
7 8 9 |
# File 'lib/ruby_holdem/round.rb', line 7 def players @players end |
#pot_amount ⇒ Object (readonly)
Returns the value of attribute pot_amount.
7 8 9 |
# File 'lib/ruby_holdem/round.rb', line 7 def pot_amount @pot_amount end |
#small_blinds ⇒ Object (readonly)
Returns the value of attribute small_blinds.
7 8 9 |
# File 'lib/ruby_holdem/round.rb', line 7 def small_blinds @small_blinds end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
7 8 9 |
# File 'lib/ruby_holdem/round.rb', line 7 def state @state end |
Instance Method Details
#make_move(move_type, amount = nil) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ruby_holdem/round.rb', line 42 def make_move(move_type, amount=nil) move = MoveFactory.new(self, player_in_turn, move_type, amount).build MoveValidator.new(self, move).validate unless move[:amount].nil? player_in_turn.current_bet_amount += move[:amount] @pot_amount += move[:amount] end @move_history.add_move(move) end |
#next_stage ⇒ Object
55 56 57 58 |
# File 'lib/ruby_holdem/round.rb', line 55 def next_stage @move_history.next_stage @dealer.deal_community_cards(@move_history.stage) end |