acpc_dealer_data 0.3.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +2 -2
- data/acpc_dealer_data.gemspec +10 -8
- data/lib/acpc_dealer_data.rb +1 -0
- data/lib/acpc_dealer_data/action_messages.rb +32 -22
- data/lib/acpc_dealer_data/hand_data.rb +8 -8
- data/lib/acpc_dealer_data/hand_results.rb +20 -18
- data/lib/acpc_dealer_data/log_file.rb +3 -0
- data/lib/acpc_dealer_data/match_definition.rb +6 -10
- data/lib/acpc_dealer_data/poker_match_data.rb +73 -56
- data/lib/acpc_dealer_data/version.rb +2 -2
- data/spec/action_messages_spec.rb +79 -78
- data/spec/hand_data_spec.rb +34 -34
- data/spec/hand_results_spec.rb +20 -20
- data/spec/match_definition_spec.rb +24 -24
- data/spec/poker_match_data_spec.rb +156 -54
- data/spec/support/spec_helper.rb +14 -5
- metadata +78 -57
data/spec/hand_results_spec.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
|
2
2
|
# Spec helper (must include first to track code coverage with SimpleCov)
|
3
|
-
|
3
|
+
require_relative 'support/spec_helper'
|
4
4
|
|
5
|
-
require 'mocha'
|
5
|
+
require 'mocha/setup'
|
6
6
|
|
7
7
|
require 'acpc_dealer'
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
require 'acpc_dealer_data/hand_results'
|
10
|
+
require 'acpc_dealer_data/match_definition'
|
11
11
|
|
12
|
-
describe HandResults do
|
12
|
+
describe AcpcDealerData::HandResults do
|
13
13
|
before do
|
14
14
|
@patient = nil
|
15
15
|
@data = nil
|
@@ -23,7 +23,7 @@ describe HandResults do
|
|
23
23
|
it 'properly parses a ACPC log "STATE. . ." line' do
|
24
24
|
[
|
25
25
|
"STATE:0:rc/rrrrc/rc/crrrc:5d5c|9hQd/8dAs8s/4h/6d:28|-28:p1|p2\n" =>
|
26
|
-
{p1: 28, p2: -28},
|
26
|
+
{p1: 28, p2: -28},
|
27
27
|
"STATE:9:cc/cc/r165c/cc:4cKh|Kd7d/Ah9h9c/6s/Ks:0|0:p1|p2\n" =>
|
28
28
|
{p1: 0, p2: 0},
|
29
29
|
"STATE:18:rfrrc/cc/rrc/rrrrc:5d5c|9hQd|8dAs/8s4h6d/5s/Js:-5|-160|165:p1|p2|p3\n" =>
|
@@ -32,12 +32,12 @@ describe HandResults do
|
|
32
32
|
{p1: -20000, p2: -20000, p3: 40000}
|
33
33
|
].each do |state_to_player_results|
|
34
34
|
state_to_player_results.each do |state_string, expected_values|
|
35
|
-
HandResults.parse_state(state_string).must_equal expected_values
|
35
|
+
AcpcDealerData::HandResults.parse_state(state_string).must_equal expected_values
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
39
|
it 'returns nil if asked to parse an improperly formatted string' do
|
40
|
-
HandResults.parse_state("improperly formatted string").must_be_nil
|
40
|
+
AcpcDealerData::HandResults.parse_state("improperly formatted string").must_be_nil
|
41
41
|
end
|
42
42
|
end
|
43
43
|
describe '::parse_score' do
|
@@ -47,12 +47,12 @@ describe HandResults do
|
|
47
47
|
'SCORE:19835|621.5|-20455.5:p1|p2|p3' => {p1: 19835, p2: 621.5, p3: -20455.5}
|
48
48
|
].each do |score_to_player_results|
|
49
49
|
score_to_player_results.each do |score_string, expected_values|
|
50
|
-
HandResults.parse_score(score_string).must_equal expected_values
|
50
|
+
AcpcDealerData::HandResults.parse_score(score_string).must_equal expected_values
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
54
|
it 'returns nil if asked to parse an improperly formatted string' do
|
55
|
-
HandResults.parse_score("improperly formatted string").must_be_nil
|
55
|
+
AcpcDealerData::HandResults.parse_score("improperly formatted string").must_be_nil
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -61,17 +61,17 @@ describe HandResults do
|
|
61
61
|
it 'when every hand is desired' do
|
62
62
|
init_data do |log_statements|
|
63
63
|
file_name = 'file_name'
|
64
|
-
|
64
|
+
AcpcDealerData::LogFile.stubs(:open).with(file_name, 'r').yields(
|
65
65
|
log_statements
|
66
66
|
).returns(
|
67
|
-
HandResults.parse(
|
67
|
+
AcpcDealerData::HandResults.parse(
|
68
68
|
log_statements,
|
69
69
|
@player_names,
|
70
70
|
AcpcDealer::DEALER_DIRECTORY
|
71
71
|
)
|
72
72
|
)
|
73
73
|
|
74
|
-
@patient = HandResults.parse_file(
|
74
|
+
@patient = AcpcDealerData::HandResults.parse_file(
|
75
75
|
file_name,
|
76
76
|
@player_names,
|
77
77
|
AcpcDealer::DEALER_DIRECTORY
|
@@ -85,10 +85,10 @@ describe HandResults do
|
|
85
85
|
num_hands = 3
|
86
86
|
init_data do |log_statements|
|
87
87
|
file_name = 'file_name'
|
88
|
-
|
88
|
+
AcpcDealerData::LogFile.stubs(:open).with(file_name, 'r').yields(
|
89
89
|
log_statements
|
90
90
|
).returns(
|
91
|
-
HandResults.parse(
|
91
|
+
AcpcDealerData::HandResults.parse(
|
92
92
|
log_statements,
|
93
93
|
@player_names,
|
94
94
|
AcpcDealer::DEALER_DIRECTORY,
|
@@ -96,7 +96,7 @@ describe HandResults do
|
|
96
96
|
)
|
97
97
|
)
|
98
98
|
|
99
|
-
@patient = HandResults.parse_file(
|
99
|
+
@patient = AcpcDealerData::HandResults.parse_file(
|
100
100
|
file_name,
|
101
101
|
@player_names,
|
102
102
|
AcpcDealer::DEALER_DIRECTORY,
|
@@ -114,7 +114,7 @@ describe HandResults do
|
|
114
114
|
describe 'from array' do
|
115
115
|
it 'when every hand is desired' do
|
116
116
|
init_data do |log_statements|
|
117
|
-
@patient = HandResults.parse(
|
117
|
+
@patient = AcpcDealerData::HandResults.parse(
|
118
118
|
log_statements,
|
119
119
|
@player_names,
|
120
120
|
AcpcDealer::DEALER_DIRECTORY
|
@@ -127,7 +127,7 @@ describe HandResults do
|
|
127
127
|
@no_final_score = true
|
128
128
|
num_hands = 3
|
129
129
|
init_data do |log_statements|
|
130
|
-
@patient = HandResults.parse(
|
130
|
+
@patient = AcpcDealerData::HandResults.parse(
|
131
131
|
log_statements,
|
132
132
|
@player_names,
|
133
133
|
AcpcDealer::DEALER_DIRECTORY,
|
@@ -155,12 +155,12 @@ describe HandResults do
|
|
155
155
|
@final_score = data_hash[:final_score]
|
156
156
|
@data = data_hash[:data]
|
157
157
|
@player_names = data_hash[:player_names]
|
158
|
-
@match_def = MatchDefinition.parse(
|
158
|
+
@match_def = AcpcDealerData::MatchDefinition.parse(
|
159
159
|
data_hash[:log_statements].first,
|
160
160
|
@player_names,
|
161
161
|
AcpcDealer::DEALER_DIRECTORY
|
162
162
|
)
|
163
|
-
|
163
|
+
|
164
164
|
yield data_hash[:log_statements]
|
165
165
|
end
|
166
166
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
|
2
2
|
# Spec helper (must include first to track code coverage with SimpleCov)
|
3
|
-
|
3
|
+
require_relative 'support/spec_helper'
|
4
4
|
|
5
5
|
require 'acpc_poker_types/game_definition'
|
6
6
|
require 'acpc_dealer'
|
7
7
|
|
8
|
-
require
|
8
|
+
require 'acpc_dealer_data/match_definition'
|
9
9
|
|
10
|
-
describe MatchDefinition do
|
10
|
+
describe AcpcDealerData::MatchDefinition do
|
11
11
|
before do
|
12
12
|
@name = nil
|
13
13
|
@game_def = nil
|
@@ -20,53 +20,53 @@ describe MatchDefinition do
|
|
20
20
|
it 'raises an exception if the number of player names does not match the number of players' do
|
21
21
|
init_components do
|
22
22
|
->() do
|
23
|
-
@patient = MatchDefinition.new(
|
24
|
-
@name,
|
25
|
-
@game_def,
|
26
|
-
@number_of_hands,
|
27
|
-
@random_seed,
|
23
|
+
@patient = AcpcDealerData::MatchDefinition.new(
|
24
|
+
@name,
|
25
|
+
@game_def,
|
26
|
+
@number_of_hands,
|
27
|
+
@random_seed,
|
28
28
|
@player_names + ['extra player']
|
29
29
|
)
|
30
|
-
end.must_raise MatchDefinition::IncorrectNumberOfPlayerNames
|
30
|
+
end.must_raise AcpcDealerData::MatchDefinition::IncorrectNumberOfPlayerNames
|
31
31
|
|
32
32
|
->() do
|
33
|
-
@patient = MatchDefinition.new(
|
34
|
-
@name,
|
35
|
-
@game_def,
|
36
|
-
@number_of_hands,
|
37
|
-
@random_seed,
|
33
|
+
@patient = AcpcDealerData::MatchDefinition.new(
|
34
|
+
@name,
|
35
|
+
@game_def,
|
36
|
+
@number_of_hands,
|
37
|
+
@random_seed,
|
38
38
|
[@player_names.first]
|
39
39
|
)
|
40
|
-
end.must_raise MatchDefinition::IncorrectNumberOfPlayerNames
|
40
|
+
end.must_raise AcpcDealerData::MatchDefinition::IncorrectNumberOfPlayerNames
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe 'can be created by providing components' do
|
45
45
|
it 'separately' do
|
46
46
|
init_components do
|
47
|
-
@patient = MatchDefinition.new(
|
48
|
-
@name,
|
49
|
-
@game_def,
|
50
|
-
@number_of_hands,
|
51
|
-
@random_seed,
|
47
|
+
@patient = AcpcDealerData::MatchDefinition.new(
|
48
|
+
@name,
|
49
|
+
@game_def,
|
50
|
+
@number_of_hands,
|
51
|
+
@random_seed,
|
52
52
|
@player_names
|
53
53
|
)
|
54
|
-
|
54
|
+
|
55
55
|
check_patient
|
56
56
|
end
|
57
57
|
end
|
58
58
|
it 'in string format "# name/game/hands/seed ..."' do
|
59
59
|
init_components do
|
60
60
|
string = "# name/game/hands/seed #{@name} #{@game_def_file_name} #{@number_of_hands} #{@random_seed}\n"
|
61
|
-
@patient = MatchDefinition.parse(string, @player_names, File.dirname(@game_def_file_name))
|
62
|
-
|
61
|
+
@patient = AcpcDealerData::MatchDefinition.parse(string, @player_names, File.dirname(@game_def_file_name))
|
62
|
+
|
63
63
|
check_patient
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
67
|
it 'returns nil if asked to parse an improperly formatted string' do
|
68
68
|
string = 'improperly formatted string'
|
69
|
-
@patient = MatchDefinition.parse(string, ['p1', 'p2'], 'game def directory').must_be_nil
|
69
|
+
@patient = AcpcDealerData::MatchDefinition.parse(string, ['p1', 'p2'], 'game def directory').must_be_nil
|
70
70
|
end
|
71
71
|
|
72
72
|
def init_components
|
@@ -2,17 +2,17 @@
|
|
2
2
|
# Spec helper (must include first to track code coverage with SimpleCov)
|
3
3
|
require_relative 'support/spec_helper'
|
4
4
|
|
5
|
-
require 'mocha'
|
5
|
+
require 'mocha/setup'
|
6
6
|
|
7
7
|
require 'acpc_dealer'
|
8
8
|
require 'acpc_poker_types/match_state'
|
9
9
|
require 'acpc_poker_types/poker_action'
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
require 'acpc_dealer_data/hand_data'
|
12
|
+
require 'acpc_dealer_data/match_definition'
|
13
|
+
require 'acpc_dealer_data/poker_match_data'
|
14
14
|
|
15
|
-
describe PokerMatchData do
|
15
|
+
describe AcpcDealerData::PokerMatchData do
|
16
16
|
before do
|
17
17
|
@patient = nil
|
18
18
|
@chip_distribution = nil
|
@@ -28,70 +28,70 @@ describe PokerMatchData do
|
|
28
28
|
describe 'when given action and result messages' do
|
29
29
|
describe 'raises an exception if' do
|
30
30
|
it 'match definitions do not match' do
|
31
|
-
init_data do |action_messages, result_messages|
|
31
|
+
init_data! do |action_messages, result_messages|
|
32
32
|
new_action_messages = action_messages.dup
|
33
33
|
new_action_messages[@match_def_line_index] = '# name/game/hands/seed different_name holdem.limit.2p.reverse_blinds.game 2 0\n'
|
34
|
-
|
34
|
+
|
35
35
|
->() do
|
36
|
-
PokerMatchData.parse(
|
37
|
-
new_action_messages,
|
36
|
+
AcpcDealerData::PokerMatchData.parse(
|
37
|
+
new_action_messages,
|
38
38
|
result_messages,
|
39
39
|
@player_names,
|
40
40
|
AcpcDealer::DEALER_DIRECTORY
|
41
41
|
)
|
42
|
-
end.must_raise PokerMatchData::MatchDefinitionsDoNotMatch
|
42
|
+
end.must_raise AcpcDealerData::PokerMatchData::MatchDefinitionsDoNotMatch
|
43
43
|
|
44
44
|
new_result_messages = result_messages.dup
|
45
45
|
new_result_messages[@match_def_line_index] = '# name/game/hands/seed different_name holdem.limit.2p.reverse_blinds.game 2 0\n'
|
46
46
|
|
47
|
-
->() do
|
48
|
-
PokerMatchData.parse(
|
47
|
+
->() do
|
48
|
+
AcpcDealerData::PokerMatchData.parse(
|
49
49
|
action_messages,
|
50
50
|
new_result_messages,
|
51
51
|
@player_names,
|
52
52
|
AcpcDealer::DEALER_DIRECTORY
|
53
53
|
)
|
54
|
-
end.must_raise PokerMatchData::MatchDefinitionsDoNotMatch
|
54
|
+
end.must_raise AcpcDealerData::PokerMatchData::MatchDefinitionsDoNotMatch
|
55
55
|
end
|
56
56
|
end
|
57
57
|
it 'the final scores from each set of messages do not match' do
|
58
|
-
init_data do |action_messages, result_messages|
|
58
|
+
init_data! do |action_messages, result_messages|
|
59
59
|
new_action_messages = action_messages.dup
|
60
60
|
new_action_messages.pop
|
61
61
|
new_action_messages.pop
|
62
62
|
new_action_messages << 'SCORE:9001|-9001:p1|p2'
|
63
|
-
|
63
|
+
|
64
64
|
->() do
|
65
|
-
PokerMatchData.parse(
|
66
|
-
new_action_messages,
|
65
|
+
AcpcDealerData::PokerMatchData.parse(
|
66
|
+
new_action_messages,
|
67
67
|
result_messages,
|
68
68
|
@player_names,
|
69
69
|
AcpcDealer::DEALER_DIRECTORY
|
70
70
|
)
|
71
|
-
end.must_raise PokerMatchData::FinalScoresDoNotMatch
|
71
|
+
end.must_raise AcpcDealerData::PokerMatchData::FinalScoresDoNotMatch
|
72
72
|
|
73
73
|
new_result_messages = result_messages.dup
|
74
74
|
new_result_messages.pop
|
75
75
|
new_result_messages.pop
|
76
76
|
new_result_messages << 'SCORE:9001|-9001:p1|p2'
|
77
77
|
|
78
|
-
->() do
|
79
|
-
PokerMatchData.parse(
|
80
|
-
action_messages,
|
78
|
+
->() do
|
79
|
+
AcpcDealerData::PokerMatchData.parse(
|
80
|
+
action_messages,
|
81
81
|
new_result_messages,
|
82
82
|
@player_names,
|
83
83
|
AcpcDealer::DEALER_DIRECTORY
|
84
84
|
)
|
85
|
-
end.must_raise PokerMatchData::FinalScoresDoNotMatch
|
85
|
+
end.must_raise AcpcDealerData::PokerMatchData::FinalScoresDoNotMatch
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
89
89
|
describe 'works properly' do
|
90
90
|
it 'for every hand' do
|
91
|
-
init_data do |action_messages, result_messages|
|
91
|
+
init_data! do |action_messages, result_messages|
|
92
92
|
|
93
|
-
@patient = PokerMatchData.parse(
|
94
|
-
action_messages,
|
93
|
+
@patient = AcpcDealerData::PokerMatchData.parse(
|
94
|
+
action_messages,
|
95
95
|
result_messages,
|
96
96
|
@player_names,
|
97
97
|
AcpcDealer::DEALER_DIRECTORY
|
@@ -116,11 +116,11 @@ describe PokerMatchData do
|
|
116
116
|
it 'for a particular number of hands' do
|
117
117
|
num_hands = 1
|
118
118
|
@no_chip_distribution = true
|
119
|
-
init_data(num_hands) do |action_messages, result_messages|
|
119
|
+
init_data!(num_hands) do |action_messages, result_messages|
|
120
120
|
@chip_distribution = nil
|
121
121
|
|
122
|
-
@patient = PokerMatchData.parse(
|
123
|
-
action_messages,
|
122
|
+
@patient = AcpcDealerData::PokerMatchData.parse(
|
123
|
+
action_messages,
|
124
124
|
result_messages,
|
125
125
|
@player_names,
|
126
126
|
AcpcDealer::DEALER_DIRECTORY,
|
@@ -145,6 +145,94 @@ describe PokerMatchData do
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
end
|
148
|
+
describe '#player_acting_sequence' do
|
149
|
+
describe "doesn't append an empty array to the list when no players are active" do
|
150
|
+
it 'in two player' do
|
151
|
+
action_messages =
|
152
|
+
"# name/game/hands/seed 2p.limit.h1000.r0 holdem.limit.2p.reverse_blinds.game 1 0
|
153
|
+
#--t_response 600000
|
154
|
+
#--t_hand 600000
|
155
|
+
#--t_per_hand 7000
|
156
|
+
STARTED at 1341695999.222081
|
157
|
+
TO 1 at 1341695999.222281 MATCHSTATE:0:0::5d5c|
|
158
|
+
TO 2 at 1341695999.222349 MATCHSTATE:1:0::|9hQd
|
159
|
+
FROM 2 at 1341695999.222281 MATCHSTATE:0:0::5d5c|:c
|
160
|
+
TO 1 at 1341695999.222281 MATCHSTATE:0:0:c:5d5c|
|
161
|
+
TO 2 at 1341695999.222349 MATCHSTATE:1:0:c:|9hQd
|
162
|
+
FROM 1 at 1341695999.222349 MATCHSTATE:1:0:cr:|9hQd:r
|
163
|
+
TO 1 at 1341695999.222281 MATCHSTATE:0:0:cr:5d5c|
|
164
|
+
TO 2 at 1341695999.222349 MATCHSTATE:1:0:cr:|9hQd
|
165
|
+
FROM 2 at 1341695999.222281 MATCHSTATE:0:0:cr:5d5c:f
|
166
|
+
TO 1 at 1341695999.222281 MATCHSTATE:0:0:crf:5d5c|
|
167
|
+
TO 2 at 1341695999.222349 MATCHSTATE:1:0:crf:|9hQd
|
168
|
+
SCORE:-20|20:p1|p2".split("\n").map {|line| line += "\n" }
|
169
|
+
|
170
|
+
result_messages = [
|
171
|
+
"# name/game/hands/seed 2p.limit.h1000.r0 holdem.limit.2p.reverse_blinds.game 1 0\n",
|
172
|
+
"#--t_response 600000\n",
|
173
|
+
"#--t_hand 600000\n",
|
174
|
+
"#--t_per_hand 7000\n",
|
175
|
+
"STATE:0:crf:5d5c|9hQd:-20|20:p1|p2\n",
|
176
|
+
'SCORE:-20|20:p1|p2'
|
177
|
+
]
|
178
|
+
player_acting_sequence = [[1, 0, 1]]
|
179
|
+
@patient = AcpcDealerData::PokerMatchData.parse(
|
180
|
+
action_messages,
|
181
|
+
result_messages,
|
182
|
+
['p1', 'p2'],
|
183
|
+
AcpcDealer::DEALER_DIRECTORY
|
184
|
+
)
|
185
|
+
|
186
|
+
@patient.hand_number = 0
|
187
|
+
@patient.current_hand.turn_number = 3
|
188
|
+
@patient.player_acting_sequence.must_equal player_acting_sequence
|
189
|
+
end
|
190
|
+
it 'in three player' do
|
191
|
+
action_messages =
|
192
|
+
"# name/game/hands/seed 3p.limit.h1000.r0 holdem.limit.3p.game 1 0
|
193
|
+
#--t_response 600000
|
194
|
+
#--t_hand 600000
|
195
|
+
#--t_per_hand 7000
|
196
|
+
STARTED at 1341695999.222081
|
197
|
+
TO 1 at 1341695999.222281 MATCHSTATE:0:0::5d5c||
|
198
|
+
TO 2 at 1341695999.222349 MATCHSTATE:1:0::|9hQd|
|
199
|
+
TO 3 at 1341695999.222349 MATCHSTATE:3:0::||9cQh
|
200
|
+
FROM 1 at 1341695999.222281 MATCHSTATE:0:0::5d5c||:r
|
201
|
+
TO 1 at 1341695999.222281 MATCHSTATE:0:0:r:5d5c||
|
202
|
+
TO 2 at 1341695999.222349 MATCHSTATE:1:0:r:|9hQd|
|
203
|
+
TO 3 at 1341695999.222349 MATCHSTATE:3:0:r:||9cQh
|
204
|
+
FROM 2 at 1341695999.222349 MATCHSTATE:1:0:r:|9hQd|:f
|
205
|
+
TO 1 at 1341695999.222281 MATCHSTATE:0:0:rf:5d5c||
|
206
|
+
TO 2 at 1341695999.222349 MATCHSTATE:1:0:rf:|9hQd|
|
207
|
+
TO 3 at 1341695999.222349 MATCHSTATE:3:0:rf:||9cQh
|
208
|
+
FROM 3 at 1341695999.222349 MATCHSTATE:3:0:rf:||9cQh:f
|
209
|
+
TO 1 at 1341695999.222281 MATCHSTATE:0:0:rff:5d5c||
|
210
|
+
TO 2 at 1341695999.222349 MATCHSTATE:1:0:rff:|9hQd|
|
211
|
+
TO 3 at 1341695999.222349 MATCHSTATE:3:0:rff:||9cQh
|
212
|
+
SCORE:20|-20|-20:p1|p2|p3".split("\n").map {|line| line += "\n" }
|
213
|
+
|
214
|
+
result_messages = [
|
215
|
+
"# name/game/hands/seed 3p.limit.h1000.r0 holdem.limit.3p.game 1 0\n",
|
216
|
+
"#--t_response 600000\n",
|
217
|
+
"#--t_hand 600000\n",
|
218
|
+
"#--t_per_hand 7000\n",
|
219
|
+
"STATE:0:cff:5d5c|9hQd|9cQh:20|-20|-20:p1|p2|p3\n",
|
220
|
+
'SCORE:20|-20|-20:p1|p2|p3'
|
221
|
+
]
|
222
|
+
player_acting_sequence = [[0, 1, 2]]
|
223
|
+
@patient = AcpcDealerData::PokerMatchData.parse(
|
224
|
+
action_messages,
|
225
|
+
result_messages,
|
226
|
+
['p1', 'p2', 'p3'],
|
227
|
+
AcpcDealer::DEALER_DIRECTORY
|
228
|
+
)
|
229
|
+
|
230
|
+
@patient.hand_number = 0
|
231
|
+
@patient.current_hand.turn_number = 3
|
232
|
+
@patient.player_acting_sequence.must_equal player_acting_sequence
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
148
236
|
|
149
237
|
def check_patient
|
150
238
|
@patient.match_def.must_equal @match_def
|
@@ -155,42 +243,49 @@ describe PokerMatchData do
|
|
155
243
|
@patient.player_acting_sequence.must_equal @player_acting_sequences[@hand_number] if @turn_number + 1 == @hand_data_list[@hand_number].data.length
|
156
244
|
end
|
157
245
|
|
158
|
-
def init_data(num_hands=nil)
|
246
|
+
def init_data!(num_hands=nil)
|
159
247
|
data.each do |game, data_hash|
|
160
248
|
@chip_distribution = data_hash[:chip_distribution]
|
161
249
|
@match_def_line_index = data_hash[:match_def_line_index]
|
162
250
|
@player_names = data_hash[:player_names]
|
163
|
-
@match_def = MatchDefinition.parse(
|
251
|
+
@match_def = AcpcDealerData::MatchDefinition.parse(
|
164
252
|
data_hash[:result_messages][@match_def_line_index],
|
165
253
|
@player_names,
|
166
254
|
AcpcDealer::DEALER_DIRECTORY
|
167
255
|
)
|
168
|
-
|
169
|
-
data_hash[:action_messages],
|
170
|
-
@player_names,
|
171
|
-
AcpcDealer::DEALER_DIRECTORY,
|
172
|
-
num_hands
|
173
|
-
)
|
174
|
-
result_messages = HandResults.parse(
|
175
|
-
data_hash[:result_messages],
|
176
|
-
@player_names,
|
177
|
-
AcpcDealer::DEALER_DIRECTORY,
|
178
|
-
num_hands
|
179
|
-
)
|
180
|
-
|
181
|
-
@hand_data_list = []
|
182
|
-
action_messages.data.zip(result_messages.data).each do |action_messages_by_hand, hand_result|
|
183
|
-
@hand_data_list << HandData.new(
|
184
|
-
@match_def,
|
185
|
-
action_messages_by_hand,
|
186
|
-
hand_result
|
187
|
-
)
|
188
|
-
end
|
256
|
+
init_expected!(data_hash, num_hands, @match_def)
|
189
257
|
|
190
258
|
@player_acting_sequences = data_hash[:player_acting_sequences]
|
191
|
-
|
259
|
+
|
192
260
|
yield data_hash[:action_messages], data_hash[:result_messages]
|
193
261
|
end
|
262
|
+
self
|
263
|
+
end
|
264
|
+
|
265
|
+
def init_expected!(data_hash, num_hands=nil, match_def=@match_def)
|
266
|
+
action_messages = AcpcDealerData::ActionMessages.parse(
|
267
|
+
data_hash[:action_messages],
|
268
|
+
@player_names,
|
269
|
+
AcpcDealer::DEALER_DIRECTORY,
|
270
|
+
num_hands
|
271
|
+
)
|
272
|
+
result_messages = AcpcDealerData::HandResults.parse(
|
273
|
+
data_hash[:result_messages],
|
274
|
+
@player_names,
|
275
|
+
AcpcDealer::DEALER_DIRECTORY,
|
276
|
+
num_hands
|
277
|
+
)
|
278
|
+
|
279
|
+
@hand_data_list = []
|
280
|
+
action_messages.data.zip(result_messages.data)
|
281
|
+
.each do |action_messages_by_hand, hand_result|
|
282
|
+
@hand_data_list << AcpcDealerData::HandData.new(
|
283
|
+
match_def,
|
284
|
+
action_messages_by_hand,
|
285
|
+
hand_result
|
286
|
+
)
|
287
|
+
end
|
288
|
+
self
|
194
289
|
end
|
195
290
|
|
196
291
|
def data
|
@@ -265,7 +360,7 @@ describe PokerMatchData do
|
|
265
360
|
TO 2 at 1341695999.224329 MATCHSTATE:0:1:crc/rc/rrc/rc:6sKs|5dJd/2sTh2h/Qh/8h
|
266
361
|
FINISHED at 1341696000.058664
|
267
362
|
SCORE:110|-110:p1|p2
|
268
|
-
".split("\n").map { |line| line += "\n" },
|
363
|
+
".split("\n").map { |line| line += "\n" }, # Make each line an element in an array while preserving newlines
|
269
364
|
result_messages: [
|
270
365
|
"# name/game/hands/seed 2p.limit.h1000.r0 holdem.limit.2p.reverse_blinds.game 2 0\n",
|
271
366
|
"#--t_response 600000\n",
|
@@ -279,7 +374,14 @@ describe PokerMatchData do
|
|
279
374
|
match_def_line_index: 0,
|
280
375
|
player_names: ['p1', 'p2'],
|
281
376
|
chip_distribution: [110, -110],
|
282
|
-
player_acting_sequences: [
|
377
|
+
player_acting_sequences: [
|
378
|
+
[
|
379
|
+
[1, 0], [0, 1, 0], [0, 1], [0, 1]
|
380
|
+
],
|
381
|
+
[
|
382
|
+
[0, 1, 0], [1, 0], [1, 0, 1], [1, 0]
|
383
|
+
]
|
384
|
+
]
|
283
385
|
}
|
284
386
|
}
|
285
387
|
end
|