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

package AgentVsAgent

import (
	"fmt"
	"git.apache.org/thrift.git/lib/go/thrift"
	"math"
)

// (needed to ensure safety because of naive import list construction.)
var _ = math.MinInt32
var _ = thrift.ZERO
var _ = fmt.Printf

type Hearts interface {
	// Parameters:
	//  - Request
	EnterArena(request *EntryRequest) (r *EntryResponse, err error)
	// Parameters:
	//  - Ticket
	GetGameInfo(ticket *Ticket) (r *GameInfo, ex *GameException, err error)
	// Parameters:
	//  - Ticket
	GetHand(ticket *Ticket) (r []*Card, ex *GameException, err error)
	// Parameters:
	//  - Ticket
	//  - Cards
	PassCards(ticket *Ticket, cards []*Card) (r []*Card, ex *GameException, err error)
	// Parameters:
	//  - Ticket
	GetTrick(ticket *Ticket) (r *Trick, ex *GameException, err error)
	// Parameters:
	//  - Ticket
	//  - Card
	PlayCard(ticket *Ticket, card *Card) (r *Trick, ex *GameException, err error)
	// Parameters:
	//  - Ticket
	GetRoundResult(ticket *Ticket) (r *RoundResult, ex *GameException, err error)
	// Parameters:
	//  - Ticket
	GetGameResult(ticket *Ticket) (r *GameResult, ex *GameException, err error)
}

type HeartsClient struct {
	Transport       thrift.TTransport
	ProtocolFactory thrift.TProtocolFactory
	InputProtocol   thrift.TProtocol
	OutputProtocol  thrift.TProtocol
	SeqId           int32
}

func NewHeartsClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *HeartsClient {
	return &HeartsClient{Transport: t,
		ProtocolFactory: f,
		InputProtocol:   f.GetProtocol(t),
		OutputProtocol:  f.GetProtocol(t),
		SeqId:           0,
	}
}

func NewHeartsClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *HeartsClient {
	return &HeartsClient{Transport: t,
		ProtocolFactory: nil,
		InputProtocol:   iprot,
		OutputProtocol:  oprot,
		SeqId:           0,
	}
}

// Parameters:
//  - Request
func (p *HeartsClient) EnterArena(request *EntryRequest) (r *EntryResponse, err error) {
	if err = p.sendEnterArena(request); err != nil {
		return
	}
	return p.recvEnterArena()
}

func (p *HeartsClient) sendEnterArena(request *EntryRequest) (err error) {
	oprot := p.OutputProtocol
	if oprot == nil {
		oprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.OutputProtocol = oprot
	}
	p.SeqId++
	oprot.WriteMessageBegin("enter_arena", thrift.CALL, p.SeqId)
	args1 := NewEnterArenaArgs()
	args1.Request = request
	err = args1.Write(oprot)
	oprot.WriteMessageEnd()
	oprot.Flush()
	return
}

func (p *HeartsClient) recvEnterArena() (value *EntryResponse, err error) {
	iprot := p.InputProtocol
	if iprot == nil {
		iprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.InputProtocol = iprot
	}
	_, mTypeId, seqId, err := iprot.ReadMessageBegin()
	if err != nil {
		return
	}
	if mTypeId == thrift.EXCEPTION {
		error3 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
		var error4 error
		error4, err = error3.Read(iprot)
		if err != nil {
			return
		}
		if err = iprot.ReadMessageEnd(); err != nil {
			return
		}
		err = error4
		return
	}
	if p.SeqId != seqId {
		err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "ping failed: out of sequence response")
		return
	}
	result2 := NewEnterArenaResult()
	err = result2.Read(iprot)
	iprot.ReadMessageEnd()
	value = result2.Success
	return
}

// Parameters:
//  - Ticket
func (p *HeartsClient) GetGameInfo(ticket *Ticket) (r *GameInfo, ex *GameException, err error) {
	if err = p.sendGetGameInfo(ticket); err != nil {
		return
	}
	return p.recvGetGameInfo()
}

func (p *HeartsClient) sendGetGameInfo(ticket *Ticket) (err error) {
	oprot := p.OutputProtocol
	if oprot == nil {
		oprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.OutputProtocol = oprot
	}
	p.SeqId++
	oprot.WriteMessageBegin("get_game_info", thrift.CALL, p.SeqId)
	args5 := NewGetGameInfoArgs()
	args5.Ticket = ticket
	err = args5.Write(oprot)
	oprot.WriteMessageEnd()
	oprot.Flush()
	return
}

func (p *HeartsClient) recvGetGameInfo() (value *GameInfo, ex *GameException, err error) {
	iprot := p.InputProtocol
	if iprot == nil {
		iprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.InputProtocol = iprot
	}
	_, mTypeId, seqId, err := iprot.ReadMessageBegin()
	if err != nil {
		return
	}
	if mTypeId == thrift.EXCEPTION {
		error7 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
		var error8 error
		error8, err = error7.Read(iprot)
		if err != nil {
			return
		}
		if err = iprot.ReadMessageEnd(); err != nil {
			return
		}
		err = error8
		return
	}
	if p.SeqId != seqId {
		err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "ping failed: out of sequence response")
		return
	}
	result6 := NewGetGameInfoResult()
	err = result6.Read(iprot)
	iprot.ReadMessageEnd()
	value = result6.Success
	if result6.Ex != nil {
		ex = result6.Ex
	}
	return
}

// Parameters:
//  - Ticket
func (p *HeartsClient) GetHand(ticket *Ticket) (r []*Card, ex *GameException, err error) {
	if err = p.sendGetHand(ticket); err != nil {
		return
	}
	return p.recvGetHand()
}

func (p *HeartsClient) sendGetHand(ticket *Ticket) (err error) {
	oprot := p.OutputProtocol
	if oprot == nil {
		oprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.OutputProtocol = oprot
	}
	p.SeqId++
	oprot.WriteMessageBegin("get_hand", thrift.CALL, p.SeqId)
	args9 := NewGetHandArgs()
	args9.Ticket = ticket
	err = args9.Write(oprot)
	oprot.WriteMessageEnd()
	oprot.Flush()
	return
}

