Sha256: f6ca27b5558bea4cd51404988934d1fc2a82221b8023f1d9b5430e5bd17c0649

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require 'acpc_dealer'

require 'acpc_poker_basic_proxy/communication_logic/dealer_stream'
require 'acpc_poker_basic_proxy/communication_logic/action_sender'
require 'acpc_poker_basic_proxy/communication_logic/match_state_receiver'

require 'contextual_exceptions'
using ContextualExceptions::ClassRefinement

# A bot that connects to a dealer as a proxy.
module AcpcPokerBasicProxy
  class BasicProxy
    exceptions :initial_match_state_not_yet_received

    # @param [AcpcDealer::ConnectionInformation] dealer_information Information about the dealer to which this bot should connect.
    def initialize(dealer_information)
      @dealer_communicator = CommunicationLogic::DealerStream.new dealer_information.port_number, dealer_information.host_name, dealer_information.millisecond_response_timeout
    end

    # @param [PokerAction] action The action to be sent.
    # @return (see ActionSender#send_action)
    # @raise InitialMatchStateNotYetReceived
    # @raise (see ActionSender#send_action)
    def send_action(action)
      raise InitialMatchStateNotYetReceived unless @match_state
      CommunicationLogic::ActionSender.send_action @dealer_communicator, @match_state, action
    end

    # @see MatchStateReceiver#receive_match_state
    def receive_match_state!
      @match_state = CommunicationLogic::MatchStateReceiver.receive_match_state @dealer_communicator
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acpc_poker_basic_proxy-2.0.0 lib/acpc_poker_basic_proxy/basic_proxy.rb