acpc_poker_types 0.0.10 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -4
  3. data/acpc_poker_types.gemspec +4 -2
  4. data/lib/acpc_poker_types.rb +13 -12
  5. data/lib/acpc_poker_types/acpc_dealer_data.rb +9 -0
  6. data/lib/acpc_poker_types/acpc_dealer_data/action_messages.rb +133 -0
  7. data/lib/acpc_poker_types/acpc_dealer_data/hand_data.rb +182 -0
  8. data/lib/acpc_poker_types/acpc_dealer_data/hand_results.rb +79 -0
  9. data/lib/acpc_poker_types/acpc_dealer_data/log_file.rb +5 -0
  10. data/lib/acpc_poker_types/acpc_dealer_data/match_definition.rb +54 -0
  11. data/lib/acpc_poker_types/acpc_dealer_data/poker_match_data.rb +393 -0
  12. data/lib/acpc_poker_types/board_cards.rb +4 -4
  13. data/lib/acpc_poker_types/card.rb +16 -16
  14. data/lib/acpc_poker_types/chip_stack.rb +1 -1
  15. data/lib/acpc_poker_types/game_definition.rb +34 -38
  16. data/lib/acpc_poker_types/hand.rb +5 -5
  17. data/lib/acpc_poker_types/match_state.rb +31 -32
  18. data/lib/acpc_poker_types/pile_of_cards.rb +1 -1
  19. data/lib/acpc_poker_types/player.rb +16 -15
  20. data/lib/acpc_poker_types/poker_action.rb +6 -6
  21. data/lib/acpc_poker_types/rank.rb +2 -2
  22. data/lib/acpc_poker_types/suit.rb +4 -4
  23. data/lib/acpc_poker_types/version.rb +1 -1
  24. data/spec/action_messages_spec.rb +450 -0
  25. data/spec/board_cards_spec.rb +9 -9
  26. data/spec/card_spec.rb +20 -20
  27. data/spec/chip_stack_spec.rb +28 -29
  28. data/spec/game_definition_spec.rb +11 -11
  29. data/spec/hand_data_spec.rb +295 -0
  30. data/spec/hand_results_spec.rb +292 -0
  31. data/spec/hand_spec.rb +11 -11
  32. data/spec/match_definition_spec.rb +95 -0
  33. data/spec/match_state_spec.rb +105 -287
  34. data/spec/pile_of_cards_spec.rb +14 -14
  35. data/spec/player_spec.rb +61 -61
  36. data/spec/poker_action_spec.rb +49 -49
  37. data/spec/poker_match_data_spec.rb +388 -0
  38. data/spec/rank_spec.rb +19 -19
  39. data/spec/suit_spec.rb +19 -19
  40. data/spec/support/spec_helper.rb +28 -6
  41. metadata +55 -10
@@ -1,10 +1,10 @@
1
1
 
2
2
  require 'dmorrill10-utils/class'
3
3
 
4
- require File.expand_path('../pile_of_cards', __FILE__)
4
+ require 'acpc_poker_types/pile_of_cards'
5
5
 
6
6
  # List of community board cards.
7
- class BoardCards < PileOfCards
7
+ class AcpcPokerTypes::BoardCards < AcpcPokerTypes::PileOfCards
8
8
 
9
9
  exceptions :too_many_board_cards
10
10
 
@@ -14,7 +14,7 @@ class BoardCards < PileOfCards
14
14
 
15
15
  def next_round!
16
16
  @round = if @round then @round + 1 else 0 end
17
- self[@round] = PileOfCards.new
17
+ self[@round] = AcpcPokerTypes::PileOfCards.new
18
18
  self
19
19
  end
20
20
 
@@ -42,7 +42,7 @@ class BoardCards < PileOfCards
42
42
  if all? { |pile_for_round| pile_for_round.empty? }
43
43
  ''
44
44
  else
