acpc_poker_match_state 2.0.1 → 2.1.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: de92656964464faf6dcc3e4bebfe4cd4ea6e7bea
4
- data.tar.gz: 2c89fecad91441e2b2f0a42b8c8baf01a20c71c9
3
+ metadata.gz: f58ec6316e316ecc579366bcc28035f66b385ea7
4
+ data.tar.gz: 21d7cf1c8182d2caa481075fe7ec520026db2e9b
5
5
  SHA512:
6
- metadata.gz: d5e54e51513b8c29d64fd021d2315b439515a557d3ef43bc9f39c36db951ff3daca4a790bc5d87fb8091779aff87e64f7eb4375b46580fb1db0a3fa5be97ec29
7
- data.tar.gz: c822998df3e9e64f04d7faa5d1ebb10cffdeb1525c592939dd53dc56e16a57ab04d1c9f2601b8630f1af4c8b7bbbfb628aaa81f68a2d5183103a077762ff603e
6
+ metadata.gz: 70137ea089982d1760ecddfa502eb83d59f8e996379fed2010c5a4084e02fa19081403f2ddf3fe9b210b6bf3d6fd11a18c60250dbadc49a9f558ef9ed463f280
7
+ data.tar.gz: fbdbcb904fcc15e5085ed32e64619ec0afc2956398d299a616352d00a0d6aee1875c34a133c843fe596d66124fa9d4a417d1f58d80afc093e71745ce2eccb997
@@ -23,6 +23,7 @@ module AcpcPokerMatchState
23
23
 
24
24
  attr_reader :users_seat
25
25
 
26
+ # @return [ChipStack] Minimum wager by.
26
27
  attr_reader :min_wager
27
28
 
28
29
  attr_reader :player_who_acted_last
@@ -247,7 +248,7 @@ module AcpcPokerMatchState
247
248
  dealers_seat.n_seats_away(1).seats_to(player.seat)
248
249
  end
249
250
 
250
- def amount_to_call(player)
251
+ def amount_to_call(player = next_player_to_act)
251
252
  @players.map do |p|
252
253
  p.chip_contributions.inject(:+)
253
254
  end.max - player.chip_contributions.inject(:+)
@@ -275,15 +276,40 @@ module AcpcPokerMatchState
275
276
  if next_player_to_act.nil?
276
277
  []
277
278
  elsif player_sees_wager?
278
- [AcpcPokerTypes::PokerAction::CALL, AcpcPokerTypes::PokerAction::FOLD, AcpcPokerTypes::PokerAction::RAISE]
279
+ actions_without_wager = [
280
+ AcpcPokerTypes::PokerAction::CALL,
281
+ AcpcPokerTypes::PokerAction::FOLD
282
+ ]
283
+
284
+ if wager_legal?
285
+ actions_without_wager << AcpcPokerTypes::PokerAction::RAISE
286
+ else
287
+ actions_without_wager
288
+ end
279
289
  elsif chips_contributed_to_pot_this_round?
280
- [AcpcPokerTypes::PokerAction::CHECK, AcpcPokerTypes::PokerAction::RAISE]
290
+ actions_without_wager = [AcpcPokerTypes::PokerAction::CHECK]
291
+
292
+ if wager_legal?
293
+ actions_without_wager << AcpcPokerTypes::PokerAction::RAISE
294
+ else
295
+ actions_without_wager
296
+ end
281
297
  else
282
- [AcpcPokerTypes::PokerAction::CHECK, AcpcPokerTypes::PokerAction::BET]
298
+ actions_without_wager = [AcpcPokerTypes::PokerAction::CHECK]
299
+
300
+ if wager_legal?
301
+ actions_without_wager << AcpcPokerTypes::PokerAction::BET
302
+ else
303
+ actions_without_wager
304
+ end
283
305
  end
284
306
  )
285
307
  end
286
308
 
309
+ def wager_legal?
310
+ next_player_to_act.chip_contributions.inject(:+) + amount_to_call < @game_def.chip_stacks[position_relative_to_dealer(next_player_to_act)]
311
+ end
312
+
287
313
  # @return [Boolean] +true+ if the current hand is the last in the match.
288
314
  def last_hand?
289
315
  # @todo make sure +@match_state.hand_number+ is not greater than @number_of_hands
@@ -292,6 +318,19 @@ module AcpcPokerMatchState
292
318
  @transition.next_state.hand_number == @number_of_hands - 1
293
319
  end
294
320
 
321
+ def big_blind
322
+ player_blind_relation.values.max
323
+ end
324
+ def big_blind_payer
325
+ player_blind_relation.key big_blind
326
+ end
327
+ def small_blind
328
+ player_blind_relation.values.sort[-2]
329
+ end
330
+ def small_blind_payer
331
+ player_blind_relation.key small_blind
332
+ end
333
+
295
334
  private
296
335
 
297
336
  def player_contributed_to_pot_this_round?(player=next_player_to_act)
@@ -344,7 +383,12 @@ module AcpcPokerMatchState
344
383
  )
345
384
  unless action_with_context.to_s == 'f'
346
385
  last_amount_called = amount_to_call(player_who_acted_last)
347
- @min_wager = AcpcPokerTypes::ChipStack.new [@min_wager.to_r, action_with_context.cost.to_r - last_amount_called].max
386
+ @min_wager = AcpcPokerTypes::ChipStack.new(
387
+ [
388
+ @min_wager.to_r,
389
+ action_with_context.cost.to_r - last_amount_called
390
+ ].max
391
+ )
348
392
  end
349
393
 
350
394
  player_who_acted_last.take_action!(
@@ -1,3 +1,3 @@
1
1
  module AcpcPokerMatchState
2
- VERSION = "2.0.1"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acpc_poker_match_state
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.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: 2013-06-05 00:00:00.000000000 Z
11
+ date: 2013-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acpc_poker_types