package pet

import (
	"blazing/logic/service/common"
	"blazing/logic/service/player"
	"blazing/logic/service/space"
	"blazing/modules/blazing/model"
)

type InInfo struct {
	Head player.TomeeHeader `cmd:"2301" struc:"[0]pad"`

	CatchTime uint32
}

type OutInfo struct {
	model.PetInfo
}

// PetReleaseOutboundInfo 宠物释放出站消息
type PetReleaseOutboundInfo struct {
	HomeEnergy   uint32 `json:"home_energy" fieldDescription:"暂定0" autoCodec:"true" uint:"true"`
	FirstPetTime uint32 `json:"first_pet_time" fieldDescription:"精灵生成时间" autoCodec:"true" uint:"true"`
	Flag         uint32
	PetInfo      model.PetInfo `json:"pet_info" fieldDescription:"精灵信息" autoCodec:"true"`
}

// 放入背包或者加入仓库
type PetReleaseInboundInfo struct {
	Head      player.TomeeHeader `cmd:"2304" struc:"[0]pad"`
	CatchTime uint32             `json:"catch_time" fieldDescription:"精灵生成时间" autoCodec:"true" uint:"true"`
	Flag      uint32             `json:"flag" fieldDescription:"0为放入仓库，1为放入背包" autoCodec:"true" uint:"true"`
}

type PetShowInboundInfo struct {
	Head player.TomeeHeader `cmd:"2305" struc:"[0]pad"`

	CatchTime uint32 `codec:"catchTime" inboundMessageType:"Pet_Show"`
	Flag      uint32 `codec:"flag"`
}

func (t *PetShowInboundInfo) Broadcast(mapid uint32, o PetShowOutboundInfo) {

	space.GetSpace(mapid).Range(func(playerID uint32, player common.PlayerI) bool {
		t.Head.Result = 0

		player.SendPack(t.Head.Pack(&o))
		return true
	})
}

type PetShowOutboundInfo struct {
	UserID    uint32 `codec:"UserID" description:"米米号"`
	CatchTime uint32 `codec:"CatchTime" description:"精灵获得的时间"`
	ID        uint32 `codec:"PetID" description:"精灵编号"`
	Flag      uint32 `codec:"flag" description:"1为显示 0为收回"`
	Dv        uint32 `codec:"dv" description:"个体"`
	Shiny     uint32 `codec:"shiny" description:"闪光状态标识"`
	SkinID    uint32 `codec:"skinID" description:"皮肤ID"`
	Reserved1 [3]uint32
}
type PetOneCureInboundInfo struct {
	Head      player.TomeeHeader `cmd:"2310" struc:"[0]pad"`
	CatchTime uint32             `json:"catchTime" fieldDescription:"精灵捕捉时间" uint:"true"`
} // PetOneCureOutboundInfo 宠物单个治疗出站消息
type PetOneCureOutboundInfo struct {
	CatchTime uint32 `json:"catchTime" fieldDescription:"精灵捕捉时间" uint:"true"`
}

// PetDefaultInboundInfo
// 实现了InboundMessage接口
type PetDefaultInboundInfo struct {
	Head      player.TomeeHeader `cmd:"2308" struc:"[0]pad"`
	CatchTime uint32             `json:"catchTime" fieldDescription:"精灵捕捉时间" uint:"true" autoCodec:"true" inboundMessageType:"Pet_Default"`
}

// PetDefaultOutboundInfo
// 实现了OutboundMessage接口
type PetDefaultOutboundInfo struct {
	IsDefault uint32 `json:"isDefault" fieldDescription:"0: 首发设置失败，1: 首发设置成功" uint:"true" autoCodec:"true" outboundMessageType:"Pet_Default"`
}