func (p *HeartsClient) recvGetHand() (value []*Card, ex *GameException, err error) {
	iprot := p.InputProtocol
	if iprot == nil {
		iprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.InputProtocol = iprot
	}
	_, mTypeId, seqId, err := iprot.ReadMessageBegin()
	if err != nil {
		return
	}
	if mTypeId == thrift.EXCEPTION {
		error11 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
		var error12 error
		error12, err = error11.Read(iprot)
		if err != nil {
			return
		}
		if err = iprot.ReadMessageEnd(); err != nil {
			return
		}
		err = error12
		return
	}
	if p.SeqId != seqId {
		err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "ping failed: out of sequence response")
		return
	}
	result10 := NewGetHandResult()
	err = result10.Read(iprot)
	iprot.ReadMessageEnd()
	value = result10.Success
	if result10.Ex != nil {
		ex = result10.Ex
	}
	return
}

// Parameters:
//  - Ticket
//  - Cards
func (p *HeartsClient) PassCards(ticket *Ticket, cards []*Card) (r []*Card, ex *GameException, err error) {
	if err = p.sendPassCards(ticket, cards); err != nil {
		return
	}
	return p.recvPassCards()
}

func (p *HeartsClient) sendPassCards(ticket *Ticket, cards []*Card) (err error) {
	oprot := p.OutputProtocol
	if oprot == nil {
		oprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.OutputProtocol = oprot
	}
	p.SeqId++
	oprot.WriteMessageBegin("pass_cards", thrift.CALL, p.SeqId)
	args13 := NewPassCardsArgs()
	args13.Ticket = ticket
	args13.Cards = cards
	err = args13.Write(oprot)
	oprot.WriteMessageEnd()
	oprot.Flush()
	return
}

func (p *HeartsClient) recvPassCards() (value []*Card, ex *GameException, err error) {
	iprot := p.InputProtocol
	if iprot == nil {
		iprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.InputProtocol = iprot
	}
	_, mTypeId, seqId, err := iprot.ReadMessageBegin()
	if err != nil {
		return
	}
	if mTypeId == thrift.EXCEPTION {
		error15 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
		var error16 error
		error16, err = error15.Read(iprot)
		if err != nil {
			return
		}
		if err = iprot.ReadMessageEnd(); err != nil {
			return
		}
		err = error16
		return
	}
	if p.SeqId != seqId {
		err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "ping failed: out of sequence response")
		return
	}
	result14 := NewPassCardsResult()
	err = result14.Read(iprot)
	iprot.ReadMessageEnd()
	value = result14.Success
	if result14.Ex != nil {
		ex = result14.Ex
	}
	return
}

// Parameters:
//  - Ticket
func (p *HeartsClient) GetTrick(ticket *Ticket) (r *Trick, ex *GameException, err error) {
	if err = p.sendGetTrick(ticket); err != nil {
		return
	}
	return p.recvGetTrick()
}

func (p *HeartsClient) sendGetTrick(ticket *Ticket) (err error) {
	oprot := p.OutputProtocol
	if oprot == nil {
		oprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.OutputProtocol = oprot
	}
	p.SeqId++
	oprot.WriteMessageBegin("get_trick", thrift.CALL, p.SeqId)
	args17 := NewGetTrickArgs()
	args17.Ticket = ticket
	err = args17.Write(oprot)
	oprot.WriteMessageEnd()
	oprot.Flush()
	return
}

func (p *HeartsClient) recvGetTrick() (value *Trick, ex *GameException, err error) {
	iprot := p.InputProtocol
	if iprot == nil {
		iprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.InputProtocol = iprot
	}
	_, mTypeId, seqId, err := iprot.ReadMessageBegin()
	if err != nil {
		return
	}
	if mTypeId == thrift.EXCEPTION {
		error19 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
		var error20 error
		error20, err = error19.Read(iprot)
		if err != nil {
			return
		}
		if err = iprot.ReadMessageEnd(); err != nil {
			return
		}
		err = error20
		return
	}
	if p.SeqId != seqId {
		err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "ping failed: out of sequence response")
		return
	}
	result18 := NewGetTrickResult()
	err = result18.Read(iprot)
	iprot.ReadMessageEnd()
	value = result18.Success
	if result18.Ex != nil {
		ex = result18.Ex
	}
	return
}

// Parameters:
//  - Ticket
//  - Card
func (p *HeartsClient) PlayCard(ticket *Ticket, card *Card) (r *Trick, ex *GameException, err error) {
	if err = p.sendPlayCard(ticket, card); err != nil {
		return
	}
	return p.recvPlayCard()
}

func (p *HeartsClient) sendPlayCard(ticket *Ticket, card *Card) (err error) {
	oprot := p.OutputProtocol
	if oprot == nil {
		oprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.OutputProtocol = oprot
	}
	p.SeqId++
	oprot.WriteMessageBegin("play_card", thrift.CALL, p.SeqId)
	args21 := NewPlayCardArgs()
	args21.Ticket = ticket
	args21.Card = card
	err = args21.Write(oprot)
	oprot.WriteMessageEnd()
	oprot.Flush()
	return
}

func (p *HeartsClient) recvPlayCard() (value *Trick, ex *GameException, err error) {
	iprot := p.InputProtocol
	if iprot == nil {
		iprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.InputProtocol = iprot
	}
	_, mTypeId, seqId, err := iprot.ReadMessageBegin()
	if err != nil {
		return
	}
	if mTypeId == thrift.EXCEPTION {
		error23 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
		var error24 error
		error24, err = error23.Read(iprot)
		if err != nil {
			return
		}
		if err = iprot.ReadMessageEnd(); err != nil {
			return
		}
		err = error24
		return
	}
	if p.SeqId != seqId {
		err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "ping failed: out of sequence response")
		return
	}
	result22 := NewPlayCardResult()
	err = result22.Read(iprot)
	iprot.ReadMessageEnd()
	value = result22.Success
	if result22.Ex != nil {
		ex = result22.Ex
	}
	return
}

// Parameters:
//  - Ticket
func (p *HeartsClient) GetRoundResult(ticket *Ticket) (r *RoundResult, ex *GameException, err error) {
	if err = p.sendGetRoundResult(ticket); err != nil {
		return
	}
	return p.recvGetRoundResult()
}

