acpc_poker_types 6.2.1 → 6.2.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e43b20038af9069a45fed735f016b7c3082a882d
4
- data.tar.gz: dbd1b22c8d6c84ad06f8560728084a000b6a61d3
3
+ metadata.gz: 61dde71cbe5078bb8420f94dc3205f3c5068d207
4
+ data.tar.gz: 539221fc8a9eded8eb4f67e3665f1c249d5d20fe
5
5
  SHA512:
6
- metadata.gz: 99611a882a44a52bdde8f0f3668cf90509735cb0cff5df8c35da7e4839e6b4b0b9a502c12e28ccef5e1f0c13706d65bbbf0e15062c812706888b62ad98ece0a3
7
- data.tar.gz: 3ecdf8af9868049c0b28eb332386172ff450d1ab5bce47e5a29086b99b33f156cee5359c09b1684b72e8e0ccd5859c62aa803f6f918693b7eb9eafed0e2ac3ce
6
+ metadata.gz: edcd59b6a50857689d793352d1ac4ce92d0940527e051ca1bb2d96cde5341f56e63a1a1390e1c264e56044fb9d514783e6a262a7df6067abbb466271b140411e
7
+ data.tar.gz: 3d645d72f22c5fdd38df91f9ae8c99b39c4b4584e99f02d9a21fd6c5dd0021ff268421f83ff6c4105df354be332f14d59b6053b55ad99f861ae3926919a8a83b
@@ -162,8 +162,8 @@ class MatchState
162
162
  def community_cards
163
163
  @community_cards ||= -> do
164
164
  lcl_community_cards = BoardCards.new(
165
- all_sets_of_community_cards(@community_cards_string).map do |cards_in_round|
166
- Card.cards(cards_in_round)
165
+ all_sets_of_community_cards(@community_cards_string).map do |cards_per_round|
166
+ Card.cards(cards_per_round)
167
167
  end
168
168
  )
169
169
  if lcl_community_cards.round < @community_cards_string.count(COMMUNITY_CARD_SEPARATOR)
@@ -262,39 +262,11 @@ class MatchState
262
262
  def every_action(game_def)
263
263
  @players = players_at_hand_start game_def.chip_stacks, game_def.blinds
264
264
 
265
- last_round = -1
266
265
  @next_to_act = game_def.first_player_positions.first
267
266
  @player_acting_sequence = []
268
267
  @min_wager_by = game_def.min_wagers.first
269
- every_action_token do |action, round|
270
- if round != last_round
271
- @min_wager_by = game_def.min_wagers[round]
272
- @next_to_act = @players.position_of_first_active_player(
273
- game_def.first_player_positions[round]
274
- )
275
- @player_acting_sequence << []
276
- last_round = round
277
- end
278
-
279
- @player_acting_sequence.last << @next_to_act
280
- acting_player_position = @player_acting_sequence.last.last
281
-
282
- @next_to_act = @players.next_to_act(@next_to_act)
283
268
 
284
- cost = @players.action_cost(
285
- acting_player_position,
286
- action,
287
- game_def.min_wagers[round]
288
- )
289
-
290
- action = PokerAction.new(action.to_s, cost: cost) if cost > 0
291
-
292
- adjust_min_wager!(action, acting_player_position)
293
-
294
- @players[acting_player_position].append_action!(action, round)
295
-
296
- yield action, round, acting_player_position, @players if block_given?
297
- end
269
+ walk_over_betting_sequence!(game_def)
298
270
 
299
271
  distribute_chips!(game_def) if hand_ended?(game_def)
300
272
 
@@ -347,6 +319,47 @@ class MatchState
347
319
 
348
320
  private
349
321
 
322
+ def walk_over_betting_sequence!(game_def)
323
+ last_round = -1
324
+ betting_sequence.each_with_index do |actions_per_round, current_round|
325
+ @min_wager_by = game_def.min_wagers[current_round]
326
+ @next_to_act = @players.position_of_first_active_player(
327
+ game_def.first_player_positions[current_round]
328
+ )
329
+ @player_acting_sequence << []
330
+ last_round = current_round
331
+
332
+ walk_over_actions!(actions_per_round, game_def, last_round, current_round)
333
+ end
334
+
335
+ self
336
+ end
337
+
338
+ def walk_over_actions!(actions_per_round, game_def, last_round, current_round)
339
+ actions_per_round.each do |action|
340
+ @player_acting_sequence.last << @next_to_act
341
+ acting_player_position = @player_acting_sequence.last.last
342
+
343
+ @next_to_act = @players.next_to_act(@next_to_act)
344
+
345
+ cost = @players.action_cost(
346
+ acting_player_position,
347
+ action,
348
+ game_def.min_wagers[current_round]
349
+ )
350
+
351
+ action = PokerAction.new(action.to_s, cost: cost) if cost > 0
352
+
353
+ adjust_min_wager!(action, acting_player_position)
354
+
355
+ @players[acting_player_position].append_action!(action, current_round)
356
+
357
+ yield action, current_round, acting_player_position if block_given?
358
+ end
359
+
360
+ self
361
+ end
362
+
350
363
  # Distribute chips to all winning players
351
364
  def distribute_chips!(game_def)
352
365
  return self if pot(game_def) <= 0
@@ -373,14 +386,6 @@ class MatchState
373
386
  self
374
387
  end
375
388
 
376
- def every_action_token
377
- betting_sequence.each_with_index do |actions_per_round, round|
378
- actions_per_round.each do |action|
379
- yield action, round if block_given?
380
- end
381
- end
382
- end
383
-
384
389
  def all_string_hands(string_of_card_sets)
385
390
  all_sets_of_cards(string_of_card_sets, HAND_SEPARATOR)
386
391
  end
@@ -22,7 +22,7 @@ class PlayerGroup < DelegateClass(Array)
22
22
  end
23
23
 
24
24
  def position_of_first_active_player(acting_player_position=0)
25
- raise NoPlayerCouldHaveActed if all? { |player| player.inactive? }
25
+ return nil if all? { |player| player.inactive? }
26
26
 
27
27
  # This must eventually exit because of the above assertion
28
28
  while @players[acting_player_position].inactive?
@@ -1,3 +1,3 @@
1
1
  module AcpcPokerTypes
2
- VERSION = '6.2.1'
2
+ VERSION = '6.2.2'
3
3
  end
@@ -816,6 +816,26 @@ describe MatchState do
816
816
  end
817
817
  end
818
818
  end
819
+ describe '#next_to_act' do
820
+ it 'works at the start of new rounds' do
821
+ wager_size = 10
822
+ x_game_def = GameDefinition.new(
823
+ first_player_positions: [1, 0, 0],
824
+ chip_stacks: [100, 200],
825
+ blinds: [0, 10],
826
+ raise_sizes: [wager_size]*3,
827
+ number_of_ranks: 3
828
+ )
829
+
830
+ (0..x_game_def.number_of_players-1).each do |position|
831
+ x_next_to_act = [0, 0]
832
+ patient = MatchState.new("#{MatchState::LABEL}:#{position}:0:cc/:5d5c|/8dAs8s")
833
+ patient.every_action(x_game_def) do
834
+ patient.next_to_act(x_game_def).must_equal x_next_to_act.shift
835
+ end
836
+ end
837
+ end
838
+ end
819
839
  end
820
840
 
821
841
  def for_every_card
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acpc_poker_types
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.1
4
+ version: 6.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Morrill