acpc_poker_types 7.7.1 → 7.7.2
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 +13 -2
- data/lib/acpc_poker_types/version.rb +1 -1
- data/spec/match_state_spec.rb +19 -0
- 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: bdfea85f6f2b2b796bedf4d2908e40e840d029f6
|
4
|
+
data.tar.gz: ded5cd67c1bfcaffd5623e89defe8d25572370a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d7329740b7ddd8e217fb9aebba88ee13e673ba2c60d536d7873fa837a0b2677009caf39e7f4184ac14cce1b35a98652e8b80f2b2e6ee96a3eda5202b1a26900
|
7
|
+
data.tar.gz: 27c04ec8f3b44a0e11ddd0ecc863d33eedb7be4b0b061f839215bd7c2be2bf77ed903150a19fc2b60390ac1d06f5c6af4c664cbf7697bc4d30b6a8295b7784a1
|
@@ -60,9 +60,13 @@ class MatchState < DelegateClass(String)
|
|
60
60
|
attr_reader :winning_players
|
61
61
|
|
62
62
|
# @return [Array<Float> or nil] The stack sizes at the beginning of the
|
63
|
-
# current hand
|
63
|
+
# current hand or +nil+ if none were specified by the match state string.
|
64
64
|
attr_reader :stack_sizes
|
65
65
|
|
66
|
+
# @return [String or nil] The comment appended to the end of the match state
|
67
|
+
# string or +nil+ if none was specified.
|
68
|
+
attr_reader :comment
|
69
|
+
|
66
70
|
# @return [String] Label for match state strings.
|
67
71
|
LABEL = 'MATCHSTATE'
|
68
72
|
|
@@ -108,10 +112,17 @@ class MatchState < DelegateClass(String)
|
|
108
112
|
# @param [String] raw_match_state A raw match state string to be parsed.
|
109
113
|
# @raise IncompleteMatchState
|
110
114
|
def initialize(raw_match_state, previous_state = nil, game_def = nil)
|
111
|
-
fields = raw_match_state.split(FIELD_SEPARATOR)[1..-1]
|
115
|
+
fields = raw_match_state.split(/(#{FIELD_SEPARATOR}|\s+#\s*)/)[1..-1]
|
116
|
+
fields.delete ':'
|
112
117
|
@position_relative_to_dealer = fields.shift.to_i
|
113
118
|
@hand_number = fields.shift.to_i
|
114
119
|
|
120
|
+
@comment = if fields[-2].count('#') > 0
|
121
|
+
comment = fields.pop
|
122
|
+
fields.pop
|
123
|
+
comment
|
124
|
+
end
|
125
|
+
|
115
126
|
@stack_sizes = if (
|
116
127
|
fields.length > 2 &&
|
117
128
|
fields.first.count(HAND_SEPARATOR) > 0
|
data/spec/match_state_spec.rb
CHANGED
@@ -142,6 +142,25 @@ describe MatchState do
|
|
142
142
|
|
143
143
|
test_match_state_success match_state
|
144
144
|
end
|
145
|
+
it 'parses an initial match state that contains a comment' do
|
146
|
+
partial_match_state = MatchState::LABEL + ":0:22:"
|
147
|
+
betting = ''
|
148
|
+
community_cards = ''
|
149
|
+
hands = arbitrary_hole_card_hand.to_acpc + "|" + arbitrary_hole_card_hand.to_acpc
|
150
|
+
|
151
|
+
match_state = (
|
152
|
+
partial_match_state +
|
153
|
+
betting +
|
154
|
+
":" +
|
155
|
+
hands +
|
156
|
+
community_cards
|
157
|
+
)
|
158
|
+
ms_with_comment = match_state + ' # comment'
|
159
|
+
|
160
|
+
patient = MatchState.parse ms_with_comment
|
161
|
+
patient.to_s.must_equal match_state
|
162
|
+
patient.comment.must_equal 'comment'
|
163
|
+
end
|
145
164
|
end
|
146
165
|
|
147
166
|
describe '#new allows bootstrapping from previous states' do
|