func (p *HeartsClient) sendGetRoundResult(ticket *Ticket) (err error) {
	oprot := p.OutputProtocol
	if oprot == nil {
		oprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.OutputProtocol = oprot
	}
	p.SeqId++
	oprot.WriteMessageBegin("get_round_result", thrift.CALL, p.SeqId)
	args25 := NewGetRoundResultArgs()
	args25.Ticket = ticket
	err = args25.Write(oprot)
	oprot.WriteMessageEnd()
	oprot.Flush()
	return
}

func (p *HeartsClient) recvGetRoundResult() (value *RoundResult, ex *GameException, err error) {
	iprot := p.InputProtocol
	if iprot == nil {
		iprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.InputProtocol = iprot
	}
	_, mTypeId, seqId, err := iprot.ReadMessageBegin()
	if err != nil {
		return
	}
	if mTypeId == thrift.EXCEPTION {
		error27 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
		var error28 error
		error28, err = error27.Read(iprot)
		if err != nil {
			return
		}
		if err = iprot.ReadMessageEnd(); err != nil {
			return
		}
		err = error28
		return
	}
	if p.SeqId != seqId {
		err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "ping failed: out of sequence response")
		return
	}
	result26 := NewGetRoundResultResult()
	err = result26.Read(iprot)
	iprot.ReadMessageEnd()
	value = result26.Success
	if result26.Ex != nil {
		ex = result26.Ex
	}
	return
}

// Parameters:
//  - Ticket
func (p *HeartsClient) GetGameResult(ticket *Ticket) (r *GameResult, ex *GameException, err error) {
	if err = p.sendGetGameResult(ticket); err != nil {
		return
	}
	return p.recvGetGameResult()
}

func (p *HeartsClient) sendGetGameResult(ticket *Ticket) (err error) {
	oprot := p.OutputProtocol
	if oprot == nil {
		oprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.OutputProtocol = oprot
	}
	p.SeqId++
	oprot.WriteMessageBegin("get_game_result", thrift.CALL, p.SeqId)
	args29 := NewGetGameResultArgs()
	args29.Ticket = ticket
	err = args29.Write(oprot)
	oprot.WriteMessageEnd()
	oprot.Flush()
	return
}

func (p *HeartsClient) recvGetGameResult() (value *GameResult, ex *GameException, err error) {
	iprot := p.InputProtocol
	if iprot == nil {
		iprot = p.ProtocolFactory.GetProtocol(p.Transport)
		p.InputProtocol = iprot
	}
	_, mTypeId, seqId, err := iprot.ReadMessageBegin()
	if err != nil {
		return
	}
	if mTypeId == thrift.EXCEPTION {
		error31 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
		var error32 error
		error32, err = error31.Read(iprot)
		if err != nil {
			return
		}
		if err = iprot.ReadMessageEnd(); err != nil {
			return
		}
		err = error32
		return
	}
	if p.SeqId != seqId {
		err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "ping failed: out of sequence response")
		return
	}
	result30 := NewGetGameResultResult()
	err = result30.Read(iprot)
	iprot.ReadMessageEnd()
	value = result30.Success
	if result30.Ex != nil {
		ex = result30.Ex
	}
	return
}

type HeartsProcessor struct {
	processorMap map[string]thrift.TProcessorFunction
	handler      Hearts
}

func (p *HeartsProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
	p.processorMap[key] = processor
}

func (p *HeartsProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
	processor, ok = p.processorMap[key]
	return processor, ok
}

func (p *HeartsProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
	return p.processorMap
}

func NewHeartsProcessor(handler Hearts) *HeartsProcessor {

	self33 := &HeartsProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)}
	self33.processorMap["enter_arena"] = &heartsProcessorEnterArena{handler: handler}
	self33.processorMap["get_game_info"] = &heartsProcessorGetGameInfo{handler: handler}
	self33.processorMap["get_hand"] = &heartsProcessorGetHand{handler: handler}
	self33.processorMap["pass_cards"] = &heartsProcessorPassCards{handler: handler}
	self33.processorMap["get_trick"] = &heartsProcessorGetTrick{handler: handler}
	self33.processorMap["play_card"] = &heartsProcessorPlayCard{handler: handler}
	self33.processorMap["get_round_result"] = &heartsProcessorGetRoundResult{handler: handler}
	self33.processorMap["get_game_result"] = &heartsProcessorGetGameResult{handler: handler}
	return self33
}

func (p *HeartsProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
	name, _, seqId, err := iprot.ReadMessageBegin()
	if err != nil {
		return false, err
	}
	if processor, ok := p.GetProcessorFunction(name); ok {
		return processor.Process(seqId, iprot, oprot)
	}
	iprot.Skip(thrift.STRUCT)
	iprot.ReadMessageEnd()
	x34 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
	oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
	x34.Write(oprot)
	oprot.WriteMessageEnd()
	oprot.Flush()
	return false, x34

}

type heartsProcessorEnterArena struct {
	handler Hearts
}

