acpc_poker_types 7.5.1 → 7.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d18e6beaa53b55a84a197898627ecf4d3af23d7e
4
- data.tar.gz: 34df880a2fccadd74722f97cd0a2842c69526207
3
+ metadata.gz: ca0a2cfb399bc8392e1f76c85c4216ebb4408628
4
+ data.tar.gz: 083fbc027d582f2f2e293604917c6f160c1e032d
5
5
  SHA512:
6
- metadata.gz: 614ab04b2ef68d6fb7961173b48f92e3d8f10427aee1f5e25dca4ac165e33e9b5acfcb277d27a378688c2d2548dc5ca861da97c70dc2fb37af0614ff68a7b906
7
- data.tar.gz: e989357b69373ecff2a71de8407b995186c81677ccc42071345bc6c8fcf85ecce736d6a6a0633aee3d928e5a9ba5621ef59fb08a420f3f8310dbe12cd654cb9a
6
+ metadata.gz: b39bdef075cc8c4a75dfed7950bc63263097702e370195bd4a9f49ae6eb883ce85523dbbc4e19aaa4d183fea311f21e78ee124bf91392909de1e0474966a842c
7
+ data.tar.gz: c43b90c82a965b4847e0d6a4b1ce680534427682cacb9c5da499885c3c746abe9905efa80b5183798bea07ff422f1130d7f956d4a0a541c485c2aebf1cff74fa
@@ -57,6 +57,8 @@ class MatchState < DelegateClass(String)
57
57
 
58
58
  attr_reader :community_cards_string
59
59
 
60
+ attr_reader :winning_players
61
+
60
62
  # @return [String] Label for match state strings.
61
63
  LABEL = 'MATCHSTATE'
62
64
 
@@ -107,6 +109,7 @@ class MatchState < DelegateClass(String)
107
109
  @hands_string = $4
108
110
  @community_cards_string = $5
109
111
  end
112
+ @winning_players = nil
110
113
  @str = nil
111
114
  @all_hands = nil
112
115
  @community_cards = nil
@@ -323,6 +326,8 @@ class MatchState < DelegateClass(String)
323
326
 
324
327
  walk_over_betting_sequence!(game_def)
325
328
 
329
+ compute_winning_players!(game_def)
330
+
326
331
  distribute_chips!(game_def) if hand_ended?(game_def)
327
332
 
328
333
  @players
@@ -390,6 +395,17 @@ class MatchState < DelegateClass(String)
390
395
 
391
396
  private
392
397
 
398
+ def compute_winning_players!(game_def)
399
+ hand_strengths = players(game_def).map do |player|
400
+ if player.folded?
401
+ -1
402
+ else
403
+ PileOfCards.new(community_cards.flatten + player.hand).to_poker_hand_strength
404
+ end
405
+ end
406
+ @winning_players = hand_strengths.indices hand_strengths.max
407
+ end
408
+
393
409
  def walk_over_betting_sequence!(game_def)
394
410
  betting_sequence.each_with_index do |actions_per_round, current_round|
395
411
  init_new_round!(game_def, current_round)
@@ -465,23 +481,13 @@ class MatchState < DelegateClass(String)
465
481
  def distribute_chips!(game_def)
466
482
  return self if pot(game_def) <= 0
467
483
 
484
+ compute_winning_players!(game_def) unless @winning_players
485
+
468
486
  # @todo This only works for Doyle's game where there are no side-pots.
469
- if 1 == players(game_def).count { |player| !player.folded? }
470
- players(game_def).select { |player| !player.folded? }.first.winnings = pot(game_def)
471
- else
472
- hand_strengths = players(game_def).map do |player|
473
- if player.folded?
474
- -1
475
- else
476
- PileOfCards.new(community_cards.flatten + player.hand).to_poker_hand_strength
477
- end
478
- end
479
- winning_players = hand_strengths.indices(hand_strengths.max)
480
- amount_each_player_wins = pot(game_def)/winning_players.length.to_r
487
+ amount_each_player_wins = pot(game_def)/@winning_players.length.to_r
481
488
 
482
- winning_players.each do |player_index|
483
- @players[player_index].winnings = amount_each_player_wins
484
- end
489
+ @winning_players.each do |player_index|
490
+ @players[player_index].winnings = amount_each_player_wins
485
491
  end
486
492
 
487
493
  self
@@ -1,3 +1,3 @@
1
1
  module AcpcPokerTypes
2
- VERSION = '7.5.1'
2
+ VERSION = '7.6.0'
3
3
  end
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: 7.5.1
4
+ version: 7.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Morrill