acpc_dealer_data 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,7 +29,7 @@ class HandData
29
29
 
30
30
  # State messages are organized by seat
31
31
  Turn = Struct.new(
32
- # @returns [Array<MatchState>] Match states sent during this turn
32
+ # @returns [Array<MatchState>] Match states sent during this turn arranged by seat
33
33
  :state_messages,
34
34
  # @returns [ActionMessages::FromMessage] Action message sent during this turn
35
35
  :action_message
@@ -136,8 +136,8 @@ class PokerMatchData
136
136
 
137
137
  @players.each_with_index do |player, seat|
138
138
  player.start_new_hand!(
139
- @match_def.game_def.blinds[seat],
140
- @match_def.game_def.chip_stacks[seat],
139
+ @match_def.game_def.blinds[current_hand.data.first.state_messages[seat].position_relative_to_dealer],
140
+ @match_def.game_def.chip_stacks[current_hand.data.first.state_messages[seat].position_relative_to_dealer],
141
141
  current_hand.data.first.state_messages[seat].users_hole_cards
142
142
  )
143
143
  end
@@ -164,13 +164,17 @@ class PokerMatchData
164
164
  player.take_action!(current_hand.last_action.action)
165
165
  end
166
166
 
167
- if !match_state.first_state_of_first_round? && match_state.round > last_match_state.round
167
+ if (
168
+ player.active? &&
169
+ !match_state.first_state_of_first_round? &&
170
+ match_state.round > last_match_state.round
171
+ )
168
172
  player.start_new_round!
169
173
  end
170
174
 
171
175
  if current_hand.final_turn?
172
176
  player.take_winnings!(
173
- current_hand.chip_distribution[seat] + @match_def.game_def.blinds[seat]
177
+ current_hand.chip_distribution[seat] + @match_def.game_def.blinds[current_hand.current_match_state(seat).position_relative_to_dealer]
174
178
  )
175
179
  end
176
180
  end
@@ -228,6 +232,37 @@ class PokerMatchData
228
232
  @players.map { |player| player.chip_contributions }
229
233
  end
230
234
 
235
+ def opponents
236
+ @players.reject { |other_player| player == other_player }
237
+ end
238
+ def active_players
239
+ @players.select { |player_to_collect| player_to_collect.active? }
240
+ end
241
+ def non_folded_players
242
+ @players.reject { |player_to_reject| player_to_reject.folded? }
243
+ end
244
+ def opponents_cards_visible?
245
+ return false unless current_hand
246
+
247
+ current_hand.current_match_state.list_of_hole_card_hands.reject_empty_elements.length > 1
248
+ end
249
+ def player_with_dealer_button
250
+ return nil unless current_hand
251
+
252
+ @players.find do |plr|
253
+ current_hand.current_match_state(plr.seat).position_relative_to_dealer == @players.length - 1
254
+ end
255
+ end
256
+ # @return [Hash<Player, #to_i] Relation from player to the blind that player paid.
257
+ def player_blind_relation
258
+ return nil unless current_hand
259
+
260
+ @players.inject({}) do |relation, plr|
261
+ relation[player] = @match_def.game_def.blinds[current_hand.current_match_state(plr.seat).position_relative_to_dealer]
262
+ relation
263
+ end
264
+ end
265
+
231
266
  protected
232
267
 
233
268
  def initialize_players!
@@ -1,3 +1,3 @@
1
1
  module AcpcDealerData
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acpc_dealer_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-02 00:00:00.000000000 Z
12
+ date: 2013-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: acpc_dealer
@@ -164,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  segments:
166
166
  - 0
167
- hash: 1585358207152026945
167
+ hash: 3284938472884505613
168
168
  required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  none: false
170
170
  requirements:
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  version: '0'
174
174
  segments:
175
175
  - 0
176
- hash: 1585358207152026945
176
+ hash: 3284938472884505613
177
177
  requirements: []
178
178
  rubyforge_project:
179
179
  rubygems_version: 1.8.24