func (p *heartsProcessorEnterArena) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
	args := NewEnterArenaArgs()
	if err = args.Read(iprot); err != nil {
		iprot.ReadMessageEnd()
		x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
		oprot.WriteMessageBegin("enter_arena", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	iprot.ReadMessageEnd()
	result := NewEnterArenaResult()
	if result.Success, err = p.handler.EnterArena(args.Request); err != nil {
		x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing enter_arena: "+err.Error())
		oprot.WriteMessageBegin("enter_arena", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	if err2 := oprot.WriteMessageBegin("enter_arena", thrift.REPLY, seqId); err2 != nil {
		err = err2
	}
	if err2 := result.Write(oprot); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.WriteMessageEnd(); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.Flush(); err == nil && err2 != nil {
		err = err2
	}
	if err != nil {
		return
	}
	return true, err
}

type heartsProcessorGetGameInfo struct {
	handler Hearts
}

func (p *heartsProcessorGetGameInfo) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
	args := NewGetGameInfoArgs()
	if err = args.Read(iprot); err != nil {
		iprot.ReadMessageEnd()
		x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
		oprot.WriteMessageBegin("get_game_info", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	iprot.ReadMessageEnd()
	result := NewGetGameInfoResult()
	if result.Success, result.Ex, err = p.handler.GetGameInfo(args.Ticket); err != nil {
		x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing get_game_info: "+err.Error())
		oprot.WriteMessageBegin("get_game_info", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	if err2 := oprot.WriteMessageBegin("get_game_info", thrift.REPLY, seqId); err2 != nil {
		err = err2
	}
	if err2 := result.Write(oprot); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.WriteMessageEnd(); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.Flush(); err == nil && err2 != nil {
		err = err2
	}
	if err != nil {
		return
	}
	return true, err
}

type heartsProcessorGetHand struct {
	handler Hearts
}

func (p *heartsProcessorGetHand) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
	args := NewGetHandArgs()
	if err = args.Read(iprot); err != nil {
		iprot.ReadMessageEnd()
		x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
		oprot.WriteMessageBegin("get_hand", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	iprot.ReadMessageEnd()
	result := NewGetHandResult()
	if result.Success, result.Ex, err = p.handler.GetHand(args.Ticket); err != nil {
		x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing get_hand: "+err.Error())
		oprot.WriteMessageBegin("get_hand", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	if err2 := oprot.WriteMessageBegin("get_hand", thrift.REPLY, seqId); err2 != nil {
		err = err2
	}
	if err2 := result.Write(oprot); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.WriteMessageEnd(); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.Flush(); err == nil && err2 != nil {
		err = err2
	}
	if err != nil {
		return
	}
	return true, err
}

type heartsProcessorPassCards struct {
	handler Hearts
}

func (p *heartsProcessorPassCards) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
	args := NewPassCardsArgs()
	if err = args.Read(iprot); err != nil {
		iprot.ReadMessageEnd()
		x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
		oprot.WriteMessageBegin("pass_cards", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	iprot.ReadMessageEnd()
	result := NewPassCardsResult()
	if result.Success, result.Ex, err = p.handler.PassCards(args.Ticket, args.Cards); err != nil {
		x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing pass_cards: "+err.Error())
		oprot.WriteMessageBegin("pass_cards", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	if err2 := oprot.WriteMessageBegin("pass_cards", thrift.REPLY, seqId); err2 != nil {
		err = err2
	}
	if err2 := result.Write(oprot); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.WriteMessageEnd(); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.Flush(); err == nil && err2 != nil {
		err = err2
	}
	if err != nil {
		return
	}
	return true, err
}

type heartsProcessorGetTrick struct {
	handler Hearts
}

func (p *heartsProcessorGetTrick) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
	args := NewGetTrickArgs()
	if err = args.Read(iprot); err != nil {
		iprot.ReadMessageEnd()
		x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
		oprot.WriteMessageBegin("get_trick", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	iprot.ReadMessageEnd()
	result := NewGetTrickResult()
	if result.Success, result.Ex, err = p.handler.GetTrick(args.Ticket); err != nil {
		x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing get_trick: "+err.Error())
		oprot.WriteMessageBegin("get_trick", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	if err2 := oprot.WriteMessageBegin("get_trick", thrift.REPLY, seqId); err2 != nil {
		err = err2
	}
	if err2 := result.Write(oprot); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.WriteMessageEnd(); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.Flush(); err == nil && err2 != nil {
		err = err2
	}
	if err != nil {
		return
	}
	return true, err
}

type heartsProcessorPlayCard struct {
	handler Hearts
}

func (p *heartsProcessorPlayCard) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
	args := NewPlayCardArgs()
	if err = args.Read(iprot); err != nil {
		iprot.ReadMessageEnd()
		x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
		oprot.WriteMessageBegin("play_card", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	iprot.ReadMessageEnd()
	result := NewPlayCardResult()
	if result.Success, result.Ex, err = p.handler.PlayCard(args.Ticket, args.Card); err != nil {
		x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing play_card: "+err.Error())
		oprot.WriteMessageBegin("play_card", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	if err2 := oprot.WriteMessageBegin("play_card", thrift.REPLY, seqId); err2 != nil {
		err = err2
	}
	if err2 := result.Write(oprot); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.WriteMessageEnd(); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.Flush(); err == nil && err2 != nil {
		err = err2
	}
	if err != nil {
		return
	}
	return true, err
}

type heartsProcessorGetRoundResult struct {
	handler Hearts
}

func (p *heartsProcessorGetRoundResult) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
	args := NewGetRoundResultArgs()
	if err = args.Read(iprot); err != nil {
		iprot.ReadMessageEnd()
		x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
		oprot.WriteMessageBegin("get_round_result", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	iprot.ReadMessageEnd()
	result := NewGetRoundResultResult()
	if result.Success, result.Ex, err = p.handler.GetRoundResult(args.Ticket); err != nil {
		x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing get_round_result: "+err.Error())
		oprot.WriteMessageBegin("get_round_result", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	if err2 := oprot.WriteMessageBegin("get_round_result", thrift.REPLY, seqId); err2 != nil {
		err = err2
	}
	if err2 := result.Write(oprot); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.WriteMessageEnd(); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.Flush(); err == nil && err2 != nil {
		err = err2
	}
	if err != nil {
		return
	}
	return true, err
}

type heartsProcessorGetGameResult struct {
	handler Hearts
}

func (p *heartsProcessorGetGameResult) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
	args := NewGetGameResultArgs()
	if err = args.Read(iprot); err != nil {
		iprot.ReadMessageEnd()
		x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
		oprot.WriteMessageBegin("get_game_result", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	iprot.ReadMessageEnd()
	result := NewGetGameResultResult()
	if result.Success, result.Ex, err = p.handler.GetGameResult(args.Ticket); err != nil {
		x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing get_game_result: "+err.Error())
		oprot.WriteMessageBegin("get_game_result", thrift.EXCEPTION, seqId)
		x.Write(oprot)
		oprot.WriteMessageEnd()
		oprot.Flush()
		return
	}
	if err2 := oprot.WriteMessageBegin("get_game_result", thrift.REPLY, seqId); err2 != nil {
		err = err2
	}
	if err2 := result.Write(oprot); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.WriteMessageEnd(); err == nil && err2 != nil {
		err = err2
	}
	if err2 := oprot.Flush(); err == nil && err2 != nil {
		err = err2
	}
	if err != nil {
		return
	}
	return true, err
}

// HELPER FUNCTIONS AND STRUCTURES

type EnterArenaArgs struct {
	Request *EntryRequest `thrift:"request,1,required"`
}

func NewEnterArenaArgs() *EnterArenaArgs {
	return &EnterArenaArgs{}
}

func (p *EnterArenaArgs) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *EnterArenaArgs) readField1(iprot thrift.TProtocol) error {
	p.Request = NewEntryRequest()
	if err := p.Request.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Request)
	}
	return nil
}

func (p *EnterArenaArgs) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("enter_arena_args"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	if err := p.writeField1(oprot); err != nil {
		return err
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *EnterArenaArgs) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Request != nil {
		if err := oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:request: %s", p, err)
		}
		if err := p.Request.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Request)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:request: %s", p, err)
		}
	}
	return err
}

func (p *EnterArenaArgs) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("EnterArenaArgs(%+v)", *p)
}

type EnterArenaResult struct {
	Success *EntryResponse `thrift:"success,0"`
}

func NewEnterArenaResult() *EnterArenaResult {
	return &EnterArenaResult{}
}

func (p *EnterArenaResult) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 0:
			if err := p.readField0(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *EnterArenaResult) readField0(iprot thrift.TProtocol) error {
	p.Success = NewEntryResponse()
	if err := p.Success.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Success)
	}
	return nil
}

func (p *EnterArenaResult) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("enter_arena_result"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	switch {
	default:
		if err := p.writeField0(oprot); err != nil {
			return err
		}
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *EnterArenaResult) writeField0(oprot thrift.TProtocol) (err error) {
	if p.Success != nil {
		if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
			return fmt.Errorf("%T write field begin error 0:success: %s", p, err)
		}
		if err := p.Success.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Success)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 0:success: %s", p, err)
		}
	}
	return err
}

func (p *EnterArenaResult) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("EnterArenaResult(%+v)", *p)
}

type GetGameInfoArgs struct {
	Ticket *Ticket `thrift:"ticket,1,required"`
}

func NewGetGameInfoArgs() *GetGameInfoArgs {
	return &GetGameInfoArgs{}
}

func (p *GetGameInfoArgs) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *GetGameInfoArgs) readField1(iprot thrift.TProtocol) error {
	p.Ticket = NewTicket()
	if err := p.Ticket.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ticket)
	}
	return nil
}

func (p *GetGameInfoArgs) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("get_game_info_args"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	if err := p.writeField1(oprot); err != nil {
		return err
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *GetGameInfoArgs) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ticket != nil {
		if err := oprot.WriteFieldBegin("ticket", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ticket: %s", p, err)
		}
		if err := p.Ticket.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ticket)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ticket: %s", p, err)
		}
	}
	return err
}

func (p *GetGameInfoArgs) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("GetGameInfoArgs(%+v)", *p)
}

type GetGameInfoResult struct {
	Success *GameInfo      `thrift:"success,0"`
	Ex      *GameException `thrift:"ex,1"`
}

func NewGetGameInfoResult() *GetGameInfoResult {
	return &GetGameInfoResult{}
}

func (p *GetGameInfoResult) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 0:
			if err := p.readField0(iprot); err != nil {
				return err
			}
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *GetGameInfoResult) readField0(iprot thrift.TProtocol) error {
	p.Success = NewGameInfo()
	if err := p.Success.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Success)
	}
	return nil
}

func (p *GetGameInfoResult) readField1(iprot thrift.TProtocol) error {
	p.Ex = NewGameException()
	if err := p.Ex.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ex)
	}
	return nil
}

