acpc_poker_types 6.2.3 → 7.0.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.rb +2 -2
- data/lib/acpc_poker_types/dealer_data.rb +9 -0
- data/lib/acpc_poker_types/{acpc_dealer_data → dealer_data}/action_messages.rb +10 -10
- data/lib/acpc_poker_types/{acpc_dealer_data → dealer_data}/hand_data.rb +4 -4
- data/lib/acpc_poker_types/{acpc_dealer_data → dealer_data}/hand_results.rb +8 -8
- data/lib/acpc_poker_types/{acpc_dealer_data → dealer_data}/log_file.rb +1 -1
- data/lib/acpc_poker_types/{acpc_dealer_data → dealer_data}/match_definition.rb +1 -1
- data/lib/acpc_poker_types/{acpc_dealer_data → dealer_data}/poker_match_data.rb +44 -56
- data/lib/acpc_poker_types/{player_group.rb → hand_player_group.rb} +1 -1
- data/lib/acpc_poker_types/match_state.rb +11 -8
- data/lib/acpc_poker_types/player.rb +50 -0
- data/lib/acpc_poker_types/players_at_the_table.rb +168 -0
- data/lib/acpc_poker_types/version.rb +1 -1
- data/spec/{action_messages_spec.rb → dealer_data/action_messages_spec.rb} +60 -61
- data/spec/{hand_data_spec.rb → dealer_data/hand_data_spec.rb} +26 -27
- data/spec/{hand_results_spec.rb → dealer_data/hand_results_spec.rb} +17 -18
- data/spec/{match_definition_spec.rb → dealer_data/match_definition_spec.rb} +10 -11
- data/spec/{poker_match_data_spec.rb → dealer_data/poker_match_data_spec.rb} +48 -7
- data/spec/{player_group_spec.rb → hand_player_group_spec.rb} +3 -10
- data/spec/hand_player_spec.rb +1 -1
- data/spec/match_state_spec.rb +118 -76
- data/spec/player_spec.rb +45 -0
- data/spec/players_at_the_table_spec.rb +133 -0
- metadata +60 -136
- data/lib/acpc_poker_types/acpc_dealer_data.rb +0 -9
- data/spec/coverage/assets/0.7.1/application.css +0 -1110
- data/spec/coverage/assets/0.7.1/application.js +0 -626
- data/spec/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
- data/spec/coverage/assets/0.7.1/favicon_green.png +0 -0
- data/spec/coverage/assets/0.7.1/favicon_red.png +0 -0
- data/spec/coverage/assets/0.7.1/favicon_yellow.png +0 -0
- data/spec/coverage/assets/0.7.1/loading.gif +0 -0
- data/spec/coverage/assets/0.7.1/magnify.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/coverage/index.html +0 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78f0bab62893fa563b2b696c90844c647533403e
|
4
|
+
data.tar.gz: 3462780103b206dd0c9b1952bb06d5e43760c24b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4418652bec1d5c84b867e72fabd230132fa50d14b64f6a4f4bf3ed68149f68f947aad717fd533b33e2ed61e49d3a0c5cd03d59e070e15bd832ac4a08e36a186f
|
7
|
+
data.tar.gz: ab329609151c04988b321aeb400b2c14a8b09b64722e172ce1438e683ddc2055769614cf857e8d5114e4782117fcdaf3c1b795735b64b896cb0155f2549f8a5d
|
data/lib/acpc_poker_types.rb
CHANGED
@@ -5,12 +5,12 @@ require "acpc_poker_types/card"
|
|
5
5
|
require "acpc_poker_types/chip_stack"
|
6
6
|
require "acpc_poker_types/game_definition"
|
7
7
|
require "acpc_poker_types/hand"
|
8
|
-
require 'acpc_poker_types/
|
8
|
+
require 'acpc_poker_types/hand_player_group'
|
9
9
|
require "acpc_poker_types/match_state"
|
10
10
|
require "acpc_poker_types/pile_of_cards"
|
11
11
|
require "acpc_poker_types/rank"
|
12
12
|
require "acpc_poker_types/suit"
|
13
|
-
require "acpc_poker_types/
|
13
|
+
require "acpc_poker_types/dealer_data"
|
14
14
|
require 'acpc_poker_types/seat'
|
15
15
|
|
16
16
|
module AcpcPokerTypes
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'acpc_poker_types/dealer_data/action_messages'
|
2
|
+
require 'acpc_poker_types/dealer_data/hand_data'
|
3
|
+
require 'acpc_poker_types/dealer_data/hand_results'
|
4
|
+
require 'acpc_poker_types/dealer_data/poker_match_data'
|
5
|
+
require 'acpc_poker_types/dealer_data/match_definition'
|
6
|
+
require 'acpc_poker_types/dealer_data/log_file'
|
7
|
+
|
8
|
+
module AcpcPokerTypes::DealerData
|
9
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'acpc_poker_types/match_state'
|
2
2
|
require 'acpc_poker_types/poker_action'
|
3
3
|
|
4
|
-
require 'acpc_poker_types/
|
5
|
-
require 'acpc_poker_types/
|
4
|
+
require 'acpc_poker_types/dealer_data/match_definition'
|
5
|
+
require 'acpc_poker_types/dealer_data/log_file'
|
6
6
|
|
7
|
-
module AcpcPokerTypes::
|
7
|
+
module AcpcPokerTypes::DealerData
|
8
8
|
class ActionMessages
|
9
9
|
attr_reader(
|
10
10
|
:data, :final_score, :match_def
|
@@ -73,9 +73,9 @@ module AcpcPokerTypes::AcpcDealerData
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def self.parse_to_or_from_message(message)
|
76
|
-
parsed_message = AcpcPokerTypes::
|
76
|
+
parsed_message = AcpcPokerTypes::DealerData::ActionMessages.parse_to_message(message)
|
77
77
|
if parsed_message.nil?
|
78
|
-
AcpcPokerTypes::
|
78
|
+
AcpcPokerTypes::DealerData::ActionMessages.parse_from_message(message)
|
79
79
|
else
|
80
80
|
parsed_message
|
81
81
|
end
|
@@ -87,8 +87,8 @@ module AcpcPokerTypes::AcpcDealerData
|
|
87
87
|
game_def_directory,
|
88
88
|
num_hands=nil
|
89
89
|
)
|
90
|
-
AcpcPokerTypes::
|
91
|
-
AcpcPokerTypes::
|
90
|
+
AcpcPokerTypes::DealerData::LogFile.open(acpc_log_file_path, 'r') do |file|
|
91
|
+
AcpcPokerTypes::DealerData::ActionMessages.parse file, player_names, game_def_directory, num_hands
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -104,9 +104,9 @@ module AcpcPokerTypes::AcpcDealerData
|
|
104
104
|
@match_def = nil
|
105
105
|
@data = acpc_log_statements.inject([]) do |accumulating_data, log_line|
|
106
106
|
if @match_def.nil?
|
107
|
-
@match_def = AcpcPokerTypes::
|
107
|
+
@match_def = AcpcPokerTypes::DealerData::MatchDefinition.parse(log_line, player_names, game_def_directory)
|
108
108
|
else
|
109
|
-
parsed_message = AcpcPokerTypes::
|
109
|
+
parsed_message = AcpcPokerTypes::DealerData::ActionMessages.parse_to_or_from_message(log_line)
|
110
110
|
if parsed_message
|
111
111
|
if (
|
112
112
|
accumulating_data.empty? ||
|
@@ -120,7 +120,7 @@ module AcpcPokerTypes::AcpcDealerData
|
|
120
120
|
end
|
121
121
|
accumulating_data.last << parsed_message
|
122
122
|
else
|
123
|
-
@final_score = AcpcPokerTypes::
|
123
|
+
@final_score = AcpcPokerTypes::DealerData::ActionMessages.parse_score(log_line) unless @final_score
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'acpc_poker_types/
|
1
|
+
require 'acpc_poker_types/dealer_data/match_definition'
|
2
2
|
|
3
3
|
require 'contextual_exceptions'
|
4
4
|
using ContextualExceptions::ClassRefinement
|
5
5
|
|
6
6
|
# Refinement for easy boundary checking
|
7
|
-
module AcpcPokerTypes::
|
7
|
+
module AcpcPokerTypes::DealerData
|
8
8
|
module BoundaryCheckingRefinement
|
9
9
|
refine Array do
|
10
10
|
def in_bounds?(i)
|
@@ -13,9 +13,9 @@ module AcpcPokerTypes::AcpcDealerData
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
|
-
using AcpcPokerTypes::
|
16
|
+
using AcpcPokerTypes::DealerData::BoundaryCheckingRefinement
|
17
17
|
|
18
|
-
module AcpcPokerTypes::
|
18
|
+
module AcpcPokerTypes::DealerData
|
19
19
|
class HandData
|
20
20
|
exceptions :invalid_data, :names_do_not_match
|
21
21
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'acpc_poker_types/
|
2
|
-
require 'acpc_poker_types/
|
1
|
+
require 'acpc_poker_types/dealer_data/match_definition'
|
2
|
+
require 'acpc_poker_types/dealer_data/log_file'
|
3
3
|
|
4
|
-
module AcpcPokerTypes::
|
4
|
+
module AcpcPokerTypes::DealerData
|
5
5
|
class HandResults
|
6
6
|
attr_reader :data, :final_score, :match_def
|
7
7
|
|
@@ -45,8 +45,8 @@ module AcpcPokerTypes::AcpcDealerData
|
|
45
45
|
game_def_directory,
|
46
46
|
num_hands=nil
|
47
47
|
)
|
48
|
-
AcpcPokerTypes::
|
49
|
-
AcpcPokerTypes::
|
48
|
+
AcpcPokerTypes::DealerData::LogFile.open(acpc_log_file_path, 'r') do |file|
|
49
|
+
AcpcPokerTypes::DealerData::HandResults.parse file, player_names, game_def_directory, num_hands
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -58,9 +58,9 @@ module AcpcPokerTypes::AcpcDealerData
|
|
58
58
|
|
59
59
|
@data = acpc_log_statements.inject([]) do |accumulating_data, log_line|
|
60
60
|
if @match_def.nil?
|
61
|
-
@match_def = AcpcPokerTypes::
|
61
|
+
@match_def = AcpcPokerTypes::DealerData::MatchDefinition.parse(log_line, player_names, game_def_directory)
|
62
62
|
else
|
63
|
-
parsed_message = AcpcPokerTypes::
|
63
|
+
parsed_message = AcpcPokerTypes::DealerData::HandResults.parse_state(log_line)
|
64
64
|
if parsed_message
|
65
65
|
# Yes, this causes one more result to be parsed than is saved as long as
|
66
66
|
# the number of hands is less than the total number in the log, but this
|
@@ -68,7 +68,7 @@ module AcpcPokerTypes::AcpcDealerData
|
|
68
68
|
break accumulating_data if accumulating_data.length == num_hands
|
69
69
|
accumulating_data << parsed_message
|
70
70
|
else
|
71
|
-
@final_score = AcpcPokerTypes::
|
71
|
+
@final_score = AcpcPokerTypes::DealerData::HandResults.parse_score(log_line) unless @final_score
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -5,7 +5,7 @@ require 'acpc_poker_types/game_definition'
|
|
5
5
|
require 'contextual_exceptions'
|
6
6
|
using ContextualExceptions::ClassRefinement
|
7
7
|
|
8
|
-
module AcpcPokerTypes::
|
8
|
+
module AcpcPokerTypes::DealerData
|
9
9
|
class MatchDefinition
|
10
10
|
|
11
11
|
exceptions :incorrect_number_of_player_names
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'celluloid/autostart'
|
2
2
|
|
3
|
-
require 'acpc_poker_types/
|
4
|
-
require 'acpc_poker_types/
|
5
|
-
require 'acpc_poker_types/
|
6
|
-
require 'acpc_poker_types/
|
3
|
+
require 'acpc_poker_types/dealer_data/action_messages'
|
4
|
+
require 'acpc_poker_types/dealer_data/hand_data'
|
5
|
+
require 'acpc_poker_types/dealer_data/hand_results'
|
6
|
+
require 'acpc_poker_types/dealer_data/match_definition'
|
7
7
|
|
8
8
|
require 'contextual_exceptions'
|
9
9
|
using ContextualExceptions::ClassRefinement
|
10
10
|
|
11
11
|
module AcpcPokerTypes
|
12
|
-
module
|
12
|
+
module DealerData
|
13
13
|
|
14
14
|
class PokerMatchData
|
15
15
|
exceptions :match_definitions_do_not_match, :final_scores_do_not_match, :data_inconsistent, :names_do_not_match
|
@@ -23,15 +23,15 @@ class PokerMatchData
|
|
23
23
|
:match_def,
|
24
24
|
# @returns [Integer] Zero-index turn number within the hand
|
25
25
|
:hand_number,
|
26
|
-
# @returns [
|
26
|
+
# @returns [DealerData::HandData] Data from each hand
|
27
27
|
:data,
|
28
|
-
# @returns [Array<
|
28
|
+
# @returns [Array<DealerData::PokerMatchData::Player>]
|
29
29
|
:players,
|
30
30
|
# @returns [Integer] Seat of the active player
|
31
31
|
:seat
|
32
32
|
)
|
33
33
|
|
34
|
-
# @returns [
|
34
|
+
# @returns [DealerData::PokerMatchData]
|
35
35
|
def self.parse_files(
|
36
36
|
action_messages_file,
|
37
37
|
result_messages_file,
|
@@ -40,7 +40,7 @@ class PokerMatchData
|
|
40
40
|
num_hands=nil
|
41
41
|
)
|
42
42
|
parsed_action_messages = Celluloid::Future.new do
|
43
|
-
|
43
|
+
DealerData::ActionMessages.parse_file(
|
44
44
|
action_messages_file,
|
45
45
|
player_names,
|
46
46
|
dealer_directory,
|
@@ -48,7 +48,7 @@ class PokerMatchData
|
|
48
48
|
)
|
49
49
|
end
|
50
50
|
parsed_hand_results = Celluloid::Future.new do
|
51
|
-
|
51
|
+
DealerData::HandResults.parse_file(
|
52
52
|
result_messages_file,
|
53
53
|
player_names,
|
54
54
|
dealer_directory,
|
@@ -64,7 +64,7 @@ class PokerMatchData
|
|
64
64
|
)
|
65
65
|
end
|
66
66
|
|
67
|
-
# @returns [
|
67
|
+
# @returns [DealerData::PokerMatchData]
|
68
68
|
def self.parse(
|
69
69
|
action_messages,
|
70
70
|
result_messages,
|
@@ -73,7 +73,7 @@ class PokerMatchData
|
|
73
73
|
num_hands=nil
|
74
74
|
)
|
75
75
|
parsed_action_messages = Celluloid::Future.new do
|
76
|
-
|
76
|
+
DealerData::ActionMessages.parse(
|
77
77
|
action_messages,
|
78
78
|
player_names,
|
79
79
|
dealer_directory,
|
@@ -81,7 +81,7 @@ class PokerMatchData
|
|
81
81
|
)
|
82
82
|
end
|
83
83
|
parsed_hand_results = Celluloid::Future.new do
|
84
|
-
|
84
|
+
DealerData::HandResults.parse(
|
85
85
|
result_messages,
|
86
86
|
player_names,
|
87
87
|
dealer_directory,
|
@@ -150,10 +150,15 @@ class PokerMatchData
|
|
150
150
|
self
|
151
151
|
end
|
152
152
|
|
153
|
-
def
|
153
|
+
def distribute_chips!
|
154
154
|
@players.each do |plyr|
|
155
155
|
plyr.balance += hand_player(plyr).balance
|
156
156
|
end
|
157
|
+
|
158
|
+
self
|
159
|
+
end
|
160
|
+
|
161
|
+
def end_hand!
|
157
162
|
current_hand.end_hand!
|
158
163
|
|
159
164
|
self
|
@@ -199,6 +204,8 @@ class PokerMatchData
|
|
199
204
|
match_state = current_hand.current_match_state(seat)
|
200
205
|
end
|
201
206
|
|
207
|
+
distribute_chips! if current_hand.final_turn?
|
208
|
+
|
202
209
|
self
|
203
210
|
end
|
204
211
|
|
@@ -211,11 +218,6 @@ class PokerMatchData
|
|
211
218
|
self
|
212
219
|
end
|
213
220
|
|
214
|
-
def match_has_another_round?(current_round, turn_index, turns_taken)
|
215
|
-
new_round?(current_round, turn_index) ||
|
216
|
-
players_all_in?(current_round, turn_index, turns_taken)
|
217
|
-
end
|
218
|
-
|
219
221
|
def hand_started?
|
220
222
|
@hand_number &&
|
221
223
|
current_hand.turn_number &&
|
@@ -223,22 +225,7 @@ class PokerMatchData
|
|
223
225
|
end
|
224
226
|
|
225
227
|
def player_acting_sequence
|
226
|
-
|
227
|
-
|
228
|
-
return sequence unless hand_started?
|
229
|
-
|
230
|
-
turns_taken = current_hand.data[0..current_hand.turn_number-1]
|
231
|
-
turns_taken.each_with_index do |turn, turn_index|
|
232
|
-
next unless turn.action_message
|
233
|
-
|
234
|
-
sequence[turn.action_message.state.round] ||= []
|
235
|
-
sequence[turn.action_message.state.round] << turn.action_message.seat
|
236
|
-
if match_has_another_round?(sequence.length - 1, turn_index, turns_taken)
|
237
|
-
sequence << []
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
sequence
|
228
|
+
sequence_from_action_messages(:seat)
|
242
229
|
end
|
243
230
|
|
244
231
|
def current_hand
|
@@ -273,7 +260,6 @@ class PokerMatchData
|
|
273
260
|
current_hand.current_match_state(plyr.seat).position_relative_to_dealer
|
274
261
|
end
|
275
262
|
|
276
|
-
# @todo Untested
|
277
263
|
# @return [String] player acting sequence as a string.
|
278
264
|
def player_acting_sequence_string
|
279
265
|
(player_acting_sequence.map { |per_round| per_round.join('') }).join('/')
|
@@ -283,39 +269,40 @@ class PokerMatchData
|
|
283
269
|
current_hand.next_action.seat == @seat
|
284
270
|
end
|
285
271
|
def betting_sequence
|
272
|
+
sequence_from_action_messages(:action)
|
273
|
+
end
|
274
|
+
def betting_sequence_string
|
275
|
+
(betting_sequence.map do |per_round|
|
276
|
+
(per_round.map{|action| action.to_acpc}).join('')
|
277
|
+
end).join('/')
|
278
|
+
end
|
279
|
+
|
280
|
+
protected
|
281
|
+
|
282
|
+
def sequence_from_action_messages(attribute)
|
286
283
|
sequence = [[]]
|
287
284
|
|
288
|
-
|
289
|
-
@hand_number.nil? ||
|
290
|
-
current_hand.turn_number.nil? ||
|
291
|
-
current_hand.turn_number < 1
|
292
|
-
)
|
293
|
-
return sequence
|
294
|
-
end
|
285
|
+
return sequence unless hand_started?
|
295
286
|
|
296
287
|
turns_taken = current_hand.data[0..current_hand.turn_number-1]
|
297
288
|
turns_taken.each_with_index do |turn, turn_index|
|
298
289
|
next unless turn.action_message
|
299
290
|
|
300
|
-
sequence[turn.action_message.state.round]
|
291
|
+
sequence[turn.action_message.state.round] ||= []
|
292
|
+
sequence[turn.action_message.state.round] << turn.action_message[attribute]
|
301
293
|
|
302
|
-
if (
|
303
|
-
new_round?(sequence.length - 1 , turn_index) ||
|
304
|
-
players_all_in?(sequence.length - 1, turn_index, turns_taken)
|
305
|
-
)
|
294
|
+
if new_round?(sequence.length - 1, turn_index)
|
306
295
|
sequence << []
|
307
296
|
end
|
297
|
+
if players_all_in?(sequence.length - 1, turn_index, turns_taken)
|
298
|
+
while sequence.length < @match_def.game_def.number_of_rounds
|
299
|
+
sequence << []
|
300
|
+
end
|
301
|
+
end
|
308
302
|
end
|
309
303
|
|
310
304
|
sequence
|
311
305
|
end
|
312
|
-
def betting_sequence_string
|
313
|
-
(betting_sequence.map do |per_round|
|
314
|
-
(per_round.map{|action| action.to_acpc}).join('')
|
315
|
-
end).join('/')
|
316
|
-
end
|
317
|
-
|
318
|
-
protected
|
319
306
|
|
320
307
|
def initialize_players!
|
321
308
|
@players = @match_def.player_names.length.times.map do |seat|
|
@@ -346,7 +333,7 @@ class PokerMatchData
|
|
346
333
|
def set_data!(parsed_action_messages, parsed_hand_results)
|
347
334
|
@data = []
|
348
335
|
parsed_action_messages.data.zip(parsed_hand_results.data).each do |action_messages_by_hand, hand_result|
|
349
|
-
@data <<
|
336
|
+
@data << DealerData::HandData.new(
|
350
337
|
@match_def,
|
351
338
|
action_messages_by_hand,
|
352
339
|
hand_result
|
@@ -365,6 +352,7 @@ class PokerMatchData
|
|
365
352
|
end) != @players.length - 1
|
366
353
|
end
|
367
354
|
def new_round?(current_round, turn_index)
|
355
|
+
current_hand &&
|
368
356
|
current_hand.data.length > turn_index + 1 &&
|
369
357
|
current_hand.data[turn_index + 1].action_message &&
|
370
358
|
current_hand.data[turn_index + 1].action_message.state.round > current_round
|
@@ -6,7 +6,7 @@ require 'acpc_poker_types/hand_player'
|
|
6
6
|
# Model to parse and manage information from a given match state string.
|
7
7
|
module AcpcPokerTypes
|
8
8
|
|
9
|
-
class
|
9
|
+
class HandPlayerGroup < DelegateClass(Array)
|
10
10
|
attr_reader :players
|
11
11
|
|
12
12
|
def initialize(all_hands, stacks, blinds)
|
@@ -4,7 +4,7 @@ require 'acpc_poker_types/rank'
|
|
4
4
|
require 'acpc_poker_types/suit'
|
5
5
|
require 'acpc_poker_types/poker_action'
|
6
6
|
require 'acpc_poker_types/hand_player'
|
7
|
-
require 'acpc_poker_types/
|
7
|
+
require 'acpc_poker_types/hand_player_group'
|
8
8
|
|
9
9
|
module AcpcPokerTypes
|
10
10
|
module Indices
|
@@ -144,7 +144,7 @@ class MatchState
|
|
144
144
|
@betting_sequence ||= if @betting_sequence_string.empty?
|
145
145
|
[[]]
|
146
146
|
else
|
147
|
-
|
147
|
+
sequence = @betting_sequence_string.split(
|
148
148
|
BETTING_SEQUENCE_SEPARATOR
|
149
149
|
).map do |betting_string_per_round|
|
150
150
|
actions_from_acpc_characters(betting_string_per_round).map do |action|
|
@@ -153,8 +153,10 @@ class MatchState
|
|
153
153
|
end
|
154
154
|
|
155
155
|
# Adjust the number of rounds if the last action was the last action in the round
|
156
|
-
|
157
|
-
|
156
|
+
while sequence.length <= round
|
157
|
+
sequence << []
|
158
|
+
end
|
159
|
+
sequence
|
158
160
|
end
|
159
161
|
end
|
160
162
|
|
@@ -251,14 +253,14 @@ class MatchState
|
|
251
253
|
|
252
254
|
# @param stacks [Array<#to_f>]
|
253
255
|
# @param blinds [Array<#to_f>]
|
254
|
-
# @return [
|
256
|
+
# @return [HandPlayerGroup] The state of the players in this hand at the
|
255
257
|
# when the hand began.
|
256
258
|
def players_at_hand_start(stacks, blinds)
|
257
|
-
|
259
|
+
HandPlayerGroup.new all_hands, stacks, blinds
|
258
260
|
end
|
259
261
|
|
260
262
|
# @param game_def [GameDefinition]
|
261
|
-
# @return [
|
263
|
+
# @return [HandPlayerGroup] The current state of the players.
|
262
264
|
def every_action(game_def)
|
263
265
|
@players = players_at_hand_start game_def.chip_stacks, game_def.blinds
|
264
266
|
|
@@ -293,7 +295,7 @@ class MatchState
|
|
293
295
|
def hand_ended?(game_def)
|
294
296
|
return @hand_ended unless @hand_ended.nil?
|
295
297
|
|
296
|
-
@hand_ended = reached_showdown? || players(game_def).count { |player| player.
|
298
|
+
@hand_ended = reached_showdown? || players(game_def).count { |player| player.folded? } >= number_of_players - 1
|
297
299
|
end
|
298
300
|
|
299
301
|
def reached_showdown?
|
@@ -321,6 +323,7 @@ class MatchState
|
|
321
323
|
|
322
324
|
def walk_over_betting_sequence!(game_def)
|
323
325
|
last_round = -1
|
326
|
+
|
324
327
|
betting_sequence.each_with_index do |actions_per_round, current_round|
|
325
328
|
@min_wager_by = game_def.min_wagers[current_round]
|
326
329
|
@next_to_act = @players.position_of_first_active_player(
|