acpc_poker_types 7.6.4 → 7.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47e0c8b9dd9b799cb3d4d66b10c803b55d24b748
4
- data.tar.gz: bdf963c05df26543a8b5d89634ee375ee29a682b
3
+ metadata.gz: 440988b04d147e8ebd36f811f4d8c367c13a7972
4
+ data.tar.gz: 7792be06237f5dfb81ce0a26caf7daae4de70bec
5
5
  SHA512:
6
- metadata.gz: 8c88d11c93751f0fedf0b600f5a689cd937a024b4db1998ddc3fe72a012e6fba232fe9bb6b4a987d8ff4c3c5bac5b0e3353e6d47fce0881bf847081947af7c7a
7
- data.tar.gz: 0e02943c1bc8a3886cecc3871c61f5503c70af412251bd90add21072deed53ad017444f53c8e38bac71eae898d0044c1d532a47f6edd372c0a763c520ef31eea
6
+ metadata.gz: 8cd0412d181f98f897cf169be1eb70a312f0c3adb922eb44aaa6839b9e04459ec5b0eb4aee614d39ae566dadbab030ea9e54eaf58a9465c09eee3ca3671763d4
7
+ data.tar.gz: 834f4b9d84959c1917dfe1b1ebe7a7c8ba28612696268d0a3288794368adb341c0ca65e1580eb2d63cdb0cc2f50d8696df04f3f0e8b12363f3e8bd6efca1fba2
@@ -65,6 +65,7 @@ class MatchState < DelegateClass(String)
65
65
  COMMUNITY_CARD_SEPARATOR = '/'
66
66
  BETTING_SEQUENCE_SEPARATOR = COMMUNITY_CARD_SEPARATOR
67
67
  HAND_SEPARATOR = '|'
68
+ FIELD_SEPARATOR = ':'
68
69
 
69
70
  class << self; alias_method(:parse, :new) end
70
71
 
@@ -88,27 +89,32 @@ class MatchState < DelegateClass(String)
88
89
  hand_number,
89
90
  betting_sequence,
90
91
  all_hole_cards,
91
- board_cards
92
+ board_cards,
93
+ stack_sizes = nil
92
94
  )
93
- string = "#{LABEL}:#{position_relative_to_dealer}:#{hand_number}:#{betting_sequence}:#{all_hole_cards}"
95
+ string = "#{LABEL}#{FIELD_SEPARATOR}#{position_relative_to_dealer}#{FIELD_SEPARATOR}#{hand_number}#{FIELD_SEPARATOR}#{betting_sequence}#{FIELD_SEPARATOR}#{all_hole_cards}"
94
96
  string << "/#{board_cards.to_s}" if board_cards && !board_cards.empty?
97
+ if stack_sizes
98
+ string << "#{FIELD_SEPARATOR}#{stack_sizes.map { |stack| format('%g', stack) }.join('|')}"
99
+ end
95
100
  string
96
101
  end
97
102
 
98
103
  # @param [String] raw_match_state A raw match state string to be parsed.
99
104
  # @raise IncompleteMatchState
100
105
  def initialize(raw_match_state, previous_state = nil, game_def = nil)
101
- if (
102
- %r{#{LABEL}:(\d+):(\d+):([^:]*):([^#{COMMUNITY_CARD_SEPARATOR}\s]+)#{COMMUNITY_CARD_SEPARATOR}*([^\s:]*)}.match(
103
- raw_match_state
104
- )
105
- )
106
- @position_relative_to_dealer = $1.to_i
107
- @hand_number = $2.to_i
108
- @betting_sequence_string = $3
109
- @hands_string = $4
110
- @community_cards_string = $5
106
+ fields = raw_match_state.split(FIELD_SEPARATOR)
107
+ @position_relative_to_dealer = fields[1].to_i
108
+ @hand_number = fields[2].to_i
109
+ @betting_sequence_string = fields[3]
110
+ card_fields = fields[4].split(COMMUNITY_CARD_SEPARATOR)
111
+ @hands_string = card_fields.shift
112
+ @community_cards_string = card_fields.join('/')
113
+ @stack_sizes = nil
114
+ if fields.length > 5 && fields[5].count(HAND_SEPARATOR) > 0
115
+ @stack_sizes = fields[5].split(HAND_SEPARATOR).map(&:to_f)
111
116
  end
117
+
112
118
  @winning_players = nil
113
119
  @str = nil
114
120
  @all_hands = nil
@@ -162,7 +168,8 @@ class MatchState < DelegateClass(String)
162
168
  @hand_number,
163
169
  @betting_sequence_string,
164
170
  @hands_string,
165
- @community_cards_string
171
+ @community_cards_string,
172
+ @stack_sizes
166
173
  )
167
174
  end
168
175
 
@@ -317,7 +324,10 @@ class MatchState < DelegateClass(String)
317
324
  # @param game_def [GameDefinition]
318
325
  # @return [HandPlayerGroup] The current state of the players.
319
326
  def every_action(game_def)
320
- @players = players_at_hand_start game_def.chip_stacks, game_def.blinds
327
+ @players = players_at_hand_start(
328
+ @stack_sizes || game_def.chip_stacks,
329
+ game_def.blinds
330
+ )
321
331
 
322
332
  @next_to_act = game_def.first_player_positions.first
323
333
  @player_acting_sequence = []
@@ -520,4 +530,4 @@ class MatchState < DelegateClass(String)
520
530
  self
521
531
  end
522
532
  end
523
- end
533
+ end
@@ -1,3 +1,3 @@
1
1
  module AcpcPokerTypes
2
- VERSION = '7.6.4'
2
+ VERSION = '7.7.0'
3
3
  end
@@ -120,6 +120,21 @@ describe MatchState do
120
120
 
121
121
  match_state = partial_match_state + betting + ":" + hands + community_cards
122
122
 
123
+ test_match_state_success match_state
124
+ end
125
+ it 'parses an initial match state that contains stack sizes' do
126
+ partial_match_state = MatchState::LABEL + ":0:22:"
127
+ betting = ''
128
+ community_cards = ''
129
+ hands = arbitrary_hole_card_hand.to_acpc + "|" + arbitrary_hole_card_hand.to_acpc
130
+
131
+ stacks = [9001, 222]
132
+
133
+ match_state = partial_match_state + betting + ":" + hands + community_cards + ":" + stacks.map(&:to_s).join('|')
134
+
135
+ patient = MatchState.parse match_state
136
+ ap patient: patient.to_s, match_state: match_state
137
+
123
138
  test_match_state_success match_state
124
139
  end
125
140
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acpc_poker_types
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.6.4
4
+ version: 7.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Morrill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-07 00:00:00.000000000 Z
11
+ date: 2017-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: process_runner
@@ -256,4 +256,3 @@ test_files:
256
256
  - spec/support/dealer_logs/3p.nolimit.h1000.r0.actions.log
257
257
  - spec/support/dealer_logs/3p.nolimit.h1000.r0.log
258
258
  - spec/support/spec_helper.rb
259
- has_rdoc: