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
@@ -1,3 +1,3 @@
|
|
1
1
|
module AcpcDealerData
|
2
|
-
VERSION = "0.
|
3
|
-
end
|
2
|
+
VERSION = "1.0.0"
|
3
|
+
end
|
@@ -2,16 +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
|
-
|
11
|
+
require 'acpc_dealer_data/action_messages'
|
12
|
+
require 'acpc_dealer_data/match_definition'
|
13
|
+
require 'acpc_dealer_data/log_file'
|
13
14
|
|
14
|
-
describe ActionMessages do
|
15
|
+
describe AcpcDealerData::ActionMessages do
|
15
16
|
before do
|
16
17
|
@data = nil
|
17
18
|
@final_score = nil
|
@@ -25,33 +26,33 @@ describe ActionMessages do
|
|
25
26
|
it 'properly parses a ACPC log "TO . . ." line' do
|
26
27
|
[
|
27
28
|
"TO 1 at 1341695999.222281 MATCHSTATE:0:0::5d5c|\n" =>
|
28
|
-
ActionMessages::ToMessage.new(
|
29
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
29
30
|
0,
|
30
31
|
MatchState.parse('MATCHSTATE:0:0::5d5c|')
|
31
|
-
),
|
32
|
+
),
|
32
33
|
"TO 2 at 1341695920.914907 MATCHSTATE:1:0:r19686:|9hQd\n" =>
|
33
|
-
ActionMessages::ToMessage.new(
|
34
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
34
35
|
1,
|
35
36
|
MatchState.parse('MATCHSTATE:1:0:r19686:|9hQd')
|
36
37
|
),
|
37
38
|
"TO 3 at 1341696044.566738 MATCHSTATE:2:0:rf:||8dAs\n" =>
|
38
|
-
ActionMessages::ToMessage.new(
|
39
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
39
40
|
2,
|
40
41
|
MatchState.parse('MATCHSTATE:2:0:rf:||8dAs')
|
41
42
|
),
|
42
43
|
"TO 1 at 1341715418.808925 MATCHSTATE:0:0:fcr17162:5d5c||\n" =>
|
43
|
-
ActionMessages::ToMessage.new(
|
44
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
44
45
|
0,
|
45
46
|
MatchState.parse('MATCHSTATE:0:0:fcr17162:5d5c||')
|
46
47
|
)
|
47
48
|
].each do |to_message_to_data|
|
48
49
|
to_message_to_data.each do |to_message, expected_values|
|
49
|
-
ActionMessages.parse_to_message(to_message).must_equal expected_values
|
50
|
+
AcpcDealerData::ActionMessages.parse_to_message(to_message).must_equal expected_values
|
50
51
|
end
|
51
52
|
end
|
52
53
|
end
|
53
54
|
it 'returns nil if asked to parse an improperly formatted string' do
|
54
|
-
ActionMessages.parse_to_message("improperly formatted string").must_be_nil
|
55
|
+
AcpcDealerData::ActionMessages.parse_to_message("improperly formatted string").must_be_nil
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
@@ -59,37 +60,37 @@ describe ActionMessages do
|
|
59
60
|
it 'properly parses a ACPC log "FROM . . ." line' do
|
60
61
|
[
|
61
62
|
"FROM 2 at 1341695999.222410 MATCHSTATE:1:0::|9hQd:c\n" =>
|
62
|
-
ActionMessages::FromMessage.new(
|
63
|
-
1,
|
63
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
64
|
+
1,
|
64
65
|
MatchState.parse('MATCHSTATE:1:0::|9hQd'),
|
65
66
|
PokerAction.new('c')
|
66
67
|
),
|
67
68
|
"FROM 1 at 1341695920.914935 MATCHSTATE:0:0:r19686:5d5c|:r20000\n" =>
|
68
|
-
ActionMessages::FromMessage.new(
|
69
|
-
0,
|
70
|
-
MatchState.parse('MATCHSTATE:0:0:r19686:5d5c|'),
|
69
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
70
|
+
0,
|
71
|
+
MatchState.parse('MATCHSTATE:0:0:r19686:5d5c|'),
|
71
72
|
PokerAction.new('r20000')
|
72
73
|
),
|
73
74
|
"FROM 3 at 1341696044.566938 MATCHSTATE:2:0:rfr:||8dAs:r\n" =>
|
74
|
-
ActionMessages::FromMessage.new(
|
75
|
-
2,
|
76
|
-
MatchState.parse('MATCHSTATE:2:0:rfr:||8dAs'),
|
75
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
76
|
+
2,
|
77
|
+
MatchState.parse('MATCHSTATE:2:0:rfr:||8dAs'),
|
77
78
|
PokerAction.new('r')
|
78
79
|
),
|
79
80
|
"FROM 2 at 1341715418.808896 MATCHSTATE:1:0:fc:|9hQd|:r17162\n" =>
|
80
|
-
ActionMessages::FromMessage.new(
|
81
|
-
1,
|
82
|
-
MatchState.parse('MATCHSTATE:1:0:fc:|9hQd|'),
|
81
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
82
|
+
1,
|
83
|
+
MatchState.parse('MATCHSTATE:1:0:fc:|9hQd|'),
|
83
84
|
PokerAction.new('r17162')
|
84
85
|
)
|
85
86
|
].each do |from_message_to_data|
|
86
87
|
from_message_to_data.each do |from_message, expected_values|
|
87
|
-
ActionMessages.parse_from_message(from_message).must_equal expected_values
|
88
|
+
AcpcDealerData::ActionMessages.parse_from_message(from_message).must_equal expected_values
|
88
89
|
end
|
89
90
|
end
|
90
91
|
end
|
91
92
|
it 'returns nil if asked to parse an improperly formatted string' do
|
92
|
-
ActionMessages.parse_from_message("improperly formatted string").must_be_nil
|
93
|
+
AcpcDealerData::ActionMessages.parse_from_message("improperly formatted string").must_be_nil
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
@@ -100,12 +101,12 @@ describe ActionMessages do
|
|
100
101
|
'SCORE:19835|621.5|-20455.5:p1|p2|p3' => {p1: 19835, p2: 621.5, p3: -20455.5}
|
101
102
|
].each do |score_to_player_results|
|
102
103
|
score_to_player_results.each do |score_string, expected_values|
|
103
|
-
ActionMessages.parse_score(score_string).must_equal expected_values
|
104
|
+
AcpcDealerData::ActionMessages.parse_score(score_string).must_equal expected_values
|
104
105
|
end
|
105
106
|
end
|
106
107
|
end
|
107
108
|
it 'returns nil if asked to parse an improperly formatted string' do
|
108
|
-
ActionMessages.parse_score("improperly formatted string").must_be_nil
|
109
|
+
AcpcDealerData::ActionMessages.parse_score("improperly formatted string").must_be_nil
|
109
110
|
end
|
110
111
|
end
|
111
112
|
|
@@ -114,17 +115,17 @@ describe ActionMessages do
|
|
114
115
|
it 'when every hand is desired' do
|
115
116
|
init_data do |action_messages|
|
116
117
|
file_name = 'file_name'
|
117
|
-
|
118
|
+
AcpcDealerData::LogFile.expects(:open).with(file_name, 'r').yields(
|
118
119
|
action_messages
|
119
120
|
).returns(
|
120
|
-
ActionMessages.parse(
|
121
|
+
AcpcDealerData::ActionMessages.parse(
|
121
122
|
action_messages,
|
122
123
|
@player_names,
|
123
124
|
AcpcDealer::DEALER_DIRECTORY
|
124
125
|
)
|
125
126
|
)
|
126
127
|
|
127
|
-
@patient = ActionMessages.parse_file(
|
128
|
+
@patient = AcpcDealerData::ActionMessages.parse_file(
|
128
129
|
file_name,
|
129
130
|
@player_names,
|
130
131
|
AcpcDealer::DEALER_DIRECTORY
|
@@ -138,10 +139,10 @@ describe ActionMessages do
|
|
138
139
|
num_hands = 1
|
139
140
|
init_data do |action_messages|
|
140
141
|
file_name = 'file_name'
|
141
|
-
|
142
|
+
AcpcDealerData::LogFile.expects(:open).with(file_name, 'r').yields(
|
142
143
|
action_messages
|
143
144
|
).returns(
|
144
|
-
ActionMessages.parse(
|
145
|
+
AcpcDealerData::ActionMessages.parse(
|
145
146
|
action_messages,
|
146
147
|
@player_names,
|
147
148
|
AcpcDealer::DEALER_DIRECTORY,
|
@@ -149,7 +150,7 @@ describe ActionMessages do
|
|
149
150
|
)
|
150
151
|
)
|
151
152
|
|
152
|
-
@patient = ActionMessages.parse_file(
|
153
|
+
@patient = AcpcDealerData::ActionMessages.parse_file(
|
153
154
|
file_name,
|
154
155
|
@player_names,
|
155
156
|
AcpcDealer::DEALER_DIRECTORY,
|
@@ -167,7 +168,7 @@ describe ActionMessages do
|
|
167
168
|
describe 'from array' do
|
168
169
|
it 'when all hands are desired' do
|
169
170
|
init_data do |action_messages|
|
170
|
-
@patient = ActionMessages.parse(
|
171
|
+
@patient = AcpcDealerData::ActionMessages.parse(
|
171
172
|
action_messages,
|
172
173
|
@player_names,
|
173
174
|
AcpcDealer::DEALER_DIRECTORY
|
@@ -180,7 +181,7 @@ describe ActionMessages do
|
|
180
181
|
@no_final_score = true
|
181
182
|
num_hands = 1
|
182
183
|
init_data do |log_statements|
|
183
|
-
@patient = ActionMessages.parse(
|
184
|
+
@patient = AcpcDealerData::ActionMessages.parse(
|
184
185
|
log_statements,
|
185
186
|
@player_names,
|
186
187
|
AcpcDealer::DEALER_DIRECTORY,
|
@@ -199,7 +200,7 @@ describe ActionMessages do
|
|
199
200
|
|
200
201
|
def check_patient
|
201
202
|
@patient.data.must_equal @data
|
202
|
-
@patient.final_score.must_equal @final_score unless @no_final_score
|
203
|
+
@patient.final_score.must_equal @final_score unless @no_final_score
|
203
204
|
@patient.match_def.must_equal @match_def
|
204
205
|
end
|
205
206
|
|
@@ -208,12 +209,12 @@ describe ActionMessages do
|
|
208
209
|
@final_score = data_hash[:final_score]
|
209
210
|
@data = data_hash[:data]
|
210
211
|
@player_names = data_hash[:player_names]
|
211
|
-
@match_def = MatchDefinition.parse(
|
212
|
+
@match_def = AcpcDealerData::MatchDefinition.parse(
|
212
213
|
data_hash[:action_messages].first,
|
213
214
|
@player_names,
|
214
215
|
AcpcDealer::DEALER_DIRECTORY
|
215
216
|
)
|
216
|
-
|
217
|
+
|
217
218
|
yield data_hash[:action_messages]
|
218
219
|
end
|
219
220
|
end
|
@@ -236,39 +237,39 @@ describe ActionMessages do
|
|
236
237
|
],
|
237
238
|
data: [
|
238
239
|
[
|
239
|
-
ActionMessages::ToMessage.new(
|
240
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
240
241
|
0,
|
241
242
|
MatchState.parse('MATCHSTATE:1:998:crc/cc/cc/:|TdQd/As6d6h/7h/4s')
|
242
243
|
),
|
243
|
-
ActionMessages::ToMessage.new(
|
244
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
244
245
|
1,
|
245
246
|
MatchState.parse('MATCHSTATE:0:998:crc/cc/cc/:Jc8d|/As6d6h/7h/4s')
|
246
|
-
),
|
247
|
-
ActionMessages::FromMessage.new(
|
248
|
-
1,
|
247
|
+
),
|
248
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
249
|
+
1,
|
249
250
|
MatchState.parse('MATCHSTATE:0:998:crc/cc/cc/:Jc8d|/As6d6h/7h/4s'),
|
250
251
|
PokerAction.new('r')
|
251
252
|
)
|
252
253
|
],
|
253
254
|
[
|
254
|
-
ActionMessages::ToMessage.new(
|
255
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
255
256
|
0,
|
256
257
|
MatchState.parse('MATCHSTATE:1:999:crc/cc/cc/r:|TdQd/As6d6h/7h/4s')
|
257
258
|
),
|
258
|
-
ActionMessages::ToMessage.new(
|
259
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
259
260
|
1,
|
260
261
|
MatchState.parse('MATCHSTATE:0:999:crc/cc/cc/r:Jc8d|/As6d6h/7h/4s')
|
261
262
|
),
|
262
|
-
ActionMessages::FromMessage.new(
|
263
|
-
0,
|
263
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
264
|
+
0,
|
264
265
|
MatchState.parse('MATCHSTATE:1:999:crc/cc/cc/r:|TdQd/As6d6h/7h/4s'),
|
265
266
|
PokerAction.new('c')
|
266
267
|
),
|
267
|
-
ActionMessages::ToMessage.new(
|
268
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
268
269
|
0,
|
269
270
|
MatchState.parse('MATCHSTATE:1:999:crc/cc/cc/rc:Jc8d|TdQd/As6d6h/7h/4s')
|
270
271
|
),
|
271
|
-
ActionMessages::ToMessage.new(
|
272
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
272
273
|
1,
|
273
274
|
MatchState.parse('MATCHSTATE:0:999:crc/cc/cc/rc:Jc8d|TdQd/As6d6h/7h/4s')
|
274
275
|
)
|
@@ -295,47 +296,47 @@ describe ActionMessages do
|
|
295
296
|
],
|
296
297
|
data: [
|
297
298
|
[
|
298
|
-
ActionMessages::ToMessage.new(
|
299
|
-
0,
|
299
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
300
|
+
0,
|
300
301
|
MatchState.parse('MATCHSTATE:0:998:cc/r5841r19996r20000:Kc6h|/QhAh8d')
|
301
302
|
),
|
302
|
-
ActionMessages::ToMessage.new(
|
303
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
303
304
|
1,
|
304
305
|
MatchState.parse('MATCHSTATE:1:998:cc/r5841r19996r20000:|Qc3s/QhAh8d')
|
305
|
-
),
|
306
|
-
ActionMessages::FromMessage.new(
|
307
|
-
1,
|
306
|
+
),
|
307
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
308
|
+
1,
|
308
309
|
MatchState.parse('MATCHSTATE:1:998:cc/r5841r19996r20000:|Qc3s/QhAh8d:c'),
|
309
310
|
PokerAction.new('c')
|
310
311
|
),
|
311
|
-
ActionMessages::ToMessage.new(
|
312
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
312
313
|
0,
|
313
314
|
MatchState.parse('MATCHSTATE:0:998:cc/r5841r19996r20000c//:Kc6h|Qc3s/QhAh8d/Th/9d')
|
314
315
|
),
|
315
|
-
ActionMessages::ToMessage.new(
|
316
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
316
317
|
1,
|
317
318
|
MatchState.parse('MATCHSTATE:1:998:cc/r5841r19996r20000c//:Kc6h|Qc3s/QhAh8d/Th/9d')
|
318
319
|
)
|
319
320
|
],
|
320
321
|
[
|
321
|
-
ActionMessages::ToMessage.new(
|
322
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
322
323
|
0,
|
323
324
|
MatchState.parse('MATCHSTATE:1:999::|TdQd')
|
324
325
|
),
|
325
|
-
ActionMessages::ToMessage.new(
|
326
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
326
327
|
1,
|
327
328
|
MatchState.parse('MATCHSTATE:0:999::Jc8d|')
|
328
329
|
),
|
329
|
-
ActionMessages::FromMessage.new(
|
330
|
-
0,
|
330
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
331
|
+
0,
|
331
332
|
MatchState.parse('MATCHSTATE:1:999::|TdQd'),
|
332
333
|
PokerAction.new('f')
|
333
334
|
),
|
334
|
-
ActionMessages::ToMessage.new(
|
335
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
335
336
|
0,
|
336
337
|
MatchState.parse('MATCHSTATE:1:999:f:|TdQd')
|
337
338
|
),
|
338
|
-
ActionMessages::ToMessage.new(
|
339
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
339
340
|
1,
|
340
341
|
MatchState.parse('MATCHSTATE:0:999:f:Jc8d|')
|
341
342
|
)
|
@@ -359,32 +360,32 @@ describe ActionMessages do
|
|
359
360
|
],
|
360
361
|
data: [
|
361
362
|
[
|
362
|
-
ActionMessages::ToMessage.new(
|
363
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
363
364
|
0,
|
364
365
|
MatchState.parse('MATCHSTATE:0:999:ccc/ccc/rrcc/rrrfr:QsAs||/4d6d2d/5d/2c')
|
365
366
|
),
|
366
|
-
ActionMessages::ToMessage.new(
|
367
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
367
368
|
1,
|
368
369
|
MatchState.parse('MATCHSTATE:1:999:ccc/ccc/rrcc/rrrfr:|3s8h|/4d6d2d/5d/2c')
|
369
370
|
),
|
370
|
-
ActionMessages::ToMessage.new(
|
371
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
371
372
|
2,
|
372
373
|
MatchState.parse('MATCHSTATE:2:999:ccc/ccc/rrcc/rrrfr:||Qd3c/4d6d2d/5d/2c')
|
373
374
|
),
|
374
|
-
ActionMessages::FromMessage.new(
|
375
|
-
2,
|
375
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
376
|
+
2,
|
376
377
|
MatchState.parse('MATCHSTATE:2:999:ccc/ccc/rrcc/rrrfr:||Qd3c/4d6d2d/5d/2c'),
|
377
378
|
PokerAction.new('c')
|
378
379
|
),
|
379
|
-
ActionMessages::ToMessage.new(
|
380
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
380
381
|
0,
|
381
382
|
MatchState.parse('MATCHSTATE:0:999:ccc/ccc/rrcc/rrrfrc:QsAs|3s8h|Qd3c/4d6d2d/5d/2c')
|
382
383
|
),
|
383
|
-
ActionMessages::ToMessage.new(
|
384
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
384
385
|
1,
|
385
386
|
MatchState.parse('MATCHSTATE:1:999:ccc/ccc/rrcc/rrrfrc:|3s8h|Qd3c/4d6d2d/5d/2c')
|
386
387
|
),
|
387
|
-
ActionMessages::ToMessage.new(
|
388
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
388
389
|
2,
|
389
390
|
MatchState.parse('MATCHSTATE:2:999:ccc/ccc/rrcc/rrrfrc:|3s8h|Qd3c/4d6d2d/5d/2c')
|
390
391
|
)
|
@@ -408,34 +409,34 @@ describe ActionMessages do
|
|
408
409
|
],
|
409
410
|
data: [
|
410
411
|
[
|
411
|
-
ActionMessages::ToMessage.new(
|
412
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
412
413
|
0,
|
413
414
|
MatchState.parse('MATCHSTATE:0:998:ccr12926r20000c:QsAs||')
|
414
415
|
),
|
415
|
-
ActionMessages::ToMessage.new(
|
416
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
416
417
|
1,
|
417
418
|
MatchState.parse('MATCHSTATE:1:998:ccr12926r20000c:|3s8h|')
|
418
419
|
),
|
419
|
-
ActionMessages::ToMessage.new(
|
420
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
420
421
|
2,
|
421
422
|
MatchState.parse('MATCHSTATE:2:998:ccr12926r20000c:||Qd3c')
|
422
423
|
),
|
423
|
-
ActionMessages::FromMessage.new(
|
424
|
-
1,
|
424
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
425
|
+
1,
|
425
426
|
MatchState.parse('MATCHSTATE:1:998:ccr12926r20000c:|3s8h|'),
|
426
427
|
PokerAction.new('c')
|
427
428
|
)
|
428
429
|
],
|
429
430
|
[
|
430
|
-
ActionMessages::ToMessage.new(
|
431
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
431
432
|
0,
|
432
433
|
MatchState.parse('MATCHSTATE:0:999:ccr12926r20000cc///:QsAs|3s8h|Qd3c/4d6d2d/5d/2c')
|
433
434
|
),
|
434
|
-
ActionMessages::ToMessage.new(
|
435
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
435
436
|
1,
|
436
437
|
MatchState.parse('MATCHSTATE:1:999:ccr12926r20000cc///:QsAs|3s8h|Qd3c/4d6d2d/5d/2c')
|
437
438
|
),
|
438
|
-
ActionMessages::ToMessage.new(
|
439
|
+
AcpcDealerData::ActionMessages::ToMessage.new(
|
439
440
|
2,
|
440
441
|
MatchState.parse('MATCHSTATE:2:999:ccr12926r20000cc///:QsAs|3s8h|Qd3c/4d6d2d/5d/2c')
|
441
442
|
)
|
data/spec/hand_data_spec.rb
CHANGED
@@ -2,18 +2,18 @@
|
|
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
|
-
|
14
|
-
|
11
|
+
require 'acpc_dealer_data/action_messages'
|
12
|
+
require 'acpc_dealer_data/hand_data'
|
13
|
+
require 'acpc_dealer_data/hand_results'
|
14
|
+
require 'acpc_dealer_data/match_definition'
|
15
15
|
|
16
|
-
describe HandData do
|
16
|
+
describe AcpcDealerData::HandData do
|
17
17
|
before do
|
18
18
|
@patient = nil
|
19
19
|
@chip_distribution = nil
|
@@ -31,20 +31,20 @@ describe HandData do
|
|
31
31
|
describe 'raises an exception' do
|
32
32
|
it 'if the given action data does not have the proper format' do
|
33
33
|
init_data do |action_data, result|
|
34
|
-
->() do
|
35
|
-
@patient = HandData.new(
|
36
|
-
@match_def,
|
37
|
-
(action_data.data.first + [action_data.data.first.last]).flatten,
|
34
|
+
->() do
|
35
|
+
@patient = AcpcDealerData::HandData.new(
|
36
|
+
@match_def,
|
37
|
+
(action_data.data.first + [action_data.data.first.last]).flatten,
|
38
38
|
result.data.first
|
39
39
|
)
|
40
|
-
end.must_raise HandData::InvalidData
|
40
|
+
end.must_raise AcpcDealerData::HandData::InvalidData
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'reports the chip distribution for every seat' do
|
46
46
|
init_data do |action_data, result|
|
47
|
-
@patient = HandData.new @match_def, action_data.data.first, result.data.first
|
47
|
+
@patient = AcpcDealerData::HandData.new @match_def, action_data.data.first, result.data.first
|
48
48
|
|
49
49
|
check_patient
|
50
50
|
end
|
@@ -61,7 +61,7 @@ describe HandData do
|
|
61
61
|
@last_action = nil
|
62
62
|
@next_action = nil
|
63
63
|
|
64
|
-
@patient = HandData.new @match_def, action_data.data.first, result.data.first
|
64
|
+
@patient = AcpcDealerData::HandData.new @match_def, action_data.data.first, result.data.first
|
65
65
|
|
66
66
|
@turn_number = 0
|
67
67
|
@patient.for_every_turn!(@seat) do
|
@@ -98,18 +98,18 @@ describe HandData do
|
|
98
98
|
data.each do |game, data_hash|
|
99
99
|
@chip_distribution = data_hash[:chip_distribution]
|
100
100
|
@turn_data = data_hash[:turn_data]
|
101
|
-
@action_data = ActionMessages.parse(
|
101
|
+
@action_data = AcpcDealerData::ActionMessages.parse(
|
102
102
|
data_hash[:action_messages],
|
103
103
|
data_hash[:player_names],
|
104
104
|
AcpcDealer::DEALER_DIRECTORY
|
105
105
|
)
|
106
|
-
@hand_result = HandResults.parse(
|
106
|
+
@hand_result = AcpcDealerData::HandResults.parse(
|
107
107
|
data_hash[:result_message],
|
108
108
|
data_hash[:player_names],
|
109
109
|
AcpcDealer::DEALER_DIRECTORY
|
110
110
|
)
|
111
111
|
@match_def = @hand_result.match_def
|
112
|
-
|
112
|
+
|
113
113
|
yield @action_data, @hand_result
|
114
114
|
end
|
115
115
|
end
|
@@ -137,29 +137,29 @@ describe HandData do
|
|
137
137
|
chip_distribution: [60, -60],
|
138
138
|
player_names: ['p1', 'p2'],
|
139
139
|
turn_data: [
|
140
|
-
HandData::Turn.new(
|
140
|
+
AcpcDealerData::HandData::Turn.new(
|
141
141
|
[
|
142
142
|
MatchState.parse('MATCHSTATE:1:999:crc/cc/cc/:|TdQd/As6d6h/7h/4s'),
|
143
143
|
MatchState.parse('MATCHSTATE:0:999:crc/cc/cc/:Jc8d|/As6d6h/7h/4s')
|
144
144
|
],
|
145
|
-
ActionMessages::FromMessage.new(
|
146
|
-
1,
|
145
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
146
|
+
1,
|
147
147
|
MatchState.parse('MATCHSTATE:0:999:crc/cc/cc/:Jc8d|/As6d6h/7h/4s'),
|
148
148
|
PokerAction.new('r')
|
149
149
|
)
|
150
150
|
),
|
151
|
-
HandData::Turn.new(
|
151
|
+
AcpcDealerData::HandData::Turn.new(
|
152
152
|
[
|
153
153
|
MatchState.parse('MATCHSTATE:1:999:crc/cc/cc/r:|TdQd/As6d6h/7h/4s'),
|
154
154
|
MatchState.parse('MATCHSTATE:0:999:crc/cc/cc/r:Jc8d|/As6d6h/7h/4s')
|
155
155
|
],
|
156
|
-
ActionMessages::FromMessage.new(
|
157
|
-
0,
|
156
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
157
|
+
0,
|
158
158
|
MatchState.parse('MATCHSTATE:1:999:crc/cc/cc/r:|TdQd/As6d6h/7h/4s'),
|
159
159
|
PokerAction.new('c')
|
160
160
|
)
|
161
161
|
),
|
162
|
-
HandData::Turn.new(
|
162
|
+
AcpcDealerData::HandData::Turn.new(
|
163
163
|
[
|
164
164
|
MatchState.parse('MATCHSTATE:1:999:crc/cc/cc/rc:Jc8d|TdQd/As6d6h/7h/4s'),
|
165
165
|
MatchState.parse('MATCHSTATE:0:999:crc/cc/cc/rc:Jc8d|TdQd/As6d6h/7h/4s')
|
@@ -186,18 +186,18 @@ describe HandData do
|
|
186
186
|
chip_distribution: [19718, -19718],
|
187
187
|
player_names: ['p1', 'p2'],
|
188
188
|
turn_data: [
|
189
|
-
HandData::Turn.new(
|
189
|
+
AcpcDealerData::HandData::Turn.new(
|
190
190
|
[
|
191
191
|
MatchState.parse('MATCHSTATE:1:999::|TdQd'),
|
192
192
|
MatchState.parse('MATCHSTATE:0:999::Jc8d|')
|
193
193
|
],
|
194
|
-
ActionMessages::FromMessage.new(
|
195
|
-
0,
|
194
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
195
|
+
0,
|
196
196
|
MatchState.parse('MATCHSTATE:1:999::|TdQd'),
|
197
197
|
PokerAction.new('f')
|
198
198
|
)
|
199
199
|
),
|
200
|
-
HandData::Turn.new(
|
200
|
+
AcpcDealerData::HandData::Turn.new(
|
201
201
|
[
|
202
202
|
MatchState.parse('MATCHSTATE:1:999:f:|TdQd'),
|
203
203
|
MatchState.parse('MATCHSTATE:0:999:f:Jc8d|')
|
@@ -226,19 +226,19 @@ describe HandData do
|
|
226
226
|
chip_distribution: [360, -190, -170],
|
227
227
|
player_names: ['p1', 'p2', 'p3'],
|
228
228
|
turn_data: [
|
229
|
-
HandData::Turn.new(
|
229
|
+
AcpcDealerData::HandData::Turn.new(
|
230
230
|
[
|
231
231
|
MatchState.parse('MATCHSTATE:0:999:ccc/ccc/rrcc/rrrfr:QsAs||/4d6d2d/5d/2c'),
|
232
232
|
MatchState.parse('MATCHSTATE:1:999:ccc/ccc/rrcc/rrrfr:|3s8h|/4d6d2d/5d/2c'),
|
233
233
|
MatchState.parse('MATCHSTATE:2:999:ccc/ccc/rrcc/rrrfr:||Qd3c/4d6d2d/5d/2c')
|
234
234
|
],
|
235
|
-
ActionMessages::FromMessage.new(
|
236
|
-
2,
|
235
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
236
|
+
2,
|
237
237
|
MatchState.parse('MATCHSTATE:2:999:ccc/ccc/rrcc/rrrfr:||Qd3c/4d6d2d/5d/2c'),
|
238
238
|
PokerAction.new('c')
|
239
239
|
)
|
240
240
|
),
|
241
|
-
HandData::Turn.new(
|
241
|
+
AcpcDealerData::HandData::Turn.new(
|
242
242
|
[
|
243
243
|
MatchState.parse('MATCHSTATE:0:999:ccc/ccc/rrcc/rrrfrc:QsAs|3s8h|Qd3c/4d6d2d/5d/2c'),
|
244
244
|
MatchState.parse('MATCHSTATE:1:999:ccc/ccc/rrcc/rrrfrc:|3s8h|Qd3c/4d6d2d/5d/2c'),
|
@@ -268,19 +268,19 @@ describe HandData do
|
|
268
268
|
chip_distribution: [40000, -20000, -20000],
|
269
269
|
player_names: ['p1', 'p2', 'p3'],
|
270
270
|
turn_data: [
|
271
|
-
HandData::Turn.new(
|
271
|
+
AcpcDealerData::HandData::Turn.new(
|
272
272
|
[
|
273
273
|
MatchState.parse('MATCHSTATE:0:999:ccr12926r20000c:QsAs||'),
|
274
274
|
MatchState.parse('MATCHSTATE:1:999:ccr12926r20000c:|3s8h|'),
|
275
275
|
MatchState.parse('MATCHSTATE:2:999:ccr12926r20000c:||Qd3c')
|
276
276
|
],
|
277
|
-
ActionMessages::FromMessage.new(
|
277
|
+
AcpcDealerData::ActionMessages::FromMessage.new(
|
278
278
|
1,
|
279
279
|
MatchState.parse('MATCHSTATE:1:999:ccr12926r20000c:|3s8h|'),
|
280
280
|
PokerAction.new('c')
|
281
281
|
)
|
282
282
|
),
|
283
|
-
HandData::Turn.new(
|
283
|
+
AcpcDealerData::HandData::Turn.new(
|
284
284
|
[
|
285
285
|
MatchState.parse('MATCHSTATE:0:999:ccr12926r20000cc///:QsAs|3s8h|Qd3c/4d6d2d/5d/2c'),
|
286
286
|
MatchState.parse('MATCHSTATE:1:999:ccr12926r20000cc///:QsAs|3s8h|Qd3c/4d6d2d/5d/2c'),
|