45
- '/' + (map do |pile_for_round|
45
+ '/' + (map do |pile_for_round|
46
46
  (pile_for_round.map { |card| card.to_acpc }).join
47
47
  end).join('/')
48
48
  end
@@ -4,59 +4,59 @@ require 'dmorrill10-utils'
4
4
  require File.expand_path('../rank', __FILE__)
5
5
  require File.expand_path('../suit', __FILE__)
6
6
 
7
- class Card
8
- exceptions :unable_to_parse_acpc_card
7
+ class AcpcPokerTypes::Card
8
+ exceptions :parse_error
9
9
 
10
10
  # @param [String] acpc_string_of_cards A string of cards in ACPC format
11
- # @return [Array<Card>]
11
+ # @return [Array<AcpcPokerTypes::Card>]
12
12
  def self.cards(acpc_string_of_cards)
13
- all_ranks = Rank::DOMAIN.map do |rank, rank_properties|
13
+ all_ranks = AcpcPokerTypes::Rank::DOMAIN.map do |rank, rank_properties|
14
14
  rank_properties[:acpc_character]
15
15
  end.join
16
- all_suits = Suit::DOMAIN.map do |suit, suit_properties|
16
+ all_suits = AcpcPokerTypes::Suit::DOMAIN.map do |suit, suit_properties|
17
17
  suit_properties[:acpc_character]
18
18
  end.join
19
19
 
20
20
  acpc_string_of_cards.scan(/[#{all_ranks}][#{all_suits}]/).inject([]) do |pile, acpc_card|
21
- pile.push << Card.from_acpc(acpc_card)
21
+ pile.push << AcpcPokerTypes::Card.from_acpc(acpc_card)
22
22
  end
23
23
  end
24
24
 
25
25
  # @return [Integer] The numeric ACPC representation of the card.
26
26
  def self.acpc_card_number(rank, suit)
27
- rank.to_i * Suit::DOMAIN.length + suit.to_i
27
+ rank.to_i * AcpcPokerTypes::Suit::DOMAIN.length + suit.to_i
28
28
  end
29
29
 
30
30
  attr_reader :rank, :suit
31
31
 
32
- # @return Card
32
+ # @return AcpcPokerTypes::Card
33
33
  def self.from_acpc(acpc_card)
34
- all_ranks = Rank::DOMAIN.values.map do |card_rank|
34
+ all_ranks = AcpcPokerTypes::Rank::DOMAIN.values.map do |card_rank|
35
35
  card_rank[:acpc_character]
36
36
  end.join
37
- all_suits = Suit::DOMAIN.values.map do |card_suit|
38
- card_suit[:acpc_character]
37
+ all_suits = AcpcPokerTypes::Suit::DOMAIN.values.map do |card_suit|
38
+ card_suit[:acpc_character]
39
39
  end.join
40
40
 
41
41
  if acpc_card.match(/([#{all_ranks}])([#{all_suits}])/)
42
42
  rank = $1
43
43
  suit = $2
44
44
 
45
- Card.from_components rank, suit
45
+ AcpcPokerTypes::Card.from_components rank, suit
46
46
  else
47
- raise UnableToParseAcpcCard, acpc_card
47
+ raise ParseError, acpc_card
48
48
  end
49
49
  end
50
50
 
51
51
  alias_new :from_components
52
52
 
53
53
  def initialize(rank, suit)
54
- @rank = Rank.new rank
55
- @suit = Suit.new suit
54
+ @rank = AcpcPokerTypes::Rank.new rank
55
+ @suit = AcpcPokerTypes::Suit.new suit
56
56
  end
57
57
 
58
58
  def to_i
59
- Card.acpc_card_number(@rank, @suit)
59
+ AcpcPokerTypes::Card.acpc_card_number(@rank, @suit)
60
60
  end
61
61
 
62
62
  def to_str
@@ -3,7 +3,7 @@ require 'dmorrill10-utils/class'
3
3
 
4
4
  require 'delegate'
5
5
 
6
- class ChipStack < DelegateClass(Rational)
6
+ class AcpcPokerTypes::ChipStack < DelegateClass(Rational)
7
7
  exceptions :illegal_number_of_chips
8
8
 
9
9
  # @param [#to_i] number_of_chips The number of chips to be made into a stack.
@@ -3,13 +3,13 @@ require 'dmorrill10-utils/enumerable'
3
3
  require 'dmorrill10-utils/integer'
4
4
  require 'set'
5
5
 
6
- require File.expand_path('../chip_stack', __FILE__)
7
- require File.expand_path('../suit', __FILE__)
8
- require File.expand_path('../rank', __FILE__)
6
+ require 'acpc_poker_types/chip_stack'
7
+ require 'acpc_poker_types/suit'
8
+ require 'acpc_poker_types/rank'
9
9
 
10
10
  # Class that parses and manages game definition information from a game definition file.
11
- class GameDefinition
12
- exceptions :game_definition_parse_error
11
+ class AcpcPokerTypes::GameDefinition
12
+ exceptions :parse_error
13
13
 
14
14
  # @return [String] The string designating the betting type.
15
15
  attr_reader :betting_type
@@ -72,8 +72,8 @@ class GameDefinition
72
72
  }
73
73
 
74
74
  MAX_VALUES = {
75
- :@number_of_suits => Suit::DOMAIN.length,
76
- :@number_of_ranks => Rank::DOMAIN.length
75
+ :@number_of_suits => AcpcPokerTypes::Suit::DOMAIN.length,
76
+ :@number_of_ranks => AcpcPokerTypes::Rank::DOMAIN.length
77
77
  }
78
78
 
79
79
  # @return [Hash] Betting types understood by this class.
@@ -110,10 +110,10 @@ class GameDefinition
110
110
  end
111
111
 
112
112
  # @param [Integer] number_of_players The number of players that require stacks.
113
- # @return [Array<ChipStack>] The default list of initial stacks for every player.
113
+ # @return [Array<AcpcPokerTypes::ChipStack>] The default list of initial stacks for every player.
114
114
  def self.default_chip_stacks(number_of_players)
115
115
  number_of_players.to_i.times.inject([]) do |list, i|
116
- list << ChipStack.new(DEFAULT_CHIP_STACK)
116
+ list << AcpcPokerTypes::ChipStack.new(DEFAULT_CHIP_STACK)
117
117
  end
118
118
  end
119
119
 
@@ -145,7 +145,7 @@ class GameDefinition
145
145
  (0..values.length-1).each do |i|
146
146
  values[i] = values[i].to_i
147
147
  end
148
- GameDefinition.flatten_if_single_element_array values
148
+ flatten_if_single_element_array values
149
149
  end
150
150
  end
151
151
 
@@ -156,27 +156,21 @@ class GameDefinition
156
156
  # @return [String] line The line to check.
157
157
  # @return [Boolean] +true+ if the line is not informative, +false+ otherwise.
158
158
  def self.game_def_line_not_informative?(line)
159
- GameDefinition.line_is_comment_or_empty?(line) || line.match(/\s*gamedef\s*/i)
159
+ line_is_comment_or_empty?(line) || line.match(/\s*gamedef\s*/i)
160
160
  end
161
161
 
162
162
  # @param [String] game_definition_file_name The name of the game definition file that this instance should parse.
163
- # @raise (see #initialize)
164
163
  def self.parse_file(game_definition_file_name)
165
- File.open(game_definition_file_name, 'r') { |file| GameDefinition.parse file }
164
+ File.open(game_definition_file_name, 'r') { |file| parse file }
166
165
  end
167
166
 
168
167
  alias_new :parse
169
168
 
170
- # @raise GameDefinitionParseError
171
169
  def initialize(definitions)
172
170
  initialize_members!
173
- begin
174
- parse_definitions! definitions
175
- rescue => unable_to_read_or_open_file_error
176
- raise GameDefinitionParseError, unable_to_read_or_open_file_error.message
177
- end
171
+ parse_definitions! definitions
178
172
 
179
- @chip_stacks = GameDefinition.default_chip_stacks(@number_of_players) if @chip_stacks.empty?
173
+ @chip_stacks = AcpcPokerTypes::GameDefinition.default_chip_stacks(@number_of_players) if @chip_stacks.empty?
180
174
 
181
175
  unless @first_player_positions.any? { |pos| pos <= 0 }
182
176
  @first_player_positions.map! { |position| position - 1 }
@@ -228,9 +222,9 @@ class GameDefinition
228
222
  @blinds = @number_of_players.times.inject([]) { |blinds, i| blinds << 0 }
229
223
  @number_of_rounds = MIN_VALUES[:@number_of_rounds]
230
224
  @number_of_board_cards = @number_of_rounds.times.inject([]) { |cards, i| cards << 0 }
231
- @first_player_positions = GameDefinition.default_first_player_positions @number_of_rounds
232
- @max_number_of_wagers = GameDefinition.default_max_number_of_wagers @number_of_rounds
233
- @chip_stacks = GameDefinition.default_chip_stacks @number_of_players
225
+ @first_player_positions = AcpcPokerTypes::GameDefinition.default_first_player_positions @number_of_rounds
226
+ @max_number_of_wagers = AcpcPokerTypes::GameDefinition.default_max_number_of_wagers @number_of_rounds
227
+ @chip_stacks = AcpcPokerTypes::GameDefinition.default_chip_stacks @number_of_players
234
228
  @number_of_suits = MIN_VALUES[:@number_of_suits]
235
229
  @number_of_ranks = MIN_VALUES[:@number_of_ranks]
236
230
  @number_of_hole_cards = MIN_VALUES[:@number_of_hole_cards]
@@ -239,7 +233,10 @@ class GameDefinition
239
233
  end
240
234
 
241
235
  def set_defintion_if_present!(definition_symbol, line, definition_label_in_line)
242
- new_definition = GameDefinition.check_game_def_line_for_definition line, definition_label_in_line
236
+ new_definition = AcpcPokerTypes::GameDefinition.check_game_def_line_for_definition(
237
+ line,
238
+ definition_label_in_line
239
+ )
243
240
  if new_definition
244
241
  instance_variable_set(definition_symbol, new_definition)
245
242
  true
@@ -251,9 +248,8 @@ class GameDefinition
251
248
  def parse_definitions!(definitions)
252
249
  definitions.each do |line|
253
250
  break if line.match(/\bend\s*gamedef\b/i)
254
-
255
251
  next if (
256
- GameDefinition.game_def_line_not_informative?(line) ||
252
+ AcpcPokerTypes::GameDefinition.game_def_line_not_informative?(line) ||
257
253
  BETTING_TYPES.any? do |type_and_name|
258
254
  type = type_and_name.first
259
255
  name = type_and_name[1]
@@ -273,21 +269,21 @@ class GameDefinition
273
269
  self
274
270
  end
275
271
 
276
- # @raise GameDefinitionParseError
272
+ # @raise ParseError
277
273
  def sanity_check_game_definitions!
278
274
  adjust_definitions_if_necessary!
279
275
 
280
- raise GameDefinitionParseError, "list of player stacks not specified" unless @chip_stacks
281
- raise GameDefinitionParseError, "list of blinds not specified" unless @blinds
282
- raise GameDefinitionParseError, "raise size in each round not specified" unless min_wagers
283
- raise GameDefinitionParseError, "first player position in each round not specified" unless @first_player_positions
284
- raise GameDefinitionParseError, "maximum raise in each round not specified" unless @max_number_of_wagers
285
- raise GameDefinitionParseError, "number of board cards in each round not specified" unless @number_of_board_cards
276
+ raise ParseError, "list of player stacks not specified" unless @chip_stacks
277
+ raise ParseError, "list of blinds not specified" unless @blinds
278
+ raise ParseError, "raise size in each round not specified" unless min_wagers
279
+ raise ParseError, "first player position in each round not specified" unless @first_player_positions
280
+ raise ParseError, "maximum raise in each round not specified" unless @max_number_of_wagers
281
+ raise ParseError, "number of board cards in each round not specified" unless @number_of_board_cards
286
282
 
287
283
  MIN_VALUES.each do |symbol, min_value|
288
284
  if instance_variable_get(symbol) < min_value
289
285
  raise(
290
- GameDefinitionParseError,
286
+ ParseError,
291
287
  "Invalid definition, #{DEFINITION[symbol]} must be greater than #{min_value} but was set to #{instance_variable_get(symbol)}"
292
288
  )
293
289
  end
@@ -296,7 +292,7 @@ class GameDefinition
296
292
  (0..@number_of_players-1).each do |i|
297
293
  if @blinds[i] > @chip_stacks[i]
298
294
  raise(
299
- GameDefinitionParseError,
295
+ ParseError,
300
296
  "Blind for player #{i+1} (#{@blinds[i]}) is greater than stack size (#{@chip_stacks[i]})"
301
297
  )
302
298
  end
@@ -305,7 +301,7 @@ class GameDefinition
305
301
  @number_of_rounds.times do |i|
306
302
  unless @first_player_positions[i].seat_in_bounds? @number_of_players
307
303
  raise(
308
- GameDefinitionParseError,
304
+ ParseError,
309
305
  "Invalid first player #{@first_player_positions[i]} on round #{i+1}"
310
306
  )
311
307
  end
@@ -314,7 +310,7 @@ class GameDefinition
314
310
  MAX_VALUES.each do |symbol, max_value|
315
311
  if instance_variable_get(symbol) > max_value
316
312
  raise(
317
- GameDefinitionParseError,
313
+ ParseError,
318
314
  "Invalid definition, #{DEFINITIONS[symbol]} must be less than #{max_value} but was set to #{instance_variable_get(symbol)}"
319
315
  )
320
316
  end
@@ -324,7 +320,7 @@ class GameDefinition
324
320
 
325
321
  if number_of_cards_required > (@number_of_suits * @number_of_ranks)
326
322
  raise(
327
- GameDefinitionParseError,
323
+ ParseError,
328
324
  "Too many hole and board cards (#{number_of_cards_required}) for specified deck (#{(@number_of_suits * @number_of_ranks)})"
329
325
  )
330
326
  end
@@ -1,17 +1,17 @@
1
1
 
2
- require File.expand_path('../pile_of_cards', __FILE__)
3
- require File.expand_path('../card', __FILE__)
2
+ require 'acpc_poker_types/pile_of_cards'
3
+ require 'acpc_poker_types/card'
4
4
 
5
- class Hand < PileOfCards
5
+ class AcpcPokerTypes::Hand < AcpcPokerTypes::PileOfCards
6
6
  # @return [Hand]
7
7
  def self.draw_cards(*cards)
8
- Hand.new cards
8
+ AcpcPokerTypes::Hand.new cards
9
9
  end
10
10
 
11
11
  # @param [String] acpc_string_hand ACPC string description of a hand.
12
12
  # @return [Hand]
13
13
  def self.from_acpc(acpc_string_hand)
14
- Hand.new Card.cards(acpc_string_hand)
14
+ AcpcPokerTypes::Hand.new AcpcPokerTypes::Card.cards(acpc_string_hand)
15
15
  end
16
16
 
17
17
  def to_s
@@ -1,15 +1,14 @@
1
1
 
2
2
  require 'dmorrill10-utils'
3
3
 
4
- require File.expand_path('../board_cards', __FILE__)
5
- require File.expand_path('../hand', __FILE__)
6
- require File.expand_path('../rank', __FILE__)
7
- require File.expand_path('../suit', __FILE__)
8
- require File.expand_path('../poker_action', __FILE__)
9
-
4
+ require 'acpc_poker_types/board_cards'
5
+ require 'acpc_poker_types/hand'
6
+ require 'acpc_poker_types/rank'
7
+ require 'acpc_poker_types/suit'
8
+ require 'acpc_poker_types/poker_action'
10
9
 
11
10
  # Model to parse and manage information from a given match state string.
12
- class MatchState
11
+ class AcpcPokerTypes::MatchState
13
12
  exceptions :incomplete_match_state
14
13
 
15
14
  # @return [Integer] The position relative to the dealer of the player that
@@ -24,13 +23,13 @@ class MatchState
24
23
  # @return [Integer] The hand number.
25
24
  attr_reader :hand_number
26
25
 
27
- # @return [Array<Array<PokerAction>>] The sequence of betting actions.
26
+ # @return [Array<Array<AcpcPokerTypes::PokerAction>>] The sequence of betting actions.
28
27
  attr_reader :betting_sequence
29
28
 
30
- # @return [Array<Hand>] The list of visible hole card sets for each player.
29
+ # @return [Array<AcpcPokerTypes::Hand>] The list of visible hole card sets for each player.
31
30
  attr_reader :list_of_hole_card_hands
32
31
 
33
- # @return [BoardCards] All visible community cards on the board.
32
+ # @return [AcpcPokerTypes::BoardCards] All visible community cards on the board.
34
33
  attr_reader :board_cards
35
34
 
36
35
  # @return [Array<Integer>] The list of first seats for each round.
@@ -51,9 +50,9 @@ class MatchState
51
50
  # @return [String] The constructed match state string.
52
51
  def self.build_match_state_string(
53
52
  position_relative_to_dealer,
54
- hand_number,
53
+ hand_number,
55
54
  betting_sequence,
56
- all_hole_cards,
55
+ all_hole_cards,
57
56
  board_cards
58
57
  )
59
58
  string = LABEL +
@@ -74,11 +73,11 @@ class MatchState
74
73
  # @param [String] raw_match_state A raw match state string to be parsed.
75
74
  # @raise IncompleteMatchState
76
75
  def initialize(raw_match_state)
77
- raise IncompleteMatchState, raw_match_state if MatchState.line_is_comment_or_empty? raw_match_state
76
+ raise IncompleteMatchState, raw_match_state if AcpcPokerTypes::MatchState.line_is_comment_or_empty? raw_match_state
78
77
 
79
- all_actions = PokerAction::LEGAL_ACPC_CHARACTERS.to_a.join
80
- all_ranks = (Rank::DOMAIN.map { |rank, properties| properties[:acpc_character] }).join
81
- all_suits = (Suit::DOMAIN.map { |suit, properties| properties[:acpc_character] }).join
78
+ all_actions = AcpcPokerTypes::PokerAction::LEGAL_ACPC_CHARACTERS.to_a.join
79
+ all_ranks = (AcpcPokerTypes::Rank::DOMAIN.map { |rank, properties| properties[:acpc_character] }).join
80
+ all_suits = (AcpcPokerTypes::Suit::DOMAIN.map { |suit, properties| properties[:acpc_character] }).join
82
81
  all_card_tokens = all_ranks + all_suits
83
82
  if raw_match_state.match(
84
83
  /#{LABEL}:(\d+):(\d+):([\d#{all_actions}\/]*):([|#{all_card_tokens}]+)\/*([\/#{all_card_tokens}]*)/)
@@ -92,12 +91,12 @@ class MatchState
92
91
  raise IncompleteMatchState, raw_match_state if incomplete_match_state?
93
92
  end
94
93
 
95
- # @return [String] The MatchState in raw text form.
94
+ # @return [String] The AcpcPokerTypes::MatchState in raw text form.
96
95
  def to_str
97
- MatchState.build_match_state_string(
96
+ AcpcPokerTypes::MatchState.build_match_state_string(
98
97
  @position_relative_to_dealer,
99
98
  @hand_number, betting_sequence_string,
100
- hole_card_strings,
99
+ hole_card_strings,
101
100
  @board_cards
102
101
  )
103
102
  end
@@ -105,7 +104,7 @@ class MatchState
105
104
  # @see to_str
106
105
  alias_method :to_s, :to_str
107
106
 
108
- # @param [MatchState] another_match_state A match state string to compare against this one.
107
+ # @param [AcpcPokerTypes::MatchState] another_match_state A match state string to compare against this one.
109
108
  # @return [Boolean] +true+ if this match state string is equivalent to +another_match_state+, +false+ otherwise.
110
109
  def ==(another_match_state)
111
110
  another_match_state.to_s == to_s
@@ -114,8 +113,8 @@ class MatchState
114
113
  # @return [Integer] The number of players in this match.
115
114
  def number_of_players() @list_of_hole_card_hands.length end
116
115
 
117
- # @param [Array<Array<PokerAction>>] betting_sequence The betting sequence from which the last action should be retrieved.
118
- # @return [PokerAction] The last action taken.
116
+ # @param [Array<Array<AcpcPokerTypes::PokerAction>>] betting_sequence The betting sequence from which the last action should be retrieved.
117
+ # @return [AcpcPokerTypes::PokerAction] The last action taken.
119
118
  # @raise NoActionsHaveBeenTaken if no actions have been taken.
120
119
  def last_action(betting_sequence=@betting_sequence)
121
120
  if betting_sequence.nil? || betting_sequence.empty?
@@ -127,7 +126,7 @@ class MatchState
127
126
  end
128
127
  end
129
128
 
130
- # @return [Hand] The user's hole cards.
129
+ # @return [AcpcPokerTypes::Hand] The user's hole cards.
131
130
  # @example An ace of diamonds and a 4 of clubs is represented as
132
131
  # 'Ad4c'
133
132
  def users_hole_cards
@@ -136,7 +135,7 @@ class MatchState
136
135
 
137
136
  # @return [Array] The list of opponent hole cards that are visible.
138
137
  # @example If there are two opponents, one with AhKs and the other with QdJc, then
139
- # list_of_opponents_hole_cards == [AhKs:Hand, QdJc:Hand]
138
+ # list_of_opponents_hole_cards == [AhKs:AcpcPokerTypes::Hand, QdJc:AcpcPokerTypes::Hand]
140
139
  def list_of_opponents_hole_cards
141
140
  local_list_of_hole_card_hands = @list_of_hole_card_hands.dup
142
141
  local_list_of_hole_card_hands.delete_at @position_relative_to_dealer
@@ -209,7 +208,7 @@ class MatchState
209
208
  end
210
209
 
211
210
  def list_of_actions_from_acpc_characters(betting_sequence)
212
- all_actions = PokerAction::LEGAL_ACPC_CHARACTERS.to_a.join ''
211
+ all_actions = AcpcPokerTypes::PokerAction::LEGAL_ACPC_CHARACTERS.to_a.join ''
213
212
  betting_sequence.scan(/[#{all_actions}]\d*/)
214
213
  end
215
214
 
@@ -221,11 +220,11 @@ class MatchState
221
220
  def parse_list_of_hole_card_hands(string_of_hole_cards)
222
221
  list_of_hole_card_hands = []
223
222
  for_every_set_of_cards(string_of_hole_cards, '\|') do |string_hand|
224
- hand = Hand.from_acpc string_hand
223
+ hand = AcpcPokerTypes::Hand.from_acpc string_hand
225
224
  list_of_hole_card_hands.push hand
226
225
  end
227
226
  while list_of_hole_card_hands.length < (string_of_hole_cards.count('|') + 1)
228
- list_of_hole_card_hands.push Hand.new
227
+ list_of_hole_card_hands.push AcpcPokerTypes::Hand.new
229
228
  end
230
229
  list_of_hole_card_hands
231
230
  end
@@ -236,13 +235,13 @@ class MatchState
236
235
  list_of_actions_by_round = string_betting_sequence.split(/\//)
237
236
  betting_sequence = list_of_actions_by_round.inject([]) do |list_of_actions, betting_string_in_a_particular_round|
238
237
  list_of_actions_in_a_particular_round = list_of_actions_from_acpc_characters(betting_string_in_a_particular_round).inject([]) do |list, action|
239
- list.push PokerAction.new(action)
238
+ list.push AcpcPokerTypes::PokerAction.new(action)
240
239
  end
241
240
  list_of_actions.push list_of_actions_in_a_particular_round
242
241
  end
243
242
  # Increase the resolution of the last action
244
- # @todo I'm creating one too many PokerActions, but I'm not going to worry about it for now.
245
- betting_sequence[-1][-1] = PokerAction.new(
243
+ # @todo I'm creating one too many AcpcPokerTypes::PokerActions, but I'm not going to worry about it for now.
244
+ betting_sequence[-1][-1] = AcpcPokerTypes::PokerAction.new(
246
245
  last_action(betting_sequence).to_acpc_character,
247
246
  {
248
247
  amount_to_put_in_pot: last_action(betting_sequence).amount_to_put_in_pot,
@@ -259,7 +258,7 @@ class MatchState
259
258
  end
260
259
 
261
260
  def parse_board_cards(string_board_cards)
262
- board_cards = BoardCards.new
261
+ board_cards = AcpcPokerTypes::BoardCards.new
263
262
  for_every_set_of_cards(string_board_cards, '\/') do |string_board_card_set|
264
263
  next if string_board_card_set.match(/^\s*$/)
265
264
  for_every_card(string_board_card_set) do |card|
@@ -277,7 +276,7 @@ class MatchState
277
276
  end
278
277
 
279
278
  def for_every_card(string_of_cards)
280
- Card.cards(string_of_cards).each do |card|
279
+ AcpcPokerTypes::Card.cards(string_of_cards).each do |card|
281
280
  yield card
282
281
  end
283
282
  end