Sha256: affd3e73872a1b1880de4fa9c764ec9db3dc979fc5714b0d9ef742072cd49bb3
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
require 'delegate' require 'acpc_poker_types/poker_action' require 'acpc_poker_types/hand_player' # Model to parse and manage information from a given match state string. module AcpcPokerTypes class HandPlayerGroup < DelegateClass(Array) attr_reader :players def initialize(all_hands, stacks, blinds) @players = all_hands.length.times.map do |i| HandPlayer.new all_hands[i], stacks[i], blinds[i] end super @players end def next_player_position(acting_player_position=-1) (acting_player_position + 1) % length end def position_of_first_active_player(acting_player_position=0) return nil if all? { |player| player.inactive? } # This must eventually exit because of the above assertion while @players[acting_player_position].inactive? acting_player_position = next_player_position(acting_player_position) end acting_player_position end def action_cost(acting_player_position, action, min_wager) case action.to_s[0] when PokerAction::CALL amount_to_call acting_player_position when PokerAction::RAISE if action.modifier action.modifier.to_i - players[acting_player_position].total_contribution else min_wager + amount_to_call(acting_player_position) end else 0 end end def amount_to_call(acting_player_position) ChipStack.new( [ ( map do |player| player.total_contribution end ).max - players[acting_player_position].total_contribution, @players[acting_player_position].stack ].min ) end def next_to_act(acting_player_position=-1) position_of_first_active_player( next_player_position(acting_player_position) ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acpc_poker_types-7.0.0 | lib/acpc_poker_types/hand_player_group.rb |