func (p *GetGameInfoResult) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("get_game_info_result"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	switch {
	case p.Ex != nil:
		if err := p.writeField1(oprot); err != nil {
			return err
		}
	default:
		if err := p.writeField0(oprot); err != nil {
			return err
		}
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *GetGameInfoResult) writeField0(oprot thrift.TProtocol) (err error) {
	if p.Success != nil {
		if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
			return fmt.Errorf("%T write field begin error 0:success: %s", p, err)
		}
		if err := p.Success.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Success)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 0:success: %s", p, err)
		}
	}
	return err
}

func (p *GetGameInfoResult) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ex != nil {
		if err := oprot.WriteFieldBegin("ex", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ex: %s", p, err)
		}
		if err := p.Ex.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ex)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ex: %s", p, err)
		}
	}
	return err
}

func (p *GetGameInfoResult) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("GetGameInfoResult(%+v)", *p)
}

type GetHandArgs struct {
	Ticket *Ticket `thrift:"ticket,1,required"`
}

func NewGetHandArgs() *GetHandArgs {
	return &GetHandArgs{}
}

func (p *GetHandArgs) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *GetHandArgs) readField1(iprot thrift.TProtocol) error {
	p.Ticket = NewTicket()
	if err := p.Ticket.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ticket)
	}
	return nil
}

func (p *GetHandArgs) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("get_hand_args"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	if err := p.writeField1(oprot); err != nil {
		return err
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *GetHandArgs) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ticket != nil {
		if err := oprot.WriteFieldBegin("ticket", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ticket: %s", p, err)
		}
		if err := p.Ticket.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ticket)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ticket: %s", p, err)
		}
	}
	return err
}

func (p *GetHandArgs) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("GetHandArgs(%+v)", *p)
}

type GetHandResult struct {
	Success []*Card        `thrift:"success,0"`
	Ex      *GameException `thrift:"ex,1"`
}

func NewGetHandResult() *GetHandResult {
	return &GetHandResult{}
}

func (p *GetHandResult) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 0:
			if err := p.readField0(iprot); err != nil {
				return err
			}
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *GetHandResult) readField0(iprot thrift.TProtocol) error {
	_, size, err := iprot.ReadListBegin()
	if err != nil {
		return fmt.Errorf("error reading list being: %s")
	}
	p.Success = make([]*Card, 0, size)
	for i := 0; i < size; i++ {
		_elem35 := NewCard()
		if err := _elem35.Read(iprot); err != nil {
			return fmt.Errorf("%T error reading struct: %s", _elem35)
		}
		p.Success = append(p.Success, _elem35)
	}
	if err := iprot.ReadListEnd(); err != nil {
		return fmt.Errorf("error reading list end: %s")
	}
	return nil
}

