package tienlen

import (
	tienlenApi "mongo.games.com/game/api3th/smart/tienlen"
	"mongo.games.com/game/proto"
	proto_tienlen "mongo.games.com/game/protocol/tienlen"
	"mongo.games.com/game/robot/base"
)

var TienLenNilPlayer *TienLenPlayer = nil

type TienLenPlayer struct {
	base.BasePlayer
	*proto_tienlen.TienLenPlayerData
	data *tienlenApi.PredictRequest
}

func NewTienLenPlayer(data *proto_tienlen.TienLenPlayerData) *TienLenPlayer {
	p := &TienLenPlayer{TienLenPlayerData: data}
	p.Init()
	return p
}

func (p *TienLenPlayer) Init() {
	p.Clear()
}

func (p *TienLenPlayer) Clear() {

}

func (p *TienLenPlayer) MarkFlag(flag int32) {
	myFlag := p.GetFlag()
	myFlag |= flag
	p.Flag = proto.Int32(myFlag)
}

func (p *TienLenPlayer) UnmarkFlag(flag int32) {
	myFlag := p.GetFlag()
	myFlag &= ^flag
	p.Flag = proto.Int32(myFlag)
}

func (p *TienLenPlayer) IsMarkFlag(flag int32) bool {
	if (p.GetFlag() & flag) != 0 {
		return true
	}
	return false
}

func (p *TienLenPlayer) IsOnLine() bool {
	return p.IsMarkFlag(base.PlayerState_Online)
}

func (p *TienLenPlayer) IsReady() bool {
	return true
}

func (p *TienLenPlayer) IsSceneOwner() bool {
	return false
}

func (p *TienLenPlayer) CanOp() bool {
	return true
}

func (p *TienLenPlayer) IsRobot() bool {
	player := base.PlayerMgrSingleton.GetPlayer(p.GetSnId())
	return player != nil
}

func (p *TienLenPlayer) SetFlag(flag int32) {
	p.Flag = proto.Int32(flag)
}

func (p *TienLenPlayer) GetLastOp() int32 {
	return 0
}

func (p *TienLenPlayer) SetLastOp(op int32) {
}

func (p *TienLenPlayer) UpdateCards(cards []int32) {
}
