Class: AcpcPokerPlayerProxy::PlayerProxy
- Inherits:
-
AcpcPokerTypes::PlayersAtTheTable
- Object
- AcpcPokerTypes::PlayersAtTheTable
- AcpcPokerPlayerProxy::PlayerProxy
- Includes:
- AcpcPokerBasicProxy, AcpcPokerTypes
- Defined in:
- lib/acpc_poker_player_proxy/player_proxy.rb
Instance Attribute Summary collapse
-
#must_send_ready ⇒ Object
readonly
Returns the value of attribute must_send_ready.
-
#players_at_the_table ⇒ PlayersAtTheTable
readonly
Summary of the progression of the match in which, this player is participating, since this object’s instantiation.
Instance Method Summary collapse
- #connected? ⇒ Boolean
-
#initialize(dealer_information, game_definition_argument, users_seat = nil, must_send_ready = false) {|_self| ... } ⇒ PlayerProxy
constructor
A new instance of PlayerProxy.
- #match_ended?(max_num_hands = nil) ⇒ Boolean
- #next_hand! ⇒ Object
-
#play!(action) ⇒ Object
Player action interface.
Constructor Details
#initialize(dealer_information, game_definition_argument, users_seat = nil, must_send_ready = false) {|_self| ... } ⇒ PlayerProxy
Returns a new instance of PlayerProxy.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/acpc_poker_player_proxy/player_proxy.rb', line 28 def initialize( dealer_information, game_definition_argument, users_seat = nil, must_send_ready = false ) @must_send_ready = must_send_ready game_def = if game_definition_argument.kind_of?( GameDefinition ) game_definition_argument else GameDefinition.parse_file(game_definition_argument) end @basic_proxy = BasicProxy.new dealer_information @players_at_the_table = if users_seat PlayersAtTheTable.seat_players game_def, users_seat else PlayersAtTheTable.seat_players game_def end super @players_at_the_table @dealer_died = false yield self if block_given? update_match_state_if_necessary! { yield self if block_given? } end |
Instance Attribute Details
#must_send_ready ⇒ Object (readonly)
Returns the value of attribute must_send_ready.
23 24 25 |
# File 'lib/acpc_poker_player_proxy/player_proxy.rb', line 23 def must_send_ready @must_send_ready end |
#players_at_the_table ⇒ PlayersAtTheTable (readonly)
Returns Summary of the progression of the match in which, this player is participating, since this object’s instantiation.
21 22 23 |
# File 'lib/acpc_poker_player_proxy/player_proxy.rb', line 21 def players_at_the_table @players_at_the_table end |
Instance Method Details
#connected? ⇒ Boolean
89 90 91 92 93 94 95 96 97 |
# File 'lib/acpc_poker_player_proxy/player_proxy.rb', line 89 def connected? begin @basic_proxy.send_comment 'KA' rescue AcpcPokerBasicProxy::DealerStream::UnableToWriteToDealer false else true end end |
#match_ended?(max_num_hands = nil) ⇒ Boolean
71 72 73 74 75 76 |
# File 'lib/acpc_poker_player_proxy/player_proxy.rb', line 71 def match_ended?(max_num_hands = nil) ( @players_at_the_table.match_ended?(max_num_hands) || (@dealer_died && !connected?) ) end |
#next_hand! ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/acpc_poker_player_proxy/player_proxy.rb', line 78 def next_hand! if @must_send_ready begin @basic_proxy.send_ready rescue AcpcPokerBasicProxy::DealerStream::UnableToWriteToDealer => e raise MatchEnded.with_context("Cannot send ready message!", e) end update_match_state! { yield self if block_given? } end end |
#play!(action) ⇒ Object
Player action interface
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/acpc_poker_player_proxy/player_proxy.rb', line 59 def play!(action) begin @basic_proxy.send_action action rescue AcpcPokerBasicProxy::DealerStream::UnableToWriteToDealer => e raise MatchEnded.with_context( "Cannot take action #{action} because the match has ended!", e ) end update_match_state! { yield self if block_given? } end |