func (p *GetHandResult) readField1(iprot thrift.TProtocol) error {
	p.Ex = NewGameException()
	if err := p.Ex.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ex)
	}
	return nil
}

func (p *GetHandResult) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("get_hand_result"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	switch {
	case p.Ex != nil:
		if err := p.writeField1(oprot); err != nil {
			return err
		}
	default:
		if err := p.writeField0(oprot); err != nil {
			return err
		}
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *GetHandResult) writeField0(oprot thrift.TProtocol) (err error) {
	if p.Success != nil {
		if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil {
			return fmt.Errorf("%T write field begin error 0:success: %s", p, err)
		}
		if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Success)); err != nil {
			return fmt.Errorf("error writing list begin: %s")
		}
		for _, v := range p.Success {
			if err := v.Write(oprot); err != nil {
				return fmt.Errorf("%T error writing struct: %s", v)
			}
		}
		if err := oprot.WriteListEnd(); err != nil {
			return fmt.Errorf("error writing list end: %s")
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 0:success: %s", p, err)
		}
	}
	return err
}

func (p *GetHandResult) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ex != nil {
		if err := oprot.WriteFieldBegin("ex", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ex: %s", p, err)
		}
		if err := p.Ex.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ex)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ex: %s", p, err)
		}
	}
	return err
}

func (p *GetHandResult) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("GetHandResult(%+v)", *p)
}

type PassCardsArgs struct {
	Ticket *Ticket `thrift:"ticket,1,required"`
	Cards  []*Card `thrift:"cards,2,required"`
}

func NewPassCardsArgs() *PassCardsArgs {
	return &PassCardsArgs{}
}

func (p *PassCardsArgs) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		case 2:
			if err := p.readField2(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *PassCardsArgs) readField1(iprot thrift.TProtocol) error {
	p.Ticket = NewTicket()
	if err := p.Ticket.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ticket)
	}
	return nil
}

func (p *PassCardsArgs) readField2(iprot thrift.TProtocol) error {
	_, size, err := iprot.ReadListBegin()
	if err != nil {
		return fmt.Errorf("error reading list being: %s")
	}
	p.Cards = make([]*Card, 0, size)
	for i := 0; i < size; i++ {
		_elem36 := NewCard()
		if err := _elem36.Read(iprot); err != nil {
			return fmt.Errorf("%T error reading struct: %s", _elem36)
		}
		p.Cards = append(p.Cards, _elem36)
	}
	if err := iprot.ReadListEnd(); err != nil {
		return fmt.Errorf("error reading list end: %s")
	}
	return nil
}

func (p *PassCardsArgs) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("pass_cards_args"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	if err := p.writeField1(oprot); err != nil {
		return err
	}
	if err := p.writeField2(oprot); err != nil {
		return err
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *PassCardsArgs) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ticket != nil {
		if err := oprot.WriteFieldBegin("ticket", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ticket: %s", p, err)
		}
		if err := p.Ticket.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ticket)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ticket: %s", p, err)
		}
	}
	return err
}

func (p *PassCardsArgs) writeField2(oprot thrift.TProtocol) (err error) {
	if p.Cards != nil {
		if err := oprot.WriteFieldBegin("cards", thrift.LIST, 2); err != nil {
			return fmt.Errorf("%T write field begin error 2:cards: %s", p, err)
		}
		if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Cards)); err != nil {
			return fmt.Errorf("error writing list begin: %s")
		}
		for _, v := range p.Cards {
			if err := v.Write(oprot); err != nil {
				return fmt.Errorf("%T error writing struct: %s", v)
			}
		}
		if err := oprot.WriteListEnd(); err != nil {
			return fmt.Errorf("error writing list end: %s")
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 2:cards: %s", p, err)
		}
	}
	return err
}

func (p *PassCardsArgs) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("PassCardsArgs(%+v)", *p)
}

type PassCardsResult struct {
	Success []*Card        `thrift:"success,0"`
	Ex      *GameException `thrift:"ex,1"`
}

func NewPassCardsResult() *PassCardsResult {
	return &PassCardsResult{}
}

func (p *PassCardsResult) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 0:
			if err := p.readField0(iprot); err != nil {
				return err
			}
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *PassCardsResult) readField0(iprot thrift.TProtocol) error {
	_, size, err := iprot.ReadListBegin()
	if err != nil {
		return fmt.Errorf("error reading list being: %s")
	}
	p.Success = make([]*Card, 0, size)
	for i := 0; i < size; i++ {
		_elem37 := NewCard()
		if err := _elem37.Read(iprot); err != nil {
			return fmt.Errorf("%T error reading struct: %s", _elem37)
		}
		p.Success = append(p.Success, _elem37)
	}
	if err := iprot.ReadListEnd(); err != nil {
		return fmt.Errorf("error reading list end: %s")
	}
	return nil
}

func (p *PassCardsResult) readField1(iprot thrift.TProtocol) error {
	p.Ex = NewGameException()
	if err := p.Ex.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ex)
	}
	return nil
}

func (p *PassCardsResult) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("pass_cards_result"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	switch {
	case p.Ex != nil:
		if err := p.writeField1(oprot); err != nil {
			return err
		}
	default:
		if err := p.writeField0(oprot); err != nil {
			return err
		}
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *PassCardsResult) writeField0(oprot thrift.TProtocol) (err error) {
	if p.Success != nil {
		if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil {
			return fmt.Errorf("%T write field begin error 0:success: %s", p, err)
		}
		if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Success)); err != nil {
			return fmt.Errorf("error writing list begin: %s")
		}
		for _, v := range p.Success {
			if err := v.Write(oprot); err != nil {
				return fmt.Errorf("%T error writing struct: %s", v)
			}
		}
		if err := oprot.WriteListEnd(); err != nil {
			return fmt.Errorf("error writing list end: %s")
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 0:success: %s", p, err)
		}
	}
	return err
}

func (p *PassCardsResult) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ex != nil {
		if err := oprot.WriteFieldBegin("ex", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ex: %s", p, err)
		}
		if err := p.Ex.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ex)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ex: %s", p, err)
		}
	}
	return err
}

func (p *PassCardsResult) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("PassCardsResult(%+v)", *p)
}

