#
# Autogenerated by Thrift Compiler (1.0.0-dev)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#

require 'thrift'
require 'hearts_types'

module AgentVsAgent
  module Hearts
    class Client
      include ::Thrift::Client

      def enter_arena(request)
        send_enter_arena(request)
        return recv_enter_arena()
      end

      def send_enter_arena(request)
        send_message('enter_arena', Enter_arena_args, :request => request)
      end

      def recv_enter_arena()
        result = receive_message(Enter_arena_result)
        return result.success unless result.success.nil?
        raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'enter_arena failed: unknown result')
      end

      def get_game_info(ticket)
        send_get_game_info(ticket)
        return recv_get_game_info()
      end

      def send_get_game_info(ticket)
        send_message('get_game_info', Get_game_info_args, :ticket => ticket)
      end

      def recv_get_game_info()
        result = receive_message(Get_game_info_result)
        return result.success unless result.success.nil?
        raise result.ex unless result.ex.nil?
        raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_game_info failed: unknown result')
      end

      def get_hand(ticket)
        send_get_hand(ticket)
        return recv_get_hand()
      end

      def send_get_hand(ticket)
        send_message('get_hand', Get_hand_args, :ticket => ticket)
      end

      def recv_get_hand()
        result = receive_message(Get_hand_result)
        return result.success unless result.success.nil?
        raise result.ex unless result.ex.nil?
        raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_hand failed: unknown result')
      end

      def pass_cards(ticket, cards)
        send_pass_cards(ticket, cards)
        return recv_pass_cards()
      end

      def send_pass_cards(ticket, cards)
        send_message('pass_cards', Pass_cards_args, :ticket => ticket, :cards => cards)
      end

      def recv_pass_cards()
        result = receive_message(Pass_cards_result)
        return result.success unless result.success.nil?
        raise result.ex unless result.ex.nil?
        raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'pass_cards failed: unknown result')
      end

      def get_trick(ticket)
        send_get_trick(ticket)
        return recv_get_trick()
      end

      def send_get_trick(ticket)
        send_message('get_trick', Get_trick_args, :ticket => ticket)
      end

      def recv_get_trick()
        result = receive_message(Get_trick_result)
        return result.success unless result.success.nil?
        raise result.ex unless result.ex.nil?
        raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_trick failed: unknown result')
      end

      def play_card(ticket, card)
        send_play_card(ticket, card)
        return recv_play_card()
      end

      def send_play_card(ticket, card)
        send_message('play_card', Play_card_args, :ticket => ticket, :card => card)
      end

      def recv_play_card()
        result = receive_message(Play_card_result)
        return result.success unless result.success.nil?
        raise result.ex unless result.ex.nil?
        raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'play_card failed: unknown result')
      end

      def get_round_result(ticket)
        send_get_round_result(ticket)
        return recv_get_round_result()
      end

      def send_get_round_result(ticket)
        send_message('get_round_result', Get_round_result_args, :ticket => ticket)
      end

      def recv_get_round_result()
        result = receive_message(Get_round_result_result)
        return result.success unless result.success.nil?
        raise result.ex unless result.ex.nil?
        raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_round_result failed: unknown result')
      end

      def get_game_result(ticket)
        send_get_game_result(ticket)
        return recv_get_game_result()
      end

      def send_get_game_result(ticket)
        send_message('get_game_result', Get_game_result_args, :ticket => ticket)
      end

      def recv_get_game_result()
        result = receive_message(Get_game_result_result)
        return result.success unless result.success.nil?
        raise result.ex unless result.ex.nil?
        raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_game_result failed: unknown result')
      end

    end

    class Processor
      include ::Thrift::Processor

      def process_enter_arena(seqid, iprot, oprot)
        args = read_args(iprot, Enter_arena_args)
        result = Enter_arena_result.new()
        result.success = @handler.enter_arena(args.request)
        write_result(result, oprot, 'enter_arena', seqid)
      end

      def process_get_game_info(seqid, iprot, oprot)
        args = read_args(iprot, Get_game_info_args)
        result = Get_game_info_result.new()
        begin
          result.success = @handler.get_game_info(args.ticket)
        rescue ::AgentVsAgent::GameException => ex
          result.ex = ex
        end
        write_result(result, oprot, 'get_game_info', seqid)
      end

      def process_get_hand(seqid, iprot, oprot)
        args = read_args(iprot, Get_hand_args)
        result = Get_hand_result.new()
        begin
          result.success = @handler.get_hand(args.ticket)
        rescue ::AgentVsAgent::GameException => ex
          result.ex = ex
        end
        write_result(result, oprot, 'get_hand', seqid)
      end

      def process_pass_cards(seqid, iprot, oprot)
        args = read_args(iprot, Pass_cards_args)
        result = Pass_cards_result.new()
        begin
          result.success = @handler.pass_cards(args.ticket, args.cards)
        rescue ::AgentVsAgent::GameException => ex
          result.ex = ex
        end
        write_result(result, oprot, 'pass_cards', seqid)
      end

      def process_get_trick(seqid, iprot, oprot)
        args = read_args(iprot, Get_trick_args)
        result = Get_trick_result.new()
        begin
          result.success = @handler.get_trick(args.ticket)
        rescue ::AgentVsAgent::GameException => ex
          result.ex = ex
        end
        write_result(result, oprot, 'get_trick', seqid)
      end

      def process_play_card(seqid, iprot, oprot)
        args = read_args(iprot, Play_card_args)
        result = Play_card_result.new()
        begin
          result.success = @handler.play_card(args.ticket, args.card)
        rescue ::AgentVsAgent::GameException => ex
          result.ex = ex
        end
        write_result(result, oprot, 'play_card', seqid)
      end

      def process_get_round_result(seqid, iprot, oprot)
        args = read_args(iprot, Get_round_result_args)
        result = Get_round_result_result.new()
        begin
          result.success = @handler.get_round_result(args.ticket)
        rescue ::AgentVsAgent::GameException => ex
          result.ex = ex
        end
        write_result(result, oprot, 'get_round_result', seqid)
      end

      def process_get_game_result(seqid, iprot, oprot)
        args = read_args(iprot, Get_game_result_args)
        result = Get_game_result_result.new()
        begin
          result.success = @handler.get_game_result(args.ticket)
        rescue ::AgentVsAgent::GameException => ex
          result.ex = ex
        end
        write_result(result, oprot, 'get_game_result', seqid)
      end

    end

    # HELPER FUNCTIONS AND STRUCTURES

    class Enter_arena_args
      include ::Thrift::Struct, ::Thrift::Struct_Union
      REQUEST = 1

      FIELDS = {
        REQUEST => {:type => ::Thrift::Types::STRUCT, :name => 'request', :class => ::AgentVsAgent::EntryRequest}
      }

      def struct_fields; FIELDS; end

      def validate
        raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field request is unset!') unless @request
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Enter_arena_result
      include ::Thrift::Struct, ::Thrift::Struct_Union
      SUCCESS = 0

      FIELDS = {
        SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::AgentVsAgent::EntryResponse}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Get_game_info_args
      include ::Thrift::Struct, ::Thrift::Struct_Union
      TICKET = 1

      FIELDS = {
        TICKET => {:type => ::Thrift::Types::STRUCT, :name => 'ticket', :class => ::AgentVsAgent::Ticket}
      }

      def struct_fields; FIELDS; end

      def validate
        raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field ticket is unset!') unless @ticket
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Get_game_info_result
      include ::Thrift::Struct, ::Thrift::Struct_Union
      SUCCESS = 0
      EX = 1

      FIELDS = {
        SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::AgentVsAgent::GameInfo},
        EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => ::AgentVsAgent::GameException}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Get_hand_args
      include ::Thrift::Struct, ::Thrift::Struct_Union
      TICKET = 1

      FIELDS = {
        TICKET => {:type => ::Thrift::Types::STRUCT, :name => 'ticket', :class => ::AgentVsAgent::Ticket}
      }

      def struct_fields; FIELDS; end

      def validate
        raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field ticket is unset!') unless @ticket
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Get_hand_result
      include ::Thrift::Struct, ::Thrift::Struct_Union
      SUCCESS = 0
      EX = 1

      FIELDS = {
        SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => ::AgentVsAgent::Card}},
        EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => ::AgentVsAgent::GameException}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Pass_cards_args
      include ::Thrift::Struct, ::Thrift::Struct_Union
      TICKET = 1
      CARDS = 2

      FIELDS = {
        TICKET => {:type => ::Thrift::Types::STRUCT, :name => 'ticket', :class => ::AgentVsAgent::Ticket},
        CARDS => {:type => ::Thrift::Types::LIST, :name => 'cards', :element => {:type => ::Thrift::Types::STRUCT, :class => ::AgentVsAgent::Card}}
      }

      def struct_fields; FIELDS; end

      def validate
        raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field ticket is unset!') unless @ticket
        raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field cards is unset!') unless @cards
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Pass_cards_result
      include ::Thrift::Struct, ::Thrift::Struct_Union
      SUCCESS = 0
      EX = 1

      FIELDS = {
        SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => ::AgentVsAgent::Card}},
        EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => ::AgentVsAgent::GameException}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Get_trick_args
      include ::Thrift::Struct, ::Thrift::Struct_Union
      TICKET = 1

      FIELDS = {
        TICKET => {:type => ::Thrift::Types::STRUCT, :name => 'ticket', :class => ::AgentVsAgent::Ticket}
      }

      def struct_fields; FIELDS; end

      def validate
        raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field ticket is unset!') unless @ticket
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Get_trick_result
      include ::Thrift::Struct, ::Thrift::Struct_Union
      SUCCESS = 0
      EX = 1

      FIELDS = {
        SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::AgentVsAgent::Trick},
        EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => ::AgentVsAgent::GameException}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Play_card_args
      include ::Thrift::Struct, ::Thrift::Struct_Union
      TICKET = 1
      CARD = 2

      FIELDS = {
        TICKET => {:type => ::Thrift::Types::STRUCT, :name => 'ticket', :class => ::AgentVsAgent::Ticket},
        CARD => {:type => ::Thrift::Types::STRUCT, :name => 'card', :class => ::AgentVsAgent::Card}
      }

      def struct_fields; FIELDS; end

      def validate
        raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field ticket is unset!') unless @ticket
        raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field card is unset!') unless @card
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Play_card_result
      include ::Thrift::Struct, ::Thrift::Struct_Union
      SUCCESS = 0
      EX = 1

      FIELDS = {
        SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::AgentVsAgent::Trick},
        EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => ::AgentVsAgent::GameException}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Get_round_result_args
      include ::Thrift::Struct, ::Thrift::Struct_Union
      TICKET = 1

      FIELDS = {
        TICKET => {:type => ::Thrift::Types::STRUCT, :name => 'ticket', :class => ::AgentVsAgent::Ticket}
      }

      def struct_fields; FIELDS; end

      def validate
        raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field ticket is unset!') unless @ticket
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Get_round_result_result
      include ::Thrift::Struct, ::Thrift::Struct_Union
      SUCCESS = 0
      EX = 1

      FIELDS = {
        SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::AgentVsAgent::RoundResult},
        EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => ::AgentVsAgent::GameException}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Get_game_result_args
      include ::Thrift::Struct, ::Thrift::Struct_Union
      TICKET = 1

      FIELDS = {
        TICKET => {:type => ::Thrift::Types::STRUCT, :name => 'ticket', :class => ::AgentVsAgent::Ticket}
      }

      def struct_fields; FIELDS; end

      def validate
        raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field ticket is unset!') unless @ticket
      end

      ::Thrift::Struct.generate_accessors self
    end

    class Get_game_result_result
      include ::Thrift::Struct, ::Thrift::Struct_Union
      SUCCESS = 0
      EX = 1

      FIELDS = {
        SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::AgentVsAgent::GameResult},
        EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => ::AgentVsAgent::GameException}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

  end

end
