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 +4 -4
- data/lib/acpc_poker_types/match_state.rb +21 -15
- data/lib/acpc_poker_types/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca0a2cfb399bc8392e1f76c85c4216ebb4408628
|
4
|
+
data.tar.gz: 083fbc027d582f2f2e293604917c6f160c1e032d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
483
|
-
|
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
|