type GetTrickArgs struct {
	Ticket *Ticket `thrift:"ticket,1,required"`
}

func NewGetTrickArgs() *GetTrickArgs {
	return &GetTrickArgs{}
}

func (p *GetTrickArgs) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *GetTrickArgs) readField1(iprot thrift.TProtocol) error {
	p.Ticket = NewTicket()
	if err := p.Ticket.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ticket)
	}
	return nil
}

func (p *GetTrickArgs) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("get_trick_args"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	if err := p.writeField1(oprot); err != nil {
		return err
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *GetTrickArgs) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ticket != nil {
		if err := oprot.WriteFieldBegin("ticket", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ticket: %s", p, err)
		}
		if err := p.Ticket.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ticket)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ticket: %s", p, err)
		}
	}
	return err
}

func (p *GetTrickArgs) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("GetTrickArgs(%+v)", *p)
}

type GetTrickResult struct {
	Success *Trick         `thrift:"success,0"`
	Ex      *GameException `thrift:"ex,1"`
}

func NewGetTrickResult() *GetTrickResult {
	return &GetTrickResult{}
}

func (p *GetTrickResult) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 0:
			if err := p.readField0(iprot); err != nil {
				return err
			}
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *GetTrickResult) readField0(iprot thrift.TProtocol) error {
	p.Success = NewTrick()
	if err := p.Success.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Success)
	}
	return nil
}

func (p *GetTrickResult) readField1(iprot thrift.TProtocol) error {
	p.Ex = NewGameException()
	if err := p.Ex.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ex)
	}
	return nil
}

func (p *GetTrickResult) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("get_trick_result"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	switch {
	case p.Ex != nil:
		if err := p.writeField1(oprot); err != nil {
			return err
		}
	default:
		if err := p.writeField0(oprot); err != nil {
			return err
		}
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *GetTrickResult) writeField0(oprot thrift.TProtocol) (err error) {
	if p.Success != nil {
		if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
			return fmt.Errorf("%T write field begin error 0:success: %s", p, err)
		}
		if err := p.Success.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Success)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 0:success: %s", p, err)
		}
	}
	return err
}

func (p *GetTrickResult) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ex != nil {
		if err := oprot.WriteFieldBegin("ex", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ex: %s", p, err)
		}
		if err := p.Ex.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ex)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ex: %s", p, err)
		}
	}
	return err
}

func (p *GetTrickResult) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("GetTrickResult(%+v)", *p)
}

type PlayCardArgs struct {
	Ticket *Ticket `thrift:"ticket,1,required"`
	Card   *Card   `thrift:"card,2,required"`
}

func NewPlayCardArgs() *PlayCardArgs {
	return &PlayCardArgs{}
}

func (p *PlayCardArgs) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		case 2:
			if err := p.readField2(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *PlayCardArgs) readField1(iprot thrift.TProtocol) error {
	p.Ticket = NewTicket()
	if err := p.Ticket.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ticket)
	}
	return nil
}

func (p *PlayCardArgs) readField2(iprot thrift.TProtocol) error {
	p.Card = NewCard()
	if err := p.Card.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Card)
	}
	return nil
}

func (p *PlayCardArgs) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("play_card_args"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	if err := p.writeField1(oprot); err != nil {
		return err
	}
	if err := p.writeField2(oprot); err != nil {
		return err
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *PlayCardArgs) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ticket != nil {
		if err := oprot.WriteFieldBegin("ticket", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ticket: %s", p, err)
		}
		if err := p.Ticket.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ticket)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ticket: %s", p, err)
		}
	}
	return err
}

func (p *PlayCardArgs) writeField2(oprot thrift.TProtocol) (err error) {
	if p.Card != nil {
		if err := oprot.WriteFieldBegin("card", thrift.STRUCT, 2); err != nil {
			return fmt.Errorf("%T write field begin error 2:card: %s", p, err)
		}
		if err := p.Card.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Card)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 2:card: %s", p, err)
		}
	}
	return err
}

func (p *PlayCardArgs) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("PlayCardArgs(%+v)", *p)
}

type PlayCardResult struct {
	Success *Trick         `thrift:"success,0"`
	Ex      *GameException `thrift:"ex,1"`
}

func NewPlayCardResult() *PlayCardResult {
	return &PlayCardResult{}
}

func (p *PlayCardResult) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 0:
			if err := p.readField0(iprot); err != nil {
				return err
			}
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *PlayCardResult) readField0(iprot thrift.TProtocol) error {
	p.Success = NewTrick()
	if err := p.Success.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Success)
	}
	return nil
}

func (p *PlayCardResult) readField1(iprot thrift.TProtocol) error {
	p.Ex = NewGameException()
	if err := p.Ex.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ex)
	}
	return nil
}

func (p *PlayCardResult) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("play_card_result"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	switch {
	case p.Ex != nil:
		if err := p.writeField1(oprot); err != nil {
			return err
		}
	default:
		if err := p.writeField0(oprot); err != nil {
			return err
		}
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *PlayCardResult) writeField0(oprot thrift.TProtocol) (err error) {
	if p.Success != nil {
		if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
			return fmt.Errorf("%T write field begin error 0:success: %s", p, err)
		}
		if err := p.Success.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Success)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 0:success: %s", p, err)
		}
	}
	return err
}

func (p *PlayCardResult) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ex != nil {
		if err := oprot.WriteFieldBegin("ex", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ex: %s", p, err)
		}
		if err := p.Ex.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ex)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ex: %s", p, err)
		}
	}
	return err
}

func (p *PlayCardResult) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("PlayCardResult(%+v)", *p)
}

type GetRoundResultArgs struct {
	Ticket *Ticket `thrift:"ticket,1,required"`
}

func NewGetRoundResultArgs() *GetRoundResultArgs {
	return &GetRoundResultArgs{}
}

func (p *GetRoundResultArgs) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *GetRoundResultArgs) readField1(iprot thrift.TProtocol) error {
	p.Ticket = NewTicket()
	if err := p.Ticket.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ticket)
	}
	return nil
}

