acpc_poker_types 0.0.10 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +7 -4
- data/acpc_poker_types.gemspec +4 -2
- data/lib/acpc_poker_types.rb +13 -12
- data/lib/acpc_poker_types/acpc_dealer_data.rb +9 -0
- data/lib/acpc_poker_types/acpc_dealer_data/action_messages.rb +133 -0
- data/lib/acpc_poker_types/acpc_dealer_data/hand_data.rb +182 -0
- data/lib/acpc_poker_types/acpc_dealer_data/hand_results.rb +79 -0
- data/lib/acpc_poker_types/acpc_dealer_data/log_file.rb +5 -0
- data/lib/acpc_poker_types/acpc_dealer_data/match_definition.rb +54 -0
- data/lib/acpc_poker_types/acpc_dealer_data/poker_match_data.rb +393 -0
- data/lib/acpc_poker_types/board_cards.rb +4 -4
- data/lib/acpc_poker_types/card.rb +16 -16
- data/lib/acpc_poker_types/chip_stack.rb +1 -1
- data/lib/acpc_poker_types/game_definition.rb +34 -38
- data/lib/acpc_poker_types/hand.rb +5 -5
- data/lib/acpc_poker_types/match_state.rb +31 -32
- data/lib/acpc_poker_types/pile_of_cards.rb +1 -1
- data/lib/acpc_poker_types/player.rb +16 -15
- data/lib/acpc_poker_types/poker_action.rb +6 -6
- data/lib/acpc_poker_types/rank.rb +2 -2
- data/lib/acpc_poker_types/suit.rb +4 -4
- data/lib/acpc_poker_types/version.rb +1 -1
- data/spec/action_messages_spec.rb +450 -0
- data/spec/board_cards_spec.rb +9 -9
- data/spec/card_spec.rb +20 -20
- data/spec/chip_stack_spec.rb +28 -29
- data/spec/game_definition_spec.rb +11 -11
- data/spec/hand_data_spec.rb +295 -0
- data/spec/hand_results_spec.rb +292 -0
- data/spec/hand_spec.rb +11 -11
- data/spec/match_definition_spec.rb +95 -0
- data/spec/match_state_spec.rb +105 -287
- data/spec/pile_of_cards_spec.rb +14 -14
- data/spec/player_spec.rb +61 -61
- data/spec/poker_action_spec.rb +49 -49
- data/spec/poker_match_data_spec.rb +388 -0
- data/spec/rank_spec.rb +19 -19
- data/spec/suit_spec.rb +19 -19
- data/spec/support/spec_helper.rb +28 -6
- metadata +55 -10
@@ -0,0 +1,388 @@
|
|
1
|
+
|
2
|
+
# Spec helper (must include first to track code coverage with SimpleCov)
|
3
|
+
require_relative 'support/spec_helper'
|
4
|
+
|
5
|
+
require 'mocha/setup'
|
6
|
+
|
7
|
+
require 'acpc_dealer'
|
8
|
+
require 'acpc_poker_types/match_state'
|
9
|
+
require 'acpc_poker_types/poker_action'
|
10
|
+
|
11
|
+
require 'acpc_poker_types/acpc_dealer_data/hand_data'
|
12
|
+
require 'acpc_poker_types/acpc_dealer_data/match_definition'
|
13
|
+
require 'acpc_poker_types/acpc_dealer_data/poker_match_data'
|
14
|
+
|
15
|
+
describe AcpcPokerTypes::AcpcDealerData::PokerMatchData do
|
16
|
+
before do
|
17
|
+
@patient = nil
|
18
|
+
@chip_distribution = nil
|
19
|
+
@match_def = nil
|
20
|
+
@match_def_line_index = nil
|
21
|
+
@player_names = nil
|
22
|
+
@hand_number = nil
|
23
|
+
@hand_data_list = nil
|
24
|
+
@final_hand = nil
|
25
|
+
@no_chip_distribution = false
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'when given action and result messages' do
|
29
|
+
describe 'raises an exception if' do
|
30
|
+
it 'match definitions do not match' do
|
31
|
+
init_data! do |action_messages, result_messages|
|
32
|
+
new_action_messages = action_messages.dup
|
33
|
+
new_action_messages[@match_def_line_index] = '# name/game/hands/seed different_name holdem.limit.2p.reverse_blinds.game 2 0\n'
|
34
|
+
|
35
|
+
->() do
|
36
|
+
AcpcPokerTypes::AcpcDealerData::PokerMatchData.parse(
|
37
|
+
new_action_messages,
|
38
|
+
result_messages,
|
39
|
+
@player_names,
|
40
|
+
AcpcDealer::DEALER_DIRECTORY
|
41
|
+
)
|
42
|
+
end.must_raise AcpcPokerTypes::AcpcDealerData::PokerMatchData::MatchDefinitionsDoNotMatch
|
43
|
+
|
44
|
+
new_result_messages = result_messages.dup
|
45
|
+
new_result_messages[@match_def_line_index] = '# name/game/hands/seed different_name holdem.limit.2p.reverse_blinds.game 2 0\n'
|
46
|
+
|
47
|
+
->() do
|
48
|
+
AcpcPokerTypes::AcpcDealerData::PokerMatchData.parse(
|
49
|
+
action_messages,
|
50
|
+
new_result_messages,
|
51
|
+
@player_names,
|
52
|
+
AcpcDealer::DEALER_DIRECTORY
|
53
|
+
)
|
54
|
+
end.must_raise AcpcPokerTypes::AcpcDealerData::PokerMatchData::MatchDefinitionsDoNotMatch
|
55
|
+
end
|
56
|
+
end
|
57
|
+
it 'the final scores from each set of messages do not match' do
|
58
|
+
init_data! do |action_messages, result_messages|
|
59
|
+
new_action_messages = action_messages.dup
|
60
|
+
new_action_messages.pop
|
61
|
+
new_action_messages.pop
|
62
|
+
new_action_messages << 'SCORE:9001|-9001:p1|p2'
|
63
|
+
|
64
|
+
->() do
|
65
|
+
AcpcPokerTypes::AcpcDealerData::PokerMatchData.parse(
|
66
|
+
new_action_messages,
|
67
|
+
result_messages,
|
68
|
+
@player_names,
|
69
|
+
AcpcDealer::DEALER_DIRECTORY
|
70
|
+
)
|
71
|
+
end.must_raise AcpcPokerTypes::AcpcDealerData::PokerMatchData::FinalScoresDoNotMatch
|
72
|
+
|
73
|
+
new_result_messages = result_messages.dup
|
74
|
+
new_result_messages.pop
|
75
|
+
new_result_messages.pop
|
76
|
+
new_result_messages << 'SCORE:9001|-9001:p1|p2'
|
77
|
+
|
78
|
+
->() do
|
79
|
+
AcpcPokerTypes::AcpcDealerData::PokerMatchData.parse(
|
80
|
+
action_messages,
|
81
|
+
new_result_messages,
|
82
|
+
@player_names,
|
83
|
+
AcpcDealer::DEALER_DIRECTORY
|
84
|
+
)
|
85
|
+
end.must_raise AcpcPokerTypes::AcpcDealerData::PokerMatchData::FinalScoresDoNotMatch
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
describe 'works properly' do
|
90
|
+
it 'for every hand' do
|
91
|
+
init_data! do |action_messages, result_messages|
|
92
|
+
|
93
|
+
@patient = AcpcPokerTypes::AcpcDealerData::PokerMatchData.parse(
|
94
|
+
action_messages,
|
95
|
+
result_messages,
|
96
|
+
@player_names,
|
97
|
+
AcpcDealer::DEALER_DIRECTORY
|
98
|
+
)
|
99
|
+
@patient.seat = 0
|
100
|
+
|
101
|
+
@hand_number = 0
|
102
|
+
@patient.for_every_hand! do
|
103
|
+
@turn_number = 0
|
104
|
+
|
105
|
+
@final_hand = @hand_number >= @hand_data_list.length - 1
|
106
|
+
@patient.for_every_turn! do
|
107
|
+
check_patient
|
108
|
+
|
109
|
+
@turn_number += 1
|
110
|
+
end
|
111
|
+
|
112
|
+
@hand_number += 1
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
it 'for a particular number of hands' do
|
117
|
+
num_hands = 1
|
118
|
+
@no_chip_distribution = true
|
119
|
+
init_data!(num_hands) do |action_messages, result_messages|
|
120
|
+
@chip_distribution = nil
|
121
|
+
|
122
|
+
@patient = AcpcPokerTypes::AcpcDealerData::PokerMatchData.parse(
|
123
|
+
action_messages,
|
124
|
+
result_messages,
|
125
|
+
@player_names,
|
126
|
+
AcpcDealer::DEALER_DIRECTORY,
|
127
|
+
num_hands
|
128
|
+
)
|
129
|
+
@patient.seat = 0
|
130
|
+
|
131
|
+
@hand_number = 0
|
132
|
+
@patient.for_every_hand! do
|
133
|
+
@turn_number = 0
|
134
|
+
|
135
|
+
@final_hand = @hand_number >= @hand_data_list.length - 1
|
136
|
+
@patient.for_every_turn! do
|
137
|
+
check_patient
|
138
|
+
|
139
|
+
@turn_number += 1
|
140
|
+
end
|
141
|
+
|
142
|
+
@hand_number += 1
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
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 = AcpcPokerTypes::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 = AcpcPokerTypes::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
|
236
|
+
|
237
|
+
def check_patient
|
238
|
+
@patient.match_def.must_equal @match_def
|
239
|
+
@patient.chip_distribution.must_equal @chip_distribution unless @no_chip_distribution
|
240
|
+
@patient.hand_number.must_equal @hand_number
|
241
|
+
@patient.current_hand.must_equal @hand_data_list[@hand_number]
|
242
|
+
@patient.final_hand?.must_equal @final_hand
|
243
|
+
@patient.player_acting_sequence.must_equal @player_acting_sequences[@hand_number] if @turn_number + 1 == @hand_data_list[@hand_number].data.length
|
244
|
+
end
|
245
|
+
|
246
|
+
def init_data!(num_hands=nil)
|
247
|
+
data.each do |game, data_hash|
|
248
|
+
@chip_distribution = data_hash[:chip_distribution]
|
249
|
+
@match_def_line_index = data_hash[:match_def_line_index]
|
250
|
+
@player_names = data_hash[:player_names]
|
251
|
+
@match_def = AcpcPokerTypes::AcpcDealerData::MatchDefinition.parse(
|
252
|
+
data_hash[:result_messages][@match_def_line_index],
|
253
|
+
@player_names,
|
254
|
+
AcpcDealer::DEALER_DIRECTORY
|
255
|
+
)
|
256
|
+
init_expected!(data_hash, num_hands, @match_def)
|
257
|
+
|
258
|
+
@player_acting_sequences = data_hash[:player_acting_sequences]
|
259
|
+
|
260
|
+
yield data_hash[:action_messages], data_hash[:result_messages]
|
261
|
+
end
|
262
|
+
self
|
263
|
+
end
|
264
|
+
|
265
|
+
def init_expected!(data_hash, num_hands=nil, match_def=@match_def)
|
266
|
+
action_messages = AcpcPokerTypes::AcpcDealerData::ActionMessages.parse(
|
267
|
+
data_hash[:action_messages],
|
268
|
+
@player_names,
|
269
|
+
AcpcDealer::DEALER_DIRECTORY,
|
270
|
+
num_hands
|
271
|
+
)
|
272
|
+
result_messages = AcpcPokerTypes::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 << AcpcPokerTypes::AcpcDealerData::HandData.new(
|
283
|
+
match_def,
|
284
|
+
action_messages_by_hand,
|
285
|
+
hand_result
|
286
|
+
)
|
287
|
+
end
|
288
|
+
self
|
289
|
+
end
|
290
|
+
|
291
|
+
def data
|
292
|
+
{
|
293
|
+
two_player_limit: {
|
294
|
+
action_messages:
|
295
|
+
"# name/game/hands/seed 2p.limit.h1000.r0 holdem.limit.2p.reverse_blinds.game 2 0
|
296
|
+
#--t_response 600000
|
297
|
+
#--t_hand 600000
|
298
|
+
#--t_per_hand 7000
|
299
|
+
STARTED at 1341695999.222081
|
300
|
+
TO 1 at 1341695999.222281 MATCHSTATE:0:0::5d5c|
|
301
|
+
TO 2 at 1341695999.222349 MATCHSTATE:1:0::|9hQd
|
302
|
+
FROM 2 at 1341695999.222410 MATCHSTATE:1:0::|9hQd:c
|
303
|
+
TO 1 at 1341695999.222450 MATCHSTATE:0:0:c:5d5c|
|
304
|
+
TO 2 at 1341695999.222496 MATCHSTATE:1:0:c:|9hQd
|
305
|
+
FROM 1 at 1341695999.222519 MATCHSTATE:0:0:c:5d5c|:c
|
306
|
+
TO 1 at 1341695999.222546 MATCHSTATE:0:0:cc/:5d5c|/8dAs8s
|
307
|
+
TO 2 at 1341695999.222583 MATCHSTATE:1:0:cc/:|9hQd/8dAs8s
|
308
|
+
FROM 1 at 1341695999.222605 MATCHSTATE:0:0:cc/:5d5c|/8dAs8s:c
|
309
|
+
TO 1 at 1341695999.222633 MATCHSTATE:0:0:cc/c:5d5c|/8dAs8s
|
310
|
+
TO 2 at 1341695999.222664 MATCHSTATE:1:0:cc/c:|9hQd/8dAs8s
|
311
|
+
FROM 2 at 1341695999.222704 MATCHSTATE:1:0:cc/c:|9hQd/8dAs8s:r
|
312
|
+
TO 1 at 1341695999.222734 MATCHSTATE:0:0:cc/cr:5d5c|/8dAs8s
|
313
|
+
TO 2 at 1341695999.222770 MATCHSTATE:1:0:cc/cr:|9hQd/8dAs8s
|
314
|
+
FROM 1 at 1341695999.222792 MATCHSTATE:0:0:cc/cr:5d5c|/8dAs8s:c
|
315
|
+
TO 1 at 1341695999.222820 MATCHSTATE:0:0:cc/crc/:5d5c|/8dAs8s/4h
|
316
|
+
TO 2 at 1341695999.222879 MATCHSTATE:1:0:cc/crc/:|9hQd/8dAs8s/4h
|
317
|
+
FROM 1 at 1341695999.222904 MATCHSTATE:0:0:cc/crc/:5d5c|/8dAs8s/4h:c
|
318
|
+
TO 1 at 1341695999.222932 MATCHSTATE:0:0:cc/crc/c:5d5c|/8dAs8s/4h
|
319
|
+
TO 2 at 1341695999.222964 MATCHSTATE:1:0:cc/crc/c:|9hQd/8dAs8s/4h
|
320
|
+
FROM 2 at 1341695999.223004 MATCHSTATE:1:0:cc/crc/c:|9hQd/8dAs8s/4h:c
|
321
|
+
TO 1 at 1341695999.223033 MATCHSTATE:0:0:cc/crc/cc/:5d5c|/8dAs8s/4h/6d
|
322
|
+
TO 2 at 1341695999.223069 MATCHSTATE:1:0:cc/crc/cc/:|9hQd/8dAs8s/4h/6d
|
323
|
+
FROM 1 at 1341695999.223091 MATCHSTATE:0:0:cc/crc/cc/:5d5c|/8dAs8s/4h/6d:c
|
324
|
+
TO 1 at 1341695999.223118 MATCHSTATE:0:0:cc/crc/cc/c:5d5c|/8dAs8s/4h/6d
|
325
|
+
TO 2 at 1341695999.223150 MATCHSTATE:1:0:cc/crc/cc/c:|9hQd/8dAs8s/4h/6d
|
326
|
+
FROM 2 at 1341695999.223189 MATCHSTATE:1:0:cc/crc/cc/c:|9hQd/8dAs8s/4h/6d:c
|
327
|
+
TO 1 at 1341695999.223272 MATCHSTATE:0:0:cc/crc/cc/cc:5d5c|9hQd/8dAs8s/4h/6d
|
328
|
+
TO 2 at 1341695999.223307 MATCHSTATE:1:0:cc/crc/cc/cc:5d5c|9hQd/8dAs8s/4h/6d
|
329
|
+
TO 1 at 1341695999.223333 MATCHSTATE:1:1::|5dJd
|
330
|
+
TO 2 at 1341695999.223366 MATCHSTATE:0:1::6sKs|
|
331
|
+
FROM 1 at 1341695999.223388 MATCHSTATE:1:1::|5dJd:c
|
332
|
+
TO 1 at 1341695999.223415 MATCHSTATE:1:1:c:|5dJd
|
333
|
+
TO 2 at 1341695999.223446 MATCHSTATE:0:1:c:6sKs|
|
334
|
+
FROM 2 at 1341695999.223485 MATCHSTATE:0:1:c:6sKs|:r
|
335
|
+
TO 1 at 1341695999.223513 MATCHSTATE:1:1:cr:|5dJd
|
336
|
+
TO 2 at 1341695999.223548 MATCHSTATE:0:1:cr:6sKs|
|
337
|
+
FROM 1 at 1341695999.223570 MATCHSTATE:1:1:cr:|5dJd:c
|
338
|
+
TO 1 at 1341695999.223596 MATCHSTATE:1:1:crc/:|5dJd/2sTh2h
|
339
|
+
TO 2 at 1341695999.223627 MATCHSTATE:0:1:crc/:6sKs|/2sTh2h
|
340
|
+
FROM 2 at 1341695999.223664 MATCHSTATE:0:1:crc/:6sKs|/2sTh2h:r
|
341
|
+
TO 1 at 1341695999.223692 MATCHSTATE:1:1:crc/r:|5dJd/2sTh2h
|
342
|
+
TO 2 at 1341695999.223728 MATCHSTATE:0:1:crc/r:6sKs|/2sTh2h
|
343
|
+
FROM 1 at 1341695999.223749 MATCHSTATE:1:1:crc/r:|5dJd/2sTh2h:c
|
344
|
+
TO 1 at 1341695999.223776 MATCHSTATE:1:1:crc/rc/:|5dJd/2sTh2h/Qh
|
345
|
+
TO 2 at 1341695999.223807 MATCHSTATE:0:1:crc/rc/:6sKs|/2sTh2h/Qh
|
346
|
+
FROM 2 at 1341695999.223863 MATCHSTATE:0:1:crc/rc/:6sKs|/2sTh2h/Qh:r
|
347
|
+
TO 1 at 1341695999.223897 MATCHSTATE:1:1:crc/rc/r:|5dJd/2sTh2h/Qh
|
348
|
+
TO 2 at 1341695999.223934 MATCHSTATE:0:1:crc/rc/r:6sKs|/2sTh2h/Qh
|
349
|
+
FROM 1 at 1341695999.223956 MATCHSTATE:1:1:crc/rc/r:|5dJd/2sTh2h/Qh:r
|
350
|
+
TO 1 at 1341695999.223984 MATCHSTATE:1:1:crc/rc/rr:|5dJd/2sTh2h/Qh
|
351
|
+
TO 2 at 1341695999.224015 MATCHSTATE:0:1:crc/rc/rr:6sKs|/2sTh2h/Qh
|
352
|
+
FROM 2 at 1341695999.224053 MATCHSTATE:0:1:crc/rc/rr:6sKs|/2sTh2h/Qh:c
|
353
|
+
TO 1 at 1341695999.224081 MATCHSTATE:1:1:crc/rc/rrc/:|5dJd/2sTh2h/Qh/8h
|
354
|
+
TO 2 at 1341695999.224114 MATCHSTATE:0:1:crc/rc/rrc/:6sKs|/2sTh2h/Qh/8h
|
355
|
+
FROM 2 at 1341695999.224149 MATCHSTATE:0:1:crc/rc/rrc/:6sKs|/2sTh2h/Qh/8h:r
|
356
|
+
TO 1 at 1341695999.224178 MATCHSTATE:1:1:crc/rc/rrc/r:|5dJd/2sTh2h/Qh/8h
|
357
|
+
TO 2 at 1341695999.224213 MATCHSTATE:0:1:crc/rc/rrc/r:6sKs|/2sTh2h/Qh/8h
|
358
|
+
FROM 1 at 1341695999.224235 MATCHSTATE:1:1:crc/rc/rrc/r:|5dJd/2sTh2h/Qh/8h:c
|
359
|
+
TO 1 at 1341695999.224292 MATCHSTATE:1:1:crc/rc/rrc/rc:6sKs|5dJd/2sTh2h/Qh/8h
|
360
|
+
TO 2 at 1341695999.224329 MATCHSTATE:0:1:crc/rc/rrc/rc:6sKs|5dJd/2sTh2h/Qh/8h
|
361
|
+
FINISHED at 1341696000.058664
|
362
|
+
SCORE:110|-110:p1|p2
|
363
|
+
".split("\n").map { |line| line += "\n" }, # Make each line an element in an array while preserving newlines
|
364
|
+
result_messages: [
|
365
|
+
"# name/game/hands/seed 2p.limit.h1000.r0 holdem.limit.2p.reverse_blinds.game 2 0\n",
|
366
|
+
"#--t_response 600000\n",
|
367
|
+
"#--t_hand 600000\n",
|
368
|
+
"#--t_per_hand 7000\n",
|
369
|
+
"STATE:0:cc/crc/cc/cc:5d5c|9hQd/8dAs8s/4h/6d:20|-20:p1|p2\n",
|
370
|
+
"STATE:1:crc/rc/rrc/rc:6sKs|5dJd/2sTh2h/Qh/8h:-90|90:p2|p1\n",
|
371
|
+
'SCORE:110|-110:p1|p2'
|
372
|
+
],
|
373
|
+
hand_start_line_indices: [6, 35],
|
374
|
+
match_def_line_index: 0,
|
375
|
+
player_names: ['p1', 'p2'],
|
376
|
+
chip_distribution: [110, -110],
|
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
|
+
]
|
385
|
+
}
|
386
|
+
}
|
387
|
+
end
|
388
|
+
end
|
data/spec/rank_spec.rb
CHANGED
@@ -2,46 +2,46 @@
|
|
2
2
|
# Spec helper (must include first to track code coverage with SimpleCov)
|
3
3
|
require File.expand_path('../support/spec_helper', __FILE__)
|
4
4
|
|
5
|
-
require "
|
5
|
+
require "acpc_poker_types/rank"
|
6
6
|
|
7
|
-
describe Rank do
|
7
|
+
describe AcpcPokerTypes::Rank do
|
8
8
|
describe '#new' do
|
9
9
|
it 'raises an exception if the given rank is invalid' do
|
10
|
-
|
10
|
+
->{AcpcPokerTypes::Rank.new(:not_a_rank)}.must_raise(AcpcPokerTypes::Rank::UnrecognizedRank)
|
11
11
|
end
|
12
12
|
describe 'correctly understands all ranks' do
|
13
13
|
it 'in symbol form' do
|
14
14
|
for_every_rank do
|
15
|
-
@patient = Rank.new(@symbol)
|
16
|
-
|
15
|
+
@patient = AcpcPokerTypes::Rank.new(@symbol)
|
16
|
+
|
17
17
|
check_patient!
|
18
18
|
end
|
19
19
|
end
|
20
20
|
it 'in ACPC form' do
|
21
21
|
for_every_rank do
|
22
|
-
@patient = Rank.new(@acpc)
|
23
|
-
|
22
|
+
@patient = AcpcPokerTypes::Rank.new(@acpc)
|
23
|
+
|
24
24
|
check_patient!
|
25
25
|
end
|
26
26
|
end
|
27
27
|
it 'in numeric ACPC form' do
|
28
28
|
for_every_rank do
|
29
|
-
@patient = Rank.new(@number)
|
30
|
-
|
29
|
+
@patient = AcpcPokerTypes::Rank.new(@number)
|
30
|
+
|
31
31
|
check_patient!
|
32
32
|
end
|
33
33
|
end
|
34
34
|
it 'in HTML form' do
|
35
35
|
for_every_rank do
|
36
|
-
@patient = Rank.new(@html)
|
37
|
-
|
36
|
+
@patient = AcpcPokerTypes::Rank.new(@html)
|
37
|
+
|
38
38
|
check_patient!
|
39
39
|
end
|
40
40
|
end
|
41
41
|
it 'in string form' do
|
42
42
|
for_every_rank do
|
43
|
-
@patient = Rank.new(@string)
|
44
|
-
|
43
|
+
@patient = AcpcPokerTypes::Rank.new(@string)
|
44
|
+
|
45
45
|
check_patient!
|
46
46
|
end
|
47
47
|
end
|
@@ -49,7 +49,7 @@ describe Rank do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def for_every_rank
|
52
|
-
Rank::DOMAIN.each do |rank, properties|
|
52
|
+
AcpcPokerTypes::Rank::DOMAIN.each do |rank, properties|
|
53
53
|
@symbol = rank
|
54
54
|
@number = properties[:number]
|
55
55
|
@string = properties[:text]
|
@@ -61,10 +61,10 @@ describe Rank do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def check_patient!
|
64
|
-
@patient.to_sym.
|
65
|
-
@patient.to_i.
|
66
|
-
@patient.to_acpc.
|
67
|
-
@patient.to_s.
|
68
|
-
@patient.to_html.
|
64
|
+
@patient.to_sym.must_equal @symbol
|
65
|
+
@patient.to_i.must_equal @number
|
66
|
+
@patient.to_acpc.must_equal @acpc
|
67
|
+
@patient.to_s.must_equal @string
|
68
|
+
@patient.to_html.must_equal @html
|
69
69
|
end
|
70
70
|
end
|