acpc_table_manager 2.0.0 → 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: e5d135a405ab862b042bc72b5bc5f9171e3bd0ed
4
- data.tar.gz: 0ee34a84a44f500946fdab2e8b08945b0ce09366
3
+ metadata.gz: 6b0064595ce9c7b86386220cd810ab89d8d39b4c
4
+ data.tar.gz: 20722d18a11a3337a6eb15f38ce39448bdcf4ed8
5
5
  SHA512:
6
- metadata.gz: 8c0d1bee251f1d5bc040c6feb568cc278ef5fcbef42f020199ab5dea64ebb89c0a92ed7e440ffa6a67a210da187d1e4810ac7fb849e063803b5bc1bd40877d8d
7
- data.tar.gz: a13cab8ef8c26b889577d05094bed698b00ceca9f02bba5b34c137f8fe73dd2534ffdefd2dd0d8e4e4c835905753a975d00862c9d3db36733aff9bf1b1fb2812
6
+ metadata.gz: 86933039423c1239ff48919532d400c3b4e28ff3ddf95843db5190103bfac241959eafd9a6c282d8c9b63b35baa505bee4f4da365cc1868dfbbc5ef697d343f0
7
+ data.tar.gz: bc5374598055f5b11032de6c30d0868f404e41df8f77e282d5390d51d9f629ea87c56775302840f7c00c33f951376980979c1bfa5fd8c3fd29b5145fe59ce26c
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  # For poker logic
34
34
  spec.add_dependency "acpc_poker_types"
35
35
  spec.add_dependency 'acpc_dealer', '~> 2.0'
36
- spec.add_dependency 'acpc_poker_player_proxy', '~> 1.1'
36
+ spec.add_dependency 'acpc_poker_player_proxy', '~> 1.3'
37
37
 
38
38
  # Simple exception email notifications
39
39
  spec.add_dependency 'rusen'
@@ -47,8 +47,10 @@ end
47
47
  Signal.trap("INT") { exit }
48
48
  Signal.trap("TERM") { exit }
49
49
 
50
+ must_send_ready = AcpcTableManager.config.respond_to?(:next_hand_request_code)
51
+
50
52
  begin
51
- proxy = AcpcTableManager::Proxy.start match
53
+ proxy = AcpcTableManager::Proxy.start match, must_send_ready
52
54
  proxy.log __method__, options
53
55
  loop do
54
56
  message = AcpcTableManager.redis.blpop(
@@ -57,7 +59,12 @@ begin
57
59
  )
58
60
  if message
59
61
  data = JSON.parse message[1]
60
- proxy.play! data[AcpcTableManager.config.action_key]
62
+ action = data[AcpcTableManager.config.action_key]
63
+ if must_send_ready && action == AcpcTableManager.config.next_hand_request_code
64
+ proxy.next_hand!
65
+ else
66
+ proxy.play! action
67
+ end
61
68
  end
62
69
  if proxy.match_ended?
63
70
  AcpcTableManager.redis.rpush(
@@ -19,7 +19,7 @@ class Proxy
19
19
 
20
20
  exceptions :unable_to_create_match_slice
21
21
 
22
- def self.start(match)
22
+ def self.start(match, must_send_ready = false)
23
23
  game_definition = GameDefinition.parse_file(match.game_definition_file_name)
24
24
  match.game_def_hash = game_definition.to_h
25
25
  match.save!
@@ -33,7 +33,8 @@ class Proxy
33
33
  match.seat - 1,
34
34
  game_definition,
35
35
  match.player_names.join(' '),
36
- match.number_of_hands
36
+ match.number_of_hands,
37
+ must_send_ready
37
38
  ) do |players_at_the_table|
38
39
  yield players_at_the_table if block_given?
39
40
  end
@@ -52,7 +53,8 @@ class Proxy
52
53
  users_seat,
53
54
  game_definition,
54
55
  player_names='user p2',
55
- number_of_hands=1
56
+ number_of_hands=1,
57
+ must_send_ready=false
56
58
  )
57
59
  @logger = AcpcTableManager.new_log File.join('proxies', "#{match_id}.#{users_seat}.log")
58
60
 
@@ -68,7 +70,8 @@ class Proxy
68
70
  @player_proxy = AcpcPokerPlayerProxy::PlayerProxy.new(
69
71
  dealer_information,
70
72
  game_definition,
71
- users_seat
73
+ users_seat,
74
+ must_send_ready
72
75
  ) do |players_at_the_table|
73
76
 
74
77
  if players_at_the_table.match_state
@@ -81,6 +84,26 @@ class Proxy
81
84
  end
82
85
  end
83
86
 
87
+ def next_hand!
88
+ log __method__
89
+
90
+ @player_proxy.next_hand! do |players_at_the_table|
91
+ update_database! players_at_the_table
92
+
93
+ yield players_at_the_table if block_given?
94
+ end
95
+
96
+ log(
97
+ __method__,
98
+ {
99
+ users_turn_to_act?: @player_proxy.users_turn_to_act?,
100
+ match_ended?: @player_proxy.match_ended?
101
+ }
102
+ )
103
+
104
+ self
105
+ end
106
+
84
107
  # Player action interface
85
108
  # @see PlayerProxy#play!
86
109
  def play!(action)
@@ -1,3 +1,3 @@
1
1
  module AcpcTableManager
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acpc_table_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Morrill
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-14 00:00:00.000000000 Z
11
+ date: 2016-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pony
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1.1'
117
+ version: '1.3'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '1.1'
124
+ version: '1.3'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rusen
127
127
  requirement: !ruby/object:Gem::Requirement