func (p *GetRoundResultArgs) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("get_round_result_args"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	if err := p.writeField1(oprot); err != nil {
		return err
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *GetRoundResultArgs) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ticket != nil {
		if err := oprot.WriteFieldBegin("ticket", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ticket: %s", p, err)
		}
		if err := p.Ticket.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ticket)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ticket: %s", p, err)
		}
	}
	return err
}

func (p *GetRoundResultArgs) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("GetRoundResultArgs(%+v)", *p)
}

type GetRoundResultResult struct {
	Success *RoundResult   `thrift:"success,0"`
	Ex      *GameException `thrift:"ex,1"`
}

func NewGetRoundResultResult() *GetRoundResultResult {
	return &GetRoundResultResult{}
}

func (p *GetRoundResultResult) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 0:
			if err := p.readField0(iprot); err != nil {
				return err
			}
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *GetRoundResultResult) readField0(iprot thrift.TProtocol) error {
	p.Success = NewRoundResult()
	if err := p.Success.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Success)
	}
	return nil
}

func (p *GetRoundResultResult) readField1(iprot thrift.TProtocol) error {
	p.Ex = NewGameException()
	if err := p.Ex.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ex)
	}
	return nil
}

func (p *GetRoundResultResult) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("get_round_result_result"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	switch {
	case p.Ex != nil:
		if err := p.writeField1(oprot); err != nil {
			return err
		}
	default:
		if err := p.writeField0(oprot); err != nil {
			return err
		}
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *GetRoundResultResult) writeField0(oprot thrift.TProtocol) (err error) {
	if p.Success != nil {
		if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
			return fmt.Errorf("%T write field begin error 0:success: %s", p, err)
		}
		if err := p.Success.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Success)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 0:success: %s", p, err)
		}
	}
	return err
}

func (p *GetRoundResultResult) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ex != nil {
		if err := oprot.WriteFieldBegin("ex", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ex: %s", p, err)
		}
		if err := p.Ex.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ex)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ex: %s", p, err)
		}
	}
	return err
}

func (p *GetRoundResultResult) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("GetRoundResultResult(%+v)", *p)
}

type GetGameResultArgs struct {
	Ticket *Ticket `thrift:"ticket,1,required"`
}

func NewGetGameResultArgs() *GetGameResultArgs {
	return &GetGameResultArgs{}
}

func (p *GetGameResultArgs) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *GetGameResultArgs) readField1(iprot thrift.TProtocol) error {
	p.Ticket = NewTicket()
	if err := p.Ticket.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ticket)
	}
	return nil
}

func (p *GetGameResultArgs) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("get_game_result_args"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	if err := p.writeField1(oprot); err != nil {
		return err
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *GetGameResultArgs) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ticket != nil {
		if err := oprot.WriteFieldBegin("ticket", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ticket: %s", p, err)
		}
		if err := p.Ticket.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ticket)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ticket: %s", p, err)
		}
	}
	return err
}

func (p *GetGameResultArgs) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("GetGameResultArgs(%+v)", *p)
}

type GetGameResultResult struct {
	Success *GameResult    `thrift:"success,0"`
	Ex      *GameException `thrift:"ex,1"`
}

func NewGetGameResultResult() *GetGameResultResult {
	return &GetGameResultResult{}
}

func (p *GetGameResultResult) Read(iprot thrift.TProtocol) error {
	if _, err := iprot.ReadStructBegin(); err != nil {
		return fmt.Errorf("%T read error", p)
	}
	for {
		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
		if err != nil {
			return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
		}
		if fieldTypeId == thrift.STOP {
			break
		}
		switch fieldId {
		case 0:
			if err := p.readField0(iprot); err != nil {
				return err
			}
		case 1:
			if err := p.readField1(iprot); err != nil {
				return err
			}
		default:
			if err := iprot.Skip(fieldTypeId); err != nil {
				return err
			}
		}
		if err := iprot.ReadFieldEnd(); err != nil {
			return err
		}
	}
	if err := iprot.ReadStructEnd(); err != nil {
		return fmt.Errorf("%T read struct end error: %s", p, err)
	}
	return nil
}

func (p *GetGameResultResult) readField0(iprot thrift.TProtocol) error {
	p.Success = NewGameResult()
	if err := p.Success.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Success)
	}
	return nil
}

func (p *GetGameResultResult) readField1(iprot thrift.TProtocol) error {
	p.Ex = NewGameException()
	if err := p.Ex.Read(iprot); err != nil {
		return fmt.Errorf("%T error reading struct: %s", p.Ex)
	}
	return nil
}

func (p *GetGameResultResult) Write(oprot thrift.TProtocol) error {
	if err := oprot.WriteStructBegin("get_game_result_result"); err != nil {
		return fmt.Errorf("%T write struct begin error: %s", p, err)
	}
	switch {
	case p.Ex != nil:
		if err := p.writeField1(oprot); err != nil {
			return err
		}
	default:
		if err := p.writeField0(oprot); err != nil {
			return err
		}
	}
	if err := oprot.WriteFieldStop(); err != nil {
		return fmt.Errorf("%T write field stop error: %s", err)
	}
	if err := oprot.WriteStructEnd(); err != nil {
		return fmt.Errorf("%T write struct stop error: %s", err)
	}
	return nil
}

func (p *GetGameResultResult) writeField0(oprot thrift.TProtocol) (err error) {
	if p.Success != nil {
		if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
			return fmt.Errorf("%T write field begin error 0:success: %s", p, err)
		}
		if err := p.Success.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Success)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 0:success: %s", p, err)
		}
	}
	return err
}

func (p *GetGameResultResult) writeField1(oprot thrift.TProtocol) (err error) {
	if p.Ex != nil {
		if err := oprot.WriteFieldBegin("ex", thrift.STRUCT, 1); err != nil {
			return fmt.Errorf("%T write field begin error 1:ex: %s", p, err)
		}
		if err := p.Ex.Write(oprot); err != nil {
			return fmt.Errorf("%T error writing struct: %s", p.Ex)
		}
		if err := oprot.WriteFieldEnd(); err != nil {
			return fmt.Errorf("%T write field end error 1:ex: %s", p, err)
		}
	}
	return err
}

func (p *GetGameResultResult) String() string {
	if p == nil {
		return "<nil>"
	}
	return fmt.Sprintf("GetGameResultResult(%+v)", *p)
}
