Merge branch 'main' of https://cnb.cool/blzing/blazing
This commit is contained in:
@@ -16,8 +16,10 @@ import (
|
||||
|
||||
"github.com/gogf/gf/v2/os/glog"
|
||||
"github.com/lunixbochs/struc"
|
||||
"github.com/panjf2000/gnet/v2"
|
||||
)
|
||||
|
||||
// Maincontroller 是控制器层共享变量。
|
||||
var Maincontroller = &Controller{} //注入service
|
||||
|
||||
// Controller 分发cmd逻辑实现
|
||||
@@ -44,19 +46,14 @@ func ParseCmd[T any](data []byte) T {
|
||||
// Init 初始化控制器,注册所有cmd处理方法
|
||||
// 参数 isGame: 标识是否为游戏服务器(true)或登录服务器(false)
|
||||
func Init(isGame bool) {
|
||||
// 获取控制器实例的反射值
|
||||
controllerValue := reflect.ValueOf(Maincontroller)
|
||||
|
||||
// 获取控制器类型
|
||||
controllerType := controllerValue.Type()
|
||||
|
||||
// 遍历控制器的所有方法
|
||||
for i := 0; i < controllerType.NumMethod(); i++ {
|
||||
method := controllerType.Method(i)
|
||||
methodValue := controllerValue.MethodByName(method.Name)
|
||||
methodValue := controllerValue.Method(i)
|
||||
methodType := methodValue.Type()
|
||||
|
||||
// 获取方法第一个参数的类型(请求结构体)
|
||||
if methodType.NumIn() == 0 {
|
||||
continue
|
||||
}
|
||||
@@ -67,43 +64,46 @@ func Init(isGame bool) {
|
||||
continue
|
||||
}
|
||||
reqType := reqArgType.Elem()
|
||||
binding := getCmdBinding(reqType)
|
||||
|
||||
// 解析请求结构体中的cmd标签
|
||||
for _, cmd := range getCmd(reqType) {
|
||||
if cmd == 0 { // 说明不是有效的注册方法
|
||||
for _, cmd := range binding.cmds {
|
||||
if cmd == 0 {
|
||||
glog.Warning(context.Background(), "方法参数必须包含CMD参数", method.Name, "跳过注册")
|
||||
continue
|
||||
}
|
||||
|
||||
// 根据服务器类型过滤cmd
|
||||
// 登录服务器只处理小于1000的cmd
|
||||
if methodType.NumIn() != 2 {
|
||||
glog.Warning(context.Background(), "方法参数数量必须为2", method.Name, "跳过注册")
|
||||
continue
|
||||
}
|
||||
|
||||
if !isGame && cmd > 1000 {
|
||||
continue
|
||||
}
|
||||
|
||||
// 游戏服务器只处理大于等于1000的cmd
|
||||
if isGame && cmd < 1000 {
|
||||
continue
|
||||
}
|
||||
|
||||
// 注册命令处理函数
|
||||
if cool.Config.ServerInfo.IsDebug != 0 {
|
||||
fmt.Println("注册方法", cmd, method.Name)
|
||||
}
|
||||
|
||||
cmdInfo := cool.Cmd{
|
||||
Func: methodValue,
|
||||
Req: reqType,
|
||||
|
||||
// Res: , // TODO 待实现对不同用户初始化方法以取消全局cmdcache
|
||||
}
|
||||
// 预编译创建req实例的函数:返回结构体指针
|
||||
reqTypeForNew := reqType
|
||||
cmdInfo.NewReqFunc = func() interface{} {
|
||||
return reflect.New(reqTypeForNew).Interface()
|
||||
cmdInfo := cool.Cmd{
|
||||
Func: methodValue,
|
||||
Req: reqType,
|
||||
HeaderFieldIndex: append([]int(nil), binding.headerFieldIndex...),
|
||||
UseConn: methodType.In(1) == connType,
|
||||
NewReqFunc: func() interface{} {
|
||||
return reflect.New(reqTypeForNew).Interface()
|
||||
},
|
||||
NewReqValue: func() reflect.Value {
|
||||
return reflect.New(reqTypeForNew)
|
||||
},
|
||||
}
|
||||
|
||||
if _, exists := cool.CmdCache[cmd]; exists { // 方法已存在
|
||||
if _, exists := cool.CmdCache[cmd]; exists {
|
||||
panic(fmt.Sprintf("命令处理方法已存在,跳过注册 %d %s", cmd, method.Name))
|
||||
}
|
||||
cool.CmdCache[cmd] = cmdInfo
|
||||
@@ -111,12 +111,20 @@ func Init(isGame bool) {
|
||||
}
|
||||
}
|
||||
|
||||
var targetType = reflect.TypeOf(common.TomeeHeader{})
|
||||
var cmdTypeCache sync.Map
|
||||
var (
|
||||
targetType = reflect.TypeOf(common.TomeeHeader{})
|
||||
connType = reflect.TypeOf((*gnet.Conn)(nil)).Elem()
|
||||
cmdTypeCache sync.Map
|
||||
)
|
||||
|
||||
// 默认返回值(无匹配字段/解析失败时)
|
||||
const defaultCmdValue = 0
|
||||
|
||||
type cmdBinding struct {
|
||||
cmds []uint32
|
||||
headerFieldIndex []int
|
||||
}
|
||||
|
||||
func normalizeStructType(typ reflect.Type) reflect.Type {
|
||||
for typ.Kind() == reflect.Ptr {
|
||||
typ = typ.Elem()
|
||||
@@ -124,92 +132,93 @@ func normalizeStructType(typ reflect.Type) reflect.Type {
|
||||
return typ
|
||||
}
|
||||
|
||||
// getCmd 从结构体类型中提取绑定的cmd指令(递归查找嵌套结构体,支持值/指针类型的TomeeHeader)
|
||||
// 参数 typ: 待解析的结构体类型(支持多层指针)
|
||||
// 返回值: 解析到的cmd切片,无匹配/解析失败时返回[defaultCmdValue]
|
||||
func getCmd(typ reflect.Type) []uint32 {
|
||||
// getCmdBinding 从结构体类型中提取绑定的cmd指令和头字段位置。
|
||||
func getCmdBinding(typ reflect.Type) cmdBinding {
|
||||
typ = normalizeStructType(typ)
|
||||
if cached, ok := cmdTypeCache.Load(typ); ok {
|
||||
return cached.([]uint32)
|
||||
return cached.(cmdBinding)
|
||||
}
|
||||
|
||||
// 非结构体类型直接返回默认值
|
||||
if typ.Kind() != reflect.Struct {
|
||||
return []uint32{defaultCmdValue}
|
||||
binding := cmdBinding{cmds: []uint32{defaultCmdValue}}
|
||||
cmdTypeCache.Store(typ, binding)
|
||||
return binding
|
||||
}
|
||||
|
||||
if cmd, ok := findCmd(typ, make(map[reflect.Type]struct{})); ok {
|
||||
cmdTypeCache.Store(typ, cmd)
|
||||
return cmd
|
||||
if binding, ok := findCmdBinding(typ, make(map[reflect.Type]struct{})); ok {
|
||||
cmdTypeCache.Store(typ, binding)
|
||||
return binding
|
||||
}
|
||||
|
||||
// 未找到目标字段/所有解析失败,返回默认值
|
||||
defaultCmd := []uint32{defaultCmdValue}
|
||||
cmdTypeCache.Store(typ, defaultCmd)
|
||||
return defaultCmd
|
||||
binding := cmdBinding{cmds: []uint32{defaultCmdValue}}
|
||||
cmdTypeCache.Store(typ, binding)
|
||||
return binding
|
||||
}
|
||||
|
||||
func findCmd(typ reflect.Type, visiting map[reflect.Type]struct{}) ([]uint32, bool) {
|
||||
func findCmdBinding(typ reflect.Type, visiting map[reflect.Type]struct{}) (cmdBinding, bool) {
|
||||
typ = normalizeStructType(typ)
|
||||
if typ.Kind() != reflect.Struct {
|
||||
return nil, false
|
||||
return cmdBinding{}, false
|
||||
}
|
||||
if _, seen := visiting[typ]; seen {
|
||||
return nil, false
|
||||
return cmdBinding{}, false
|
||||
}
|
||||
visiting[typ] = struct{}{}
|
||||
defer delete(visiting, typ)
|
||||
|
||||
// 遍历结构体字段,查找TomeeHeader字段并解析cmd
|
||||
for i := 0; i < typ.NumField(); i++ {
|
||||
field := typ.Field(i)
|
||||
|
||||
// 尝试解析当前字段的cmd标签
|
||||
cmdSlice, isHeader, err := parseCmdTagWithStructField(field)
|
||||
if isHeader && err == nil { // 解析成功,直接返回结果
|
||||
return cmdSlice, true
|
||||
if isHeader && err == nil {
|
||||
return cmdBinding{
|
||||
cmds: cmdSlice,
|
||||
headerFieldIndex: append([]int(nil), field.Index...),
|
||||
}, true
|
||||
}
|
||||
|
||||
// 递归处理嵌套结构体(值/指针类型)
|
||||
nestedTyp := normalizeStructType(field.Type)
|
||||
if nestedTyp.Kind() == reflect.Struct {
|
||||
// 递归查找,找到有效cmd则立即返回
|
||||
if nestedCmd, ok := findCmd(nestedTyp, visiting); ok {
|
||||
return nestedCmd, true
|
||||
}
|
||||
if nestedTyp.Kind() != reflect.Struct {
|
||||
continue
|
||||
}
|
||||
|
||||
nestedBinding, ok := findCmdBinding(nestedTyp, visiting)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
fieldIndex := make([]int, 0, len(field.Index)+len(nestedBinding.headerFieldIndex))
|
||||
fieldIndex = append(fieldIndex, field.Index...)
|
||||
fieldIndex = append(fieldIndex, nestedBinding.headerFieldIndex...)
|
||||
nestedBinding.headerFieldIndex = fieldIndex
|
||||
return nestedBinding, true
|
||||
}
|
||||
|
||||
return nil, false
|
||||
return cmdBinding{}, false
|
||||
}
|
||||
|
||||
// parseCmdTagWithStructField 校验字段是否为TomeeHeader(值/指针)并解析cmd标签
|
||||
// 参数 field: 结构体字段元信息
|
||||
// 返回值: 解析后的cmd切片,是否为目标类型,解析失败错误
|
||||
func parseCmdTagWithStructField(field reflect.StructField) ([]uint32, bool, error) {
|
||||
// 判断字段类型是否为 TomeeHeader 或 *TomeeHeader
|
||||
if field.Type != targetType && !(field.Type.Kind() == reflect.Ptr && field.Type.Elem() == targetType) {
|
||||
return nil, false, nil
|
||||
}
|
||||
|
||||
// 提取cmd标签
|
||||
cmdStr := field.Tag.Get("cmd")
|
||||
if cmdStr == "" {
|
||||
return nil, true, fmt.Errorf("field %s cmd tag is empty", field.Name)
|
||||
}
|
||||
|
||||
// 高性能解析标签为uint32切片(替代gconv,减少第三方依赖且可控)
|
||||
result := make([]uint32, 0, strings.Count(cmdStr, "|")+1)
|
||||
remain := cmdStr
|
||||
for idx := 0; ; idx++ {
|
||||
part, next, found := strings.Cut(remain, "|")
|
||||
// 去除空白字符(兼容标签中意外的空格)
|
||||
s := strings.TrimSpace(part)
|
||||
if s == "" {
|
||||
return nil, true, fmt.Errorf("field %s cmd tag part %d is empty", field.Name, idx)
|
||||
}
|
||||
|
||||
// 手动解析uint32,比gconv更可控,避免隐式转换问题
|
||||
num, err := strconv.ParseUint(s, 10, 32)
|
||||
if err != nil {
|
||||
return nil, true, fmt.Errorf("field %s cmd tag part %d parse error: %v (value: %s)",
|
||||
|
||||
@@ -43,6 +43,7 @@ var masterCupRequiredItems = map[uint32][]ItemS{
|
||||
},
|
||||
}
|
||||
|
||||
// DASHIbei 处理控制器请求。
|
||||
func (h Controller) DASHIbei(req *C2s_MASTER_REWARDS, c *player.Player) (result *S2C_MASTER_REWARDS, err errorcode.ErrorCode) {
|
||||
_ = req
|
||||
result = &S2C_MASTER_REWARDS{}
|
||||
@@ -52,6 +53,7 @@ func (h Controller) DASHIbei(req *C2s_MASTER_REWARDS, c *player.Player) (result
|
||||
return
|
||||
}
|
||||
|
||||
// DASHIbeiR 处理控制器请求。
|
||||
func (h Controller) DASHIbeiR(req *C2s_MASTER_REWARDSR, c *player.Player) (result *S2C_MASTER_REWARDSR, err errorcode.ErrorCode) {
|
||||
result = &S2C_MASTER_REWARDSR{}
|
||||
|
||||
@@ -94,6 +96,7 @@ func (h Controller) DASHIbeiR(req *C2s_MASTER_REWARDSR, c *player.Player) (resul
|
||||
return
|
||||
}
|
||||
|
||||
// ItemS 定义请求或响应数据结构。
|
||||
type ItemS struct {
|
||||
ItemId uint32
|
||||
ItemCnt uint32
|
||||
@@ -137,6 +140,7 @@ func appendMasterCupRewardItems(c *player.Player, result *S2C_MASTER_REWARDSR, i
|
||||
}
|
||||
}
|
||||
|
||||
// C2s_MASTER_REWARDS 定义请求或响应数据结构。
|
||||
type C2s_MASTER_REWARDS struct {
|
||||
Head common.TomeeHeader `cmd:"2611" struc:"skip"` //玩家登录
|
||||
}
|
||||
@@ -147,6 +151,7 @@ type S2C_MASTER_REWARDS struct {
|
||||
Reward []uint32 `json:"Reward"`
|
||||
}
|
||||
|
||||
// C2s_MASTER_REWARDSR 定义请求或响应数据结构。
|
||||
type C2s_MASTER_REWARDSR struct {
|
||||
Head common.TomeeHeader `cmd:"2612" struc:"skip"` //玩家登录
|
||||
ElementType uint32
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
)
|
||||
|
||||
// EggGamePlay 处理控制器请求。
|
||||
func (h Controller) EggGamePlay(data1 *C2S_EGG_GAME_PLAY, c *player.Player) (result *S2C_EGG_GAME_PLAY, err errorcode.ErrorCode) {
|
||||
|
||||
switch data1.EggNum {
|
||||
|
||||
@@ -37,6 +37,7 @@ func Draw15To10WithBitSet() uint32 {
|
||||
return resultBits
|
||||
}
|
||||
|
||||
// GET_XUANCAI 处理控制器请求。
|
||||
func (h Controller) GET_XUANCAI(data *C2s_GET_XUANCAI, c *player.Player) (result *S2C_GET_XUANCAI, err errorcode.ErrorCode) {
|
||||
result = &S2C_GET_XUANCAI{}
|
||||
selectedCount := 0 // 已选中的数量
|
||||
@@ -74,6 +75,7 @@ func (h Controller) GET_XUANCAI(data *C2s_GET_XUANCAI, c *player.Player) (result
|
||||
|
||||
}
|
||||
|
||||
// C2s_GET_XUANCAI 定义请求或响应数据结构。
|
||||
type C2s_GET_XUANCAI struct {
|
||||
Head common.TomeeHeader `cmd:"60001" struc:"skip"` //玩家登录
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ func (h Controller) TimeMap(data *C2s_SP, c *player.Player) (result *S2C_SP, err
|
||||
|
||||
}
|
||||
|
||||
// C2s_SP 定义请求或响应数据结构。
|
||||
type C2s_SP struct {
|
||||
Head common.TomeeHeader `cmd:"60002" struc:"skip"` //超时空地图
|
||||
}
|
||||
@@ -40,6 +41,7 @@ type S2C_SP struct {
|
||||
MapList []ServerInfo
|
||||
}
|
||||
|
||||
// ServerInfo 定义请求或响应数据结构。
|
||||
type ServerInfo struct {
|
||||
ID uint32 //地图ID
|
||||
PetLen uint32 `struc:"sizeof=Pet"`
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"blazing/logic/service/player"
|
||||
)
|
||||
|
||||
// GetLeiyiTrainStatus 处理控制器请求。
|
||||
func (h Controller) GetLeiyiTrainStatus(data *C2s_LEIYI_TRAIN_GET_STATUS, c *player.Player) (result *S2C_LEIYI_TRAIN_GET_STATUS, err errorcode.ErrorCode) {
|
||||
result = &S2C_LEIYI_TRAIN_GET_STATUS{}
|
||||
|
||||
@@ -19,6 +20,7 @@ func (h Controller) GetLeiyiTrainStatus(data *C2s_LEIYI_TRAIN_GET_STATUS, c *pla
|
||||
|
||||
}
|
||||
|
||||
// C2s_LEIYI_TRAIN_GET_STATUS 定义请求或响应数据结构。
|
||||
type C2s_LEIYI_TRAIN_GET_STATUS struct {
|
||||
Head common.TomeeHeader `cmd:"2393" struc:"skip"` //玩家登录
|
||||
}
|
||||
@@ -28,6 +30,7 @@ type S2C_LEIYI_TRAIN_GET_STATUS struct {
|
||||
Status [10]S2C_LEIYI_TRAIN_GET_STATUS_info `json:"status"`
|
||||
}
|
||||
|
||||
// S2C_LEIYI_TRAIN_GET_STATUS_info 定义请求或响应数据结构。
|
||||
type S2C_LEIYI_TRAIN_GET_STATUS_info struct {
|
||||
// Today uint32 // 今日训练HP次数
|
||||
Current uint32 // 当前训练HP次数
|
||||
|
||||
@@ -35,6 +35,7 @@ func (h Controller) HanLiuQiang(data *C2S_2608, c *player.Player) (result *fight
|
||||
return result, -1
|
||||
}
|
||||
|
||||
// C2S_2608 定义请求或响应数据结构。
|
||||
type C2S_2608 struct {
|
||||
Head common.TomeeHeader `cmd:"2608" struc:"skip"`
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"blazing/logic/service/fight"
|
||||
"blazing/logic/service/fight/info"
|
||||
@@ -31,7 +30,7 @@ func (h Controller) UseSkill(data *UseSkillInInfo, c *player.Player) (result *fi
|
||||
if err := h.checkFightStatus(c); err != 0 {
|
||||
return nil, err
|
||||
}
|
||||
go c.FightC.UseSkill(c, data.SkillId)
|
||||
h.dispatchFightActionEnvelope(c, buildLegacyUseSkillEnvelope(data))
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
@@ -41,31 +40,7 @@ func (h Controller) UseSkillAt(data *UseSkillAtInboundInfo, c *player.Player) (r
|
||||
if err := h.checkFightStatus(c); err != 0 {
|
||||
return nil, err
|
||||
}
|
||||
actorIndex := int(data.ActorIndex)
|
||||
targetIndex := int(data.TargetIndex)
|
||||
targetRelation := data.TargetRelation
|
||||
|
||||
// 前端未显式给 relation 时,按 AtkType 兜底:3=自己,1=己方,其他按对方。
|
||||
if targetRelation > fight.SkillTargetAlly {
|
||||
switch data.AtkType {
|
||||
case 3:
|
||||
targetRelation = fight.SkillTargetSelf
|
||||
case 1:
|
||||
targetRelation = fight.SkillTargetAlly
|
||||
default:
|
||||
targetRelation = fight.SkillTargetOpponent
|
||||
}
|
||||
}
|
||||
|
||||
switch targetRelation {
|
||||
case fight.SkillTargetSelf:
|
||||
targetIndex = actorIndex
|
||||
go c.FightC.UseSkillAt(c, data.SkillId, actorIndex, fight.EncodeTargetIndex(targetIndex, false))
|
||||
case fight.SkillTargetAlly:
|
||||
go c.FightC.UseSkillAt(c, data.SkillId, actorIndex, fight.EncodeTargetIndex(targetIndex, false))
|
||||
default:
|
||||
go c.FightC.UseSkillAt(c, data.SkillId, actorIndex, fight.EncodeTargetIndex(targetIndex, true))
|
||||
}
|
||||
h.dispatchFightActionEnvelope(c, buildIndexedUseSkillEnvelope(data))
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
@@ -74,8 +49,7 @@ func (h Controller) Escape(data *EscapeFightInboundInfo, c *player.Player) (resu
|
||||
if err := h.checkFightStatus(c); err != 0 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
go c.FightC.Over(c, model.BattleOverReason.PlayerEscape)
|
||||
h.dispatchFightActionEnvelope(c, buildLegacyEscapeEnvelope())
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
@@ -84,7 +58,7 @@ func (h Controller) ChangePet(data *ChangePetInboundInfo, c *player.Player) (res
|
||||
if err := h.checkFightStatus(c); err != 0 {
|
||||
return nil, err
|
||||
}
|
||||
go c.FightC.ChangePet(c, data.CatchTime)
|
||||
h.dispatchFightActionEnvelope(c, buildLegacyChangeEnvelope(data))
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
@@ -123,7 +97,7 @@ func (h Controller) UsePetItemInboundInfo(data *UsePetItemInboundInfo, c *player
|
||||
}
|
||||
}
|
||||
|
||||
go c.FightC.UseItem(c, data.CatchTime, data.ItemId)
|
||||
h.dispatchFightActionEnvelope(c, buildLegacyUseItemEnvelope(data))
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
@@ -132,6 +106,6 @@ func (h Controller) FightChat(data *ChatInfo, c *player.Player) (result *fight.N
|
||||
if err := h.checkFightStatus(c); err != 0 {
|
||||
return nil, err
|
||||
}
|
||||
go c.FightC.Chat(c, data.Message)
|
||||
h.dispatchFightActionEnvelope(c, buildChatEnvelope(data))
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
@@ -27,7 +27,10 @@ func (Controller) PlayerFightBoss(req *ChallengeBossInboundInfo, p *player.Playe
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mapNode := service.NewMapNodeService().GetDataNode(p.Info.MapID, req.BossId)
|
||||
mapNode := p.GetSpace().GetMatchedMapNode(req.BossId)
|
||||
if mapNode == nil {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
bossConfigs, err := loadMapBossConfigs(mapNode)
|
||||
if err != 0 {
|
||||
return nil, err
|
||||
@@ -43,7 +46,8 @@ func (Controller) PlayerFightBoss(req *ChallengeBossInboundInfo, p *player.Playe
|
||||
|
||||
ai := player.NewAI_player(monsterInfo)
|
||||
ai.CanCapture = resolveBossCaptureRate(bossConfigs[0].IsCapture, leadMonsterID)
|
||||
ai.Prop[0] = 2
|
||||
ai.BossScript = bossConfigs[0].Script
|
||||
ai.AddBattleProp(0, 2)
|
||||
|
||||
var fightC *fight.FightC
|
||||
fightC, err = fight.NewFight(p, ai, p.GetPetInfo(100), ai.GetPetInfo(0), func(foi model.FightOverInfo) {
|
||||
|
||||
@@ -70,9 +70,12 @@ func (h Controller) PetMelee(data *StartPetWarInboundInfo, c *player.Player) (re
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// PetKing 处理控制器请求。
|
||||
func (h Controller) PetKing(data *PetKingJoinInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
|
||||
c.Fightinfo.Status = info.BattleMode.PET_TOPLEVEL
|
||||
// ElementTypeNumbers 是控制器层共享变量。
|
||||
var ElementTypeNumbers = []int{1, 2, 3, 5, 11, 4, 6, 7, 9}
|
||||
|
||||
switch data.Type {
|
||||
|
||||
@@ -55,7 +55,7 @@ func (h Controller) OnPlayerHandleFightInvite(data *HandleFightInviteInboundInfo
|
||||
return
|
||||
}
|
||||
|
||||
_, err = fight.NewFight(v, c, v.GetInfo().PetList, c.GetInfo().PetList, func(foi model.FightOverInfo) {
|
||||
_, err = fight.NewFight(v, c, v.GetPetInfo(100), c.GetPetInfo(100), func(foi model.FightOverInfo) {
|
||||
|
||||
//println("好友对战测试", foi.Reason)
|
||||
|
||||
|
||||
79
logic/controller/fight_unified.go
Normal file
79
logic/controller/fight_unified.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"blazing/logic/service/fight"
|
||||
"blazing/logic/service/player"
|
||||
)
|
||||
|
||||
// dispatchFightActionEnvelope 把控制器层收到的统一动作结构分发回现有 FightI 接口。
|
||||
func (h Controller) dispatchFightActionEnvelope(c *player.Player, envelope fight.FightActionEnvelope) {
|
||||
if c == nil || c.FightC == nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch envelope.ActionType {
|
||||
case fight.FightActionTypeSkill:
|
||||
go c.FightC.UseSkillAt(c, envelope.SkillID, envelope.ActorIndex, envelope.EncodedTargetIndex())
|
||||
case fight.FightActionTypeItem:
|
||||
go c.FightC.UseItemAt(c, envelope.CatchTime, envelope.ItemID, envelope.ActorIndex, envelope.EncodedTargetIndex())
|
||||
case fight.FightActionTypeChange:
|
||||
go c.FightC.ChangePetAt(c, envelope.CatchTime, envelope.ActorIndex)
|
||||
case fight.FightActionTypeEscape:
|
||||
go c.FightC.Over(c, model.BattleOverReason.PlayerEscape)
|
||||
case fight.FightActionTypeChat:
|
||||
go c.FightC.Chat(c, envelope.Chat)
|
||||
}
|
||||
}
|
||||
|
||||
// buildLegacyUseSkillEnvelope 把旧 2405 技能包映射成统一动作结构。
|
||||
func buildLegacyUseSkillEnvelope(data *UseSkillInInfo) fight.FightActionEnvelope {
|
||||
if data == nil {
|
||||
return fight.NewSkillActionEnvelope(0, 0, 0, fight.SkillTargetOpponent, 0)
|
||||
}
|
||||
return fight.NewSkillActionEnvelope(data.SkillId, 0, 0, fight.SkillTargetOpponent, 0)
|
||||
}
|
||||
|
||||
// buildIndexedUseSkillEnvelope 把 7505 多战位技能包映射成统一动作结构。
|
||||
func buildIndexedUseSkillEnvelope(data *UseSkillAtInboundInfo) fight.FightActionEnvelope {
|
||||
if data == nil {
|
||||
return fight.NewSkillActionEnvelope(0, 0, 0, fight.SkillTargetOpponent, 0)
|
||||
}
|
||||
return fight.NewSkillActionEnvelope(
|
||||
data.SkillId,
|
||||
int(data.ActorIndex),
|
||||
int(data.TargetIndex),
|
||||
data.TargetRelation,
|
||||
data.AtkType,
|
||||
)
|
||||
}
|
||||
|
||||
// buildLegacyUseItemEnvelope 把旧 2406 道具包映射成统一动作结构。
|
||||
func buildLegacyUseItemEnvelope(data *UsePetItemInboundInfo) fight.FightActionEnvelope {
|
||||
if data == nil {
|
||||
return fight.NewItemActionEnvelope(0, 0, 0, 0, fight.SkillTargetOpponent)
|
||||
}
|
||||
return fight.NewItemActionEnvelope(data.CatchTime, data.ItemId, 0, 0, fight.SkillTargetOpponent)
|
||||
}
|
||||
|
||||
// buildLegacyChangeEnvelope 把旧 2407 切宠包映射成统一动作结构。
|
||||
func buildLegacyChangeEnvelope(data *ChangePetInboundInfo) fight.FightActionEnvelope {
|
||||
if data == nil {
|
||||
return fight.NewChangeActionEnvelope(0, 0)
|
||||
}
|
||||
return fight.NewChangeActionEnvelope(data.CatchTime, 0)
|
||||
}
|
||||
|
||||
// buildLegacyEscapeEnvelope 构造旧 2410 逃跑包对应的统一动作结构。
|
||||
func buildLegacyEscapeEnvelope() fight.FightActionEnvelope {
|
||||
return fight.NewEscapeActionEnvelope()
|
||||
}
|
||||
|
||||
// buildChatEnvelope 把战斗聊天包映射成统一动作结构。
|
||||
func buildChatEnvelope(data *ChatInfo) fight.FightActionEnvelope {
|
||||
if data == nil {
|
||||
return fight.NewChatActionEnvelope("")
|
||||
}
|
||||
return fight.NewChatActionEnvelope(data.Message)
|
||||
}
|
||||
@@ -82,6 +82,7 @@ func (h Controller) FreshChoiceFightLevel(data *C2S_FRESH_CHOICE_FIGHT_LEVEL, c
|
||||
return result, 0
|
||||
}
|
||||
|
||||
// FreshLeaveFightLevel 处理控制器请求。
|
||||
func (h Controller) FreshLeaveFightLevel(data *FRESH_LEAVE_FIGHT_LEVEL, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
_ = data
|
||||
defer c.GetSpace().EnterMap(c)
|
||||
@@ -92,6 +93,7 @@ func (h Controller) FreshLeaveFightLevel(data *FRESH_LEAVE_FIGHT_LEVEL, c *playe
|
||||
return result, 0
|
||||
}
|
||||
|
||||
// PetTawor 处理控制器请求。
|
||||
func (h Controller) PetTawor(data *StartTwarInboundInfo, c *player.Player) (result *fight.S2C_ChoiceLevelRequestInfo, err errorcode.ErrorCode) {
|
||||
if err = c.CanFight(); err != 0 {
|
||||
return nil, err
|
||||
@@ -110,7 +112,7 @@ func (h Controller) PetTawor(data *StartTwarInboundInfo, c *player.Player) (resu
|
||||
result = &fight.S2C_ChoiceLevelRequestInfo{CurFightLevel: currentLevel}
|
||||
appendTowerNextBossPreview(&result.BossID, bossList)
|
||||
|
||||
monsterInfo, ok := buildTowerMonsterInfo(currentBoss)
|
||||
monsterInfo, bossScript, ok := buildTowerMonsterInfo(currentBoss)
|
||||
if !ok {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
@@ -119,6 +121,7 @@ func (h Controller) PetTawor(data *StartTwarInboundInfo, c *player.Player) (resu
|
||||
c.Fightinfo.Status = fightinfo.BattleMode.FIGHT_WITH_NPC
|
||||
|
||||
ai := player.NewAI_player(monsterInfo)
|
||||
ai.BossScript = bossScript
|
||||
_, err = fight.NewFight(c, ai, c.GetPetInfo(100), ai.GetPetInfo(0), func(foi model.FightOverInfo) {
|
||||
if foi.Reason != 0 || foi.WinnerId != c.Info.UserID {
|
||||
return
|
||||
@@ -195,10 +198,10 @@ func appendTowerNextBossPreview(dst *[]uint32, bossList []configmodel.BaseTowerC
|
||||
}
|
||||
}
|
||||
|
||||
func buildTowerMonsterInfo(towerBoss configmodel.BaseTowerConfig) (*model.PlayerInfo, bool) {
|
||||
func buildTowerMonsterInfo(towerBoss configmodel.BaseTowerConfig) (*model.PlayerInfo, string, bool) {
|
||||
bosses := service.NewBossService().Get(towerBoss.BossIds[0])
|
||||
if len(bosses) == 0 {
|
||||
return nil, false
|
||||
return nil, "", false
|
||||
}
|
||||
|
||||
monsterInfo := &model.PlayerInfo{Nick: towerBoss.Name}
|
||||
@@ -234,7 +237,7 @@ func buildTowerMonsterInfo(towerBoss configmodel.BaseTowerConfig) (*model.Player
|
||||
monsterInfo.PetList = append(monsterInfo.PetList, *monster)
|
||||
}
|
||||
|
||||
return monsterInfo, true
|
||||
return monsterInfo, bosses[0].Script, true
|
||||
}
|
||||
|
||||
func handleTowerFightWin(c *player.Player, cmd uint32, taskID int, currentLevel uint32) {
|
||||
|
||||
@@ -15,6 +15,7 @@ type PetTOPLEVELnboundInfo struct {
|
||||
|
||||
}
|
||||
|
||||
// JoINtop 处理控制器请求。
|
||||
func (h Controller) JoINtop(data *PetTOPLEVELnboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
err = pvp.JoinPeakQueue(c, data.Mode)
|
||||
if err != 0 {
|
||||
@@ -23,11 +24,13 @@ func (h Controller) JoINtop(data *PetTOPLEVELnboundInfo, c *player.Player) (resu
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
// CancelPeakQueue 处理控制器请求。
|
||||
func (h Controller) CancelPeakQueue(data *PeakQueueCancelInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
pvp.CancelPeakQueue(c)
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
// SubmitPeakBanPick 处理控制器请求。
|
||||
func (h Controller) SubmitPeakBanPick(data *PeakBanPickSubmitInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
err = pvp.SubmitBanPick(c, data.SelectedCatchTimes, data.BanCatchTimes)
|
||||
if err != 0 {
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"blazing/logic/service/space"
|
||||
)
|
||||
|
||||
// ARENA_SET_OWENR 定义请求或响应数据结构。
|
||||
type ARENA_SET_OWENR struct {
|
||||
Head common.TomeeHeader `cmd:"2417" struc:"skip"`
|
||||
}
|
||||
@@ -35,6 +36,7 @@ func (h Controller) ArenaSetOwner(data *ARENA_SET_OWENR, c *player.Player) (resu
|
||||
return nil, errorcode.ErrorCodes.ErrChampionExists
|
||||
}
|
||||
|
||||
// ARENA_FIGHT_OWENR 定义请求或响应数据结构。
|
||||
type ARENA_FIGHT_OWENR struct {
|
||||
Head common.TomeeHeader `cmd:"2418" struc:"skip"`
|
||||
}
|
||||
|
||||
@@ -2,56 +2,66 @@ package controller
|
||||
|
||||
import "blazing/logic/service/common"
|
||||
|
||||
// FightNpcMonsterInboundInfo 定义请求或响应数据结构。
|
||||
type FightNpcMonsterInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2408" struc:"skip"`
|
||||
Number uint32 `fieldDesc:"地图刷新怪物结构体对应的序号 1 - 9 的位置序号" `
|
||||
}
|
||||
|
||||
// ChallengeBossInboundInfo 定义请求或响应数据结构。
|
||||
type ChallengeBossInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2411" struc:"skip"`
|
||||
BossId uint32 `json:"bossId"`
|
||||
}
|
||||
|
||||
// ReadyToFightInboundInfo 定义请求或响应数据结构。
|
||||
type ReadyToFightInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2404" struc:"skip"`
|
||||
}
|
||||
|
||||
// EscapeFightInboundInfo 定义请求或响应数据结构。
|
||||
type EscapeFightInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2410" struc:"skip"`
|
||||
}
|
||||
|
||||
// StartPetWarInboundInfo 定义请求或响应数据结构。
|
||||
type StartPetWarInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2431" struc:"skip"`
|
||||
}
|
||||
|
||||
// StartTwarInboundInfo 定义请求或响应数据结构。
|
||||
type StartTwarInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2429|2415|2425" struc:"skip"`
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ARENA_GET_INFO 定义请求或响应数据结构。
|
||||
type ARENA_GET_INFO struct {
|
||||
Head common.TomeeHeader `cmd:"2419" struc:"skip"`
|
||||
}
|
||||
|
||||
// ARENA_UPFIGHT 定义请求或响应数据结构。
|
||||
type ARENA_UPFIGHT struct {
|
||||
Head common.TomeeHeader `cmd:"2420" struc:"skip"`
|
||||
}
|
||||
|
||||
// ARENA_OWENR_ACCE 定义请求或响应数据结构。
|
||||
type ARENA_OWENR_ACCE struct {
|
||||
Head common.TomeeHeader `cmd:"2422" struc:"skip"`
|
||||
}
|
||||
|
||||
// PetKingJoinInboundInfo 定义请求或响应数据结构。
|
||||
type PetKingJoinInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2413" struc:"skip"`
|
||||
Type uint32
|
||||
FightType uint32
|
||||
}
|
||||
|
||||
// PeakQueueCancelInboundInfo 定义请求或响应数据结构。
|
||||
type PeakQueueCancelInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2459" struc:"skip"`
|
||||
}
|
||||
|
||||
// PeakBanPickSubmitInboundInfo 定义请求或响应数据结构。
|
||||
type PeakBanPickSubmitInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2460" struc:"skip"`
|
||||
|
||||
@@ -62,6 +72,7 @@ type PeakBanPickSubmitInboundInfo struct {
|
||||
BanCatchTimes []uint32 `json:"banCatchTimes"`
|
||||
}
|
||||
|
||||
// HandleFightInviteInboundInfo 定义请求或响应数据结构。
|
||||
type HandleFightInviteInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2403" struc:"skip"`
|
||||
UserID uint32 `json:"userId" codec:"userId,uint"`
|
||||
@@ -69,21 +80,25 @@ type HandleFightInviteInboundInfo struct {
|
||||
Mode uint32 `json:"mode" codec:"mode,uint"`
|
||||
}
|
||||
|
||||
// InviteToFightInboundInfo 定义请求或响应数据结构。
|
||||
type InviteToFightInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2401" struc:"skip"`
|
||||
UserID uint32
|
||||
Mode uint32
|
||||
}
|
||||
|
||||
// InviteFightCancelInboundInfo 定义请求或响应数据结构。
|
||||
type InviteFightCancelInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2402" struc:"skip"`
|
||||
}
|
||||
|
||||
// UseSkillInInfo 定义请求或响应数据结构。
|
||||
type UseSkillInInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2405" struc:"skip"`
|
||||
SkillId uint32
|
||||
}
|
||||
|
||||
// UseSkillAtInboundInfo 定义请求或响应数据结构。
|
||||
type UseSkillAtInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"7505" struc:"skip"`
|
||||
SkillId uint32 `json:"skillId"`
|
||||
@@ -93,21 +108,25 @@ type UseSkillAtInboundInfo struct {
|
||||
AtkType uint8 `json:"atkType"`
|
||||
}
|
||||
|
||||
// ChangePetInboundInfo 定义请求或响应数据结构。
|
||||
type ChangePetInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2407" struc:"skip"`
|
||||
CatchTime uint32 `json:"catchTime"`
|
||||
}
|
||||
|
||||
// CatchMonsterInboundInfo 定义请求或响应数据结构。
|
||||
type CatchMonsterInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2409" struc:"skip"`
|
||||
CapsuleId uint32 `json:"capsuleId" fieldDescription:"胶囊id" uint:"true"`
|
||||
}
|
||||
|
||||
// LoadPercentInboundInfo 定义请求或响应数据结构。
|
||||
type LoadPercentInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2441" struc:"skip"`
|
||||
Percent uint32 `fieldDescription:"加载百分比"`
|
||||
}
|
||||
|
||||
// UsePetItemInboundInfo 定义请求或响应数据结构。
|
||||
type UsePetItemInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2406" struc:"skip"`
|
||||
CatchTime uint32 `description:"精灵捕获时间" codec:"catchTime"`
|
||||
@@ -115,6 +134,7 @@ type UsePetItemInboundInfo struct {
|
||||
Reversed1 uint32 `description:"填充字段 0" codec:"reversed1"`
|
||||
}
|
||||
|
||||
// ChatInfo 定义请求或响应数据结构。
|
||||
type ChatInfo struct {
|
||||
Head common.TomeeHeader `cmd:"50002" struc:"skip"`
|
||||
Reserve uint32 `json:"reserve" fieldDescription:"填充 默认值为0" uint:"true"`
|
||||
@@ -122,16 +142,19 @@ type ChatInfo struct {
|
||||
Message string `json:"message" fieldDescription:"消息内容, 结束符为utf-8的数字0"`
|
||||
}
|
||||
|
||||
// C2S_FRESH_CHOICE_FIGHT_LEVEL 定义请求或响应数据结构。
|
||||
type C2S_FRESH_CHOICE_FIGHT_LEVEL struct {
|
||||
Head common.TomeeHeader `cmd:"2428|2414" struc:"skip"`
|
||||
Level uint `json:"level"`
|
||||
}
|
||||
|
||||
// C2S_OPEN_DARKPORTAL 定义请求或响应数据结构。
|
||||
type C2S_OPEN_DARKPORTAL struct {
|
||||
Head common.TomeeHeader `cmd:"2424" struc:"skip"`
|
||||
Level uint32 `json:"level"`
|
||||
}
|
||||
|
||||
// FRESH_LEAVE_FIGHT_LEVEL 定义请求或响应数据结构。
|
||||
type FRESH_LEAVE_FIGHT_LEVEL struct {
|
||||
Head common.TomeeHeader `cmd:"2430|2416|2426" struc:"skip"`
|
||||
}
|
||||
|
||||
@@ -2,50 +2,59 @@ package controller
|
||||
|
||||
import "blazing/logic/service/common"
|
||||
|
||||
// SeeOnlineInboundInfo 定义请求或响应数据结构。
|
||||
type SeeOnlineInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2157" struc:"skip"`
|
||||
UserIdsLen uint32 `json:"userIdsLen" struc:"sizeof=UserIds"`
|
||||
UserIds []uint32 `json:"userIds" `
|
||||
}
|
||||
|
||||
// FriendAddInboundInfo 定义请求或响应数据结构。
|
||||
type FriendAddInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2151" struc:"skip"`
|
||||
UserID uint32 `json:"userID"`
|
||||
}
|
||||
|
||||
// FriendAnswerInboundInfo 定义请求或响应数据结构。
|
||||
type FriendAnswerInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2152" struc:"skip"`
|
||||
UserID uint32 `json:"userID"`
|
||||
Flag uint32 `json:"flag"`
|
||||
}
|
||||
|
||||
// FriendRemoveInboundInfo 定义请求或响应数据结构。
|
||||
type FriendRemoveInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2153" struc:"skip"`
|
||||
UserID uint32 `json:"userID"`
|
||||
}
|
||||
|
||||
// AcceptTaskInboundInfo 定义请求或响应数据结构。
|
||||
type AcceptTaskInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2201|2231" struc:"skip"`
|
||||
TaskId uint32 `json:"taskId" description:"任务ID"`
|
||||
}
|
||||
|
||||
// AddTaskBufInboundInfo 定义请求或响应数据结构。
|
||||
type AddTaskBufInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2204|2235" struc:"skip"`
|
||||
TaskId uint32 `json:"taskId" description:"任务ID"`
|
||||
TaskList []uint32 `struc:"[20]byte"`
|
||||
}
|
||||
|
||||
// CompleteTaskInboundInfo 定义请求或响应数据结构。
|
||||
type CompleteTaskInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2202|2233" struc:"skip"`
|
||||
TaskId uint32 `json:"taskId" description:"任务ID"`
|
||||
OutState uint32 `json:"outState" `
|
||||
}
|
||||
|
||||
// GetTaskBufInboundInfo 定义请求或响应数据结构。
|
||||
type GetTaskBufInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2203|2234" struc:"skip"`
|
||||
TaskId uint32 `json:"taskId" description:"任务ID"`
|
||||
}
|
||||
|
||||
// DeleteTaskInboundInfo 定义请求或响应数据结构。
|
||||
type DeleteTaskInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2205|2232" struc:"skip"`
|
||||
TaskId uint32 `json:"taskId" description:"任务ID"`
|
||||
|
||||
@@ -2,18 +2,21 @@ package controller
|
||||
|
||||
import "blazing/logic/service/common"
|
||||
|
||||
// BuyInboundInfo 定义请求或响应数据结构。
|
||||
type BuyInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2601" struc:"skip"`
|
||||
ItemId int64 `struc:"uint32"`
|
||||
Count int64 `struc:"uint32"`
|
||||
}
|
||||
|
||||
// BuyMultiInboundInfo 定义请求或响应数据结构。
|
||||
type BuyMultiInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2606" struc:"skip"`
|
||||
ItemListLen uint32 `struc:"sizeof=ItemIds"`
|
||||
ItemIds []uint32 `json:"itemIds" description:"购买的物品ID列表"`
|
||||
}
|
||||
|
||||
// C2S_GOLD_BUY_PRODUCT 定义请求或响应数据结构。
|
||||
type C2S_GOLD_BUY_PRODUCT struct {
|
||||
Head common.TomeeHeader `cmd:"1104" struc:"skip"`
|
||||
Type uint32 `json:"type"`
|
||||
@@ -21,6 +24,7 @@ type C2S_GOLD_BUY_PRODUCT struct {
|
||||
Count int64 `struc:"uint32"`
|
||||
}
|
||||
|
||||
// ItemListInboundInfo 定义请求或响应数据结构。
|
||||
type ItemListInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2605|4475" struc:"skip"`
|
||||
Param1 uint32
|
||||
@@ -28,36 +32,43 @@ type ItemListInboundInfo struct {
|
||||
Param3 uint32
|
||||
}
|
||||
|
||||
// GoldOnlineRemainInboundInfo 定义请求或响应数据结构。
|
||||
type GoldOnlineRemainInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"1105|1106" struc:"skip"`
|
||||
}
|
||||
|
||||
// ExpTotalRemainInboundInfo 定义请求或响应数据结构。
|
||||
type ExpTotalRemainInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2319" struc:"skip"`
|
||||
}
|
||||
|
||||
// ChangePlayerClothInboundInfo 定义请求或响应数据结构。
|
||||
type ChangePlayerClothInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2604" struc:"skip"`
|
||||
ClothesLen uint32 `struc:"sizeof=ClothList" fieldDesc:"穿戴装备的信息" json:"clothes_len"`
|
||||
ClothList []uint32 `description:"玩家装备列表" codec:"list"`
|
||||
}
|
||||
|
||||
// TalkCountInboundInfo 定义请求或响应数据结构。
|
||||
type TalkCountInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2701" struc:"skip"`
|
||||
ID uint32 `description:"奖品的Type, 即ID" codec:"uint"`
|
||||
}
|
||||
|
||||
// TalkCateInboundInfo 定义请求或响应数据结构。
|
||||
type TalkCateInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2702" struc:"skip"`
|
||||
ID uint32 `description:"奖品的Type, 即ID" codec:"uint"`
|
||||
}
|
||||
|
||||
// C2S_USE_PET_ITEM_OUT_OF_FIGHT 定义请求或响应数据结构。
|
||||
type C2S_USE_PET_ITEM_OUT_OF_FIGHT struct {
|
||||
Head common.TomeeHeader `cmd:"2326" struc:"skip"`
|
||||
CatchTime uint32 `json:"catch_time"`
|
||||
ItemID int32 `struc:"uint32"`
|
||||
}
|
||||
|
||||
// C2S_PET_RESET_NATURE 定义请求或响应数据结构。
|
||||
type C2S_PET_RESET_NATURE struct {
|
||||
Head common.TomeeHeader `cmd:"2343" struc:"skip"`
|
||||
CatchTime uint32
|
||||
@@ -65,22 +76,26 @@ type C2S_PET_RESET_NATURE struct {
|
||||
ItemId uint32
|
||||
}
|
||||
|
||||
// C2S_ITEM_SALE 定义请求或响应数据结构。
|
||||
type C2S_ITEM_SALE struct {
|
||||
Head common.TomeeHeader `cmd:"2602" struc:"skip"`
|
||||
ItemId uint32
|
||||
Amount uint32
|
||||
}
|
||||
|
||||
// C2S_USE_SPEEDUP_ITEM 定义请求或响应数据结构。
|
||||
type C2S_USE_SPEEDUP_ITEM struct {
|
||||
Head common.TomeeHeader `cmd:"2327" struc:"skip"`
|
||||
ItemID uint32
|
||||
}
|
||||
|
||||
// C2S_USE_ENERGY_XISHOU 定义请求或响应数据结构。
|
||||
type C2S_USE_ENERGY_XISHOU struct {
|
||||
Head common.TomeeHeader `cmd:"2331" struc:"skip"`
|
||||
ItemID uint32
|
||||
}
|
||||
|
||||
// C2S_USE_AUTO_FIGHT_ITEM 定义请求或响应数据结构。
|
||||
type C2S_USE_AUTO_FIGHT_ITEM struct {
|
||||
Head common.TomeeHeader `cmd:"2329" struc:"skip"`
|
||||
ItemID uint32
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
// EnterMapInboundInfo 定义请求或响应数据结构。
|
||||
type EnterMapInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2001" struc:"skip"`
|
||||
MapType uint32
|
||||
@@ -12,22 +13,27 @@ type EnterMapInboundInfo struct {
|
||||
Point model.Pos `fieldDesc:"直接给坐标x,y"`
|
||||
}
|
||||
|
||||
// GetMapHotInboundInfo 定义请求或响应数据结构。
|
||||
type GetMapHotInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"1004" struc:"skip"`
|
||||
}
|
||||
|
||||
// LeaveMapInboundInfo 定义请求或响应数据结构。
|
||||
type LeaveMapInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2002" struc:"skip"`
|
||||
}
|
||||
|
||||
// ListMapPlayerInboundInfo 定义请求或响应数据结构。
|
||||
type ListMapPlayerInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2003" struc:"skip"`
|
||||
}
|
||||
|
||||
// AttackBossInboundInfo 定义请求或响应数据结构。
|
||||
type AttackBossInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2412" struc:"skip"`
|
||||
}
|
||||
|
||||
// WalkInInfo 定义请求或响应数据结构。
|
||||
type WalkInInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2101" struc:"skip"`
|
||||
Flag uint32
|
||||
@@ -36,20 +42,24 @@ type WalkInInfo struct {
|
||||
Path string
|
||||
}
|
||||
|
||||
// FitmentUseringInboundInfo 定义请求或响应数据结构。
|
||||
type FitmentUseringInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"10006" struc:"skip"`
|
||||
TargetUserID uint32 `json:"targetUserId"`
|
||||
}
|
||||
|
||||
// PetRoomListInboundInfo 定义请求或响应数据结构。
|
||||
type PetRoomListInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2324" struc:"skip"`
|
||||
TargetUserID uint32 `json:"targetUserId"`
|
||||
}
|
||||
|
||||
// FitmentAllInboundEmpty 定义请求或响应数据结构。
|
||||
type FitmentAllInboundEmpty struct {
|
||||
Head common.TomeeHeader `cmd:"10007" struc:"skip"`
|
||||
}
|
||||
|
||||
// SET_FITMENT 定义请求或响应数据结构。
|
||||
type SET_FITMENT struct {
|
||||
Head common.TomeeHeader `cmd:"10008" struc:"skip"`
|
||||
RoomID uint32 `json:"roomID"`
|
||||
@@ -57,44 +67,52 @@ type SET_FITMENT struct {
|
||||
Fitments []model.FitmentShowInfo `json:"usedList"`
|
||||
}
|
||||
|
||||
// C2S_PetShowList 定义请求或响应数据结构。
|
||||
type C2S_PetShowList struct {
|
||||
CatchTime uint32 `json:"catchTime"`
|
||||
PetID uint32 `json:"petID"`
|
||||
}
|
||||
|
||||
// C2S_PET_ROOM_SHOW 定义请求或响应数据结构。
|
||||
type C2S_PET_ROOM_SHOW struct {
|
||||
Head common.TomeeHeader `cmd:"2323" struc:"skip"`
|
||||
PetShowInfoLen uint32 `json:"PetShowInfoLen" struc:"sizeof=PetShowList"`
|
||||
PetShowList []C2S_PetShowList `json:"PetShowList"`
|
||||
}
|
||||
|
||||
// C2S_RoomPetInfo 定义请求或响应数据结构。
|
||||
type C2S_RoomPetInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2325" struc:"skip"`
|
||||
UserID uint32 `json:"userID"`
|
||||
CatchTime uint32 `json:"catchTime"`
|
||||
}
|
||||
|
||||
// C2S_BUY_FITMENT 定义请求或响应数据结构。
|
||||
type C2S_BUY_FITMENT struct {
|
||||
Head common.TomeeHeader `cmd:"10004" struc:"skip"`
|
||||
ID uint32 `json:"id"`
|
||||
Count uint32 `json:"count"`
|
||||
}
|
||||
|
||||
// NonoInboundInfo 定义请求或响应数据结构。
|
||||
type NonoInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"9003" struc:"skip"`
|
||||
UserID uint32
|
||||
}
|
||||
|
||||
// NonoFollowOrHomeInInfo 定义请求或响应数据结构。
|
||||
type NonoFollowOrHomeInInfo struct {
|
||||
Head common.TomeeHeader `cmd:"9019" struc:"skip"`
|
||||
Flag uint32 `fieldDescription:"1为跟随 0为收回 且如果为收回 那么后续结构不需要发送" uint:"true"`
|
||||
}
|
||||
|
||||
// SwitchFlyingInboundInfo 定义请求或响应数据结构。
|
||||
type SwitchFlyingInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2112" struc:"skip"`
|
||||
Type uint32 `description:"开关, 0为取消飞行模式, 大于0为开启飞行模式" codec:"auto" uint:"true"`
|
||||
}
|
||||
|
||||
// PetCureInboundInfo 定义请求或响应数据结构。
|
||||
type PetCureInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2306" struc:"skip"`
|
||||
}
|
||||
|
||||
@@ -2,15 +2,18 @@ package controller
|
||||
|
||||
import "blazing/logic/service/common"
|
||||
|
||||
// GetPetInfoInboundInfo 定义请求或响应数据结构。
|
||||
type GetPetInfoInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2301" struc:"skip"`
|
||||
CatchTime uint32
|
||||
}
|
||||
|
||||
// GetUserBagPetInfoInboundEmpty 定义请求或响应数据结构。
|
||||
type GetUserBagPetInfoInboundEmpty struct {
|
||||
Head common.TomeeHeader `cmd:"4483" struc:"skip"`
|
||||
}
|
||||
|
||||
// SavePetBagOrderInboundInfo 定义请求或响应数据结构。
|
||||
type SavePetBagOrderInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"4484" struc:"skip"`
|
||||
|
||||
@@ -20,51 +23,60 @@ type SavePetBagOrderInboundInfo struct {
|
||||
BackupPetList []uint32
|
||||
}
|
||||
|
||||
// PetReleaseInboundInfo 定义请求或响应数据结构。
|
||||
type PetReleaseInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2304" struc:"skip"`
|
||||
CatchTime uint32
|
||||
Flag uint32 `json:"flag" fieldDescription:"0为放入仓库,1为放入背包" autoCodec:"true" uint:"true"`
|
||||
}
|
||||
|
||||
// PetShowInboundInfo 定义请求或响应数据结构。
|
||||
type PetShowInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2305" struc:"skip"`
|
||||
CatchTime uint32 `codec:"catchTime" inboundMessageType:"Pet_Show"`
|
||||
Flag uint32 `codec:"flag"`
|
||||
}
|
||||
|
||||
// PetOneCureInboundInfo 定义请求或响应数据结构。
|
||||
type PetOneCureInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2310" struc:"skip"`
|
||||
CatchTime uint32 `json:"catchTime" fieldDescription:"精灵捕捉时间" uint:"true"`
|
||||
}
|
||||
|
||||
// PET_ROWEI 定义请求或响应数据结构。
|
||||
type PET_ROWEI struct {
|
||||
Head common.TomeeHeader `cmd:"2321" struc:"skip"`
|
||||
ID uint32
|
||||
CatchTime uint32 `json:"catchTime" fieldDescription:"精灵捕捉时间" uint:"true"`
|
||||
}
|
||||
|
||||
// PET_RETRIEVE 定义请求或响应数据结构。
|
||||
type PET_RETRIEVE struct {
|
||||
Head common.TomeeHeader `cmd:"2322" struc:"skip"`
|
||||
CatchTime uint32 `json:"catchTime" fieldDescription:"精灵捕捉时间" uint:"true"`
|
||||
}
|
||||
|
||||
// PetDefaultInboundInfo 定义请求或响应数据结构。
|
||||
type PetDefaultInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2308" struc:"skip"`
|
||||
CatchTime uint32 `json:"catchTime" fieldDescription:"精灵捕捉时间" uint:"true" autoCodec:"true" inboundMessageType:"Pet_Default"`
|
||||
}
|
||||
|
||||
// PetSetExpInboundInfo 定义请求或响应数据结构。
|
||||
type PetSetExpInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2318" struc:"skip"`
|
||||
CatchTime uint32 `fieldDescription:"精灵获取时间" uint:"true" autoCodec:"true"`
|
||||
Exp int64 `struc:"uint32"`
|
||||
}
|
||||
|
||||
// PetBargeListInboundInfo 定义请求或响应数据结构。
|
||||
type PetBargeListInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2309" struc:"skip"`
|
||||
StartPetId uint32 `description:"开始精灵id" codec:"startPetId"`
|
||||
EndPetId uint32 `description:"结束精灵id" codec:"endPetId"`
|
||||
}
|
||||
|
||||
// ChangeSkillInfo 定义请求或响应数据结构。
|
||||
type ChangeSkillInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2312" struc:"skip"`
|
||||
CatchTime uint32 `json:"catchTime"`
|
||||
@@ -74,6 +86,7 @@ type ChangeSkillInfo struct {
|
||||
ReplaceSkill uint32 `json:"replaceSkill"`
|
||||
}
|
||||
|
||||
// C2S_Skill_Sort 定义请求或响应数据结构。
|
||||
type C2S_Skill_Sort struct {
|
||||
Head common.TomeeHeader `cmd:"2328" struc:"skip"`
|
||||
CapTm uint32 `json:"capTm"`
|
||||
|
||||
@@ -10,11 +10,13 @@ import (
|
||||
"hash/crc32"
|
||||
)
|
||||
|
||||
// MAIN_LOGIN_IN 定义请求或响应数据结构。
|
||||
type MAIN_LOGIN_IN struct {
|
||||
Head common.TomeeHeader `cmd:"1001" struc:"skip"`
|
||||
Sid []byte `struc:"[16]byte"`
|
||||
}
|
||||
|
||||
// CheakSession 处理控制器请求。
|
||||
func (l *MAIN_LOGIN_IN) CheakSession() (bool, uint32) {
|
||||
t1 := hex.EncodeToString(l.Sid)
|
||||
r, err := cool.CacheManager.Get(context.Background(), fmt.Sprintf("session:%d", l.Head.UserID))
|
||||
@@ -30,16 +32,19 @@ func (l *MAIN_LOGIN_IN) CheakSession() (bool, uint32) {
|
||||
return true, crcValue
|
||||
}
|
||||
|
||||
// SimUserInfoInboundInfo 定义请求或响应数据结构。
|
||||
type SimUserInfoInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2051" struc:"skip"`
|
||||
UserId uint32 `fieldDescription:"米米号" uint:"true" codec:"true"`
|
||||
}
|
||||
|
||||
// MoreUserInfoInboundInfo 定义请求或响应数据结构。
|
||||
type MoreUserInfoInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2052" struc:"skip"`
|
||||
UserId uint32 `fieldDescription:"米米号" uint:"true" codec:"true"`
|
||||
}
|
||||
|
||||
// AimatInboundInfo 定义请求或响应数据结构。
|
||||
type AimatInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2104" struc:"skip"`
|
||||
ItemId uint32 `description:"物品id 射击激光 物品id为0" codec:"auto" uint:"true"`
|
||||
@@ -47,6 +52,7 @@ type AimatInboundInfo struct {
|
||||
Point model.Pos `description:"射击的坐标 x y" codec:"auto"`
|
||||
}
|
||||
|
||||
// ChatInboundInfo 定义请求或响应数据结构。
|
||||
type ChatInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2102" struc:"skip"`
|
||||
Reserve uint32 `json:"reserve" fieldDescription:"填充 默认值为0" uint:"true"`
|
||||
@@ -54,43 +60,51 @@ type ChatInboundInfo struct {
|
||||
Message string `json:"message" fieldDescription:"消息内容, 结束符为utf-8的数字0"`
|
||||
}
|
||||
|
||||
// ChangeColorInboundInfo 定义请求或响应数据结构。
|
||||
type ChangeColorInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2063" struc:"skip"`
|
||||
Color uint32 `codec:"color"`
|
||||
}
|
||||
|
||||
// ChangeDoodleInboundInfo 定义请求或响应数据结构。
|
||||
type ChangeDoodleInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2062" struc:"skip"`
|
||||
Id uint32 `codec:"id"`
|
||||
Color uint32 `codec:"color"`
|
||||
}
|
||||
|
||||
// ChangeNONOColorInboundInfo 定义请求或响应数据结构。
|
||||
type ChangeNONOColorInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"9012" struc:"skip"`
|
||||
Color uint32 `codec:"color"`
|
||||
}
|
||||
|
||||
// C2SDanceAction 定义请求或响应数据结构。
|
||||
type C2SDanceAction struct {
|
||||
Head common.TomeeHeader `cmd:"2103" struc:"skip"`
|
||||
Reserve uint32 `struc:"uint32,big"`
|
||||
Type uint32 `struc:"uint32,big"`
|
||||
}
|
||||
|
||||
// C2SPEOPLE_TRANSFROM 定义请求或响应数据结构。
|
||||
type C2SPEOPLE_TRANSFROM struct {
|
||||
Head common.TomeeHeader `cmd:"2111" struc:"skip"`
|
||||
SuitID uint32 `struc:"uint32,big"`
|
||||
}
|
||||
|
||||
// ChangePlayerNameInboundInfo 定义请求或响应数据结构。
|
||||
type ChangePlayerNameInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2061" struc:"skip"`
|
||||
Nickname string `struc:"[16]byte"`
|
||||
}
|
||||
|
||||
// ChangeTitleInboundInfo 定义请求或响应数据结构。
|
||||
type ChangeTitleInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"3404" struc:"skip"`
|
||||
TileID uint32
|
||||
}
|
||||
|
||||
// C2S_GET_GIFT_COMPLETE 定义请求或响应数据结构。
|
||||
type C2S_GET_GIFT_COMPLETE struct {
|
||||
Head common.TomeeHeader `cmd:"2801" struc:"skip"`
|
||||
PassText string `struc:"[16]byte"`
|
||||
|
||||
@@ -43,12 +43,20 @@ func (h Controller) UsePetItemOutOfFight(data *C2S_USE_PET_ITEM_OUT_OF_FIGHT, c
|
||||
return nil, errorcode.ErrorCodes.ErrInsufficientItems
|
||||
}
|
||||
|
||||
oldHP := currentPet.Hp
|
||||
itemCfg, ok := xmlres.ItemsMAP[int(itemID)]
|
||||
if !ok {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
errcode := h.handleRegularPetItem(itemID, currentPet)
|
||||
if errcode != 0 {
|
||||
return nil, errcode
|
||||
}
|
||||
refreshPetPaneKeepHP(currentPet, oldHP)
|
||||
c.Service.Item.UPDATE(itemID, -1)
|
||||
result = &item.S2C_USE_PET_ITEM_OUT_OF_FIGHT{}
|
||||
copier.Copy(&result, currentPet)
|
||||
return result, 0
|
||||
}
|
||||
|
||||
oldHP := currentPet.Hp
|
||||
var errcode errorcode.ErrorCode
|
||||
switch {
|
||||
case itemID == 300036:
|
||||
@@ -166,14 +174,7 @@ func refreshPetPaneKeepHP(currentPet *model.PetInfo, hp uint32) {
|
||||
|
||||
// handleRegularPetItem 处理普通宠物道具
|
||||
func (h Controller) handleRegularPetItem(itemID uint32, currentPet *model.PetInfo) errorcode.ErrorCode {
|
||||
handler := item.PetItemRegistry.GetHandler(itemID)
|
||||
if handler == nil {
|
||||
return errorcode.ErrorCodes.ErrItemUnusable
|
||||
}
|
||||
if !handler(itemID, currentPet) {
|
||||
return errorcode.ErrorCodes.ErrItemUnusable
|
||||
}
|
||||
return 0
|
||||
return item.PetItemRegistry.Handle(itemID, currentPet)
|
||||
}
|
||||
|
||||
// ResetNature 重置宠物性格
|
||||
|
||||
@@ -39,6 +39,7 @@ func (h Controller) EnterMap(data *EnterMapInboundInfo, c *player.Player) (resul
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
// GetMapHot 处理控制器请求。
|
||||
func (h Controller) GetMapHot(data *GetMapHotInboundInfo, c *player.Player) (result *maphot.OutInfo, err errorcode.ErrorCode) {
|
||||
result = &maphot.OutInfo{
|
||||
HotInfos: space.GetMapHot(),
|
||||
|
||||
@@ -14,6 +14,7 @@ const (
|
||||
nonoPetCureCost int64 = 50
|
||||
)
|
||||
|
||||
// NonoFollowOrHome 处理控制器请求。
|
||||
func (h Controller) NonoFollowOrHome(data *NonoFollowOrHomeInInfo, c *player.Player) (result *nono.NonoFollowOutInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
c.Info.NONO.Flag = data.Flag
|
||||
result = &nono.NonoFollowOutInfo{
|
||||
@@ -49,6 +50,7 @@ func (h *Controller) GetNonoInfo(data *NonoInboundInfo, c *player.Player) (resul
|
||||
return
|
||||
}
|
||||
|
||||
// SwitchFlying 处理控制器请求。
|
||||
func (h *Controller) SwitchFlying(data *SwitchFlyingInboundInfo, c *player.Player) (result *nono.SwitchFlyingOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
result = &nono.SwitchFlyingOutboundInfo{
|
||||
UserId: data.Head.UserID,
|
||||
@@ -59,6 +61,7 @@ func (h *Controller) SwitchFlying(data *SwitchFlyingInboundInfo, c *player.Playe
|
||||
return
|
||||
}
|
||||
|
||||
// PlayerPetCure 处理控制器请求。
|
||||
func (h *Controller) PlayerPetCure(data *PetCureInboundInfo, c *player.Player) (result *nono.PetCureOutboundEmpty, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
_ = data
|
||||
if c.IsArenaHealLocked() {
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
// PetELV 处理控制器请求。
|
||||
func (h Controller) PetELV(data *C2S_PET_EVOLVTION, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
_, currentPet, found := c.FindPet(data.CacthTime)
|
||||
if !found {
|
||||
|
||||
@@ -63,6 +63,7 @@ func (h Controller) PetEVDiy(data *PetEV, c *player.Player) (result *fight.NullO
|
||||
return result, 0
|
||||
}
|
||||
|
||||
// PetEV 定义请求或响应数据结构。
|
||||
type PetEV struct {
|
||||
Head common.TomeeHeader `cmd:"50001" struc:"skip"`
|
||||
CacthTime uint32 `description:"捕捉时间" codec:"cacthTime"`
|
||||
|
||||
@@ -16,6 +16,7 @@ func (h Controller) PetExt(
|
||||
|
||||
}
|
||||
|
||||
// C2S_NONO_EXE_LIST 定义请求或响应数据结构。
|
||||
type C2S_NONO_EXE_LIST struct {
|
||||
Head common.TomeeHeader `cmd:"9015" struc:"skip"`
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ const (
|
||||
petFusionSoulID = 1000017
|
||||
)
|
||||
|
||||
// PetFusion 处理控制器请求。
|
||||
func (h Controller) PetFusion(data *C2S_PetFusion, c *player.Player) (result *pet.PetFusionInfo, err errorcode.ErrorCode) {
|
||||
result = &pet.PetFusionInfo{
|
||||
SoulID: petFusionSoulID,
|
||||
|
||||
@@ -36,6 +36,7 @@ func (h Controller) GetUserBagPetInfo(
|
||||
return player.GetUserBagPetInfo(), 0
|
||||
}
|
||||
|
||||
// GetPetListInboundEmpty 定义请求或响应数据结构。
|
||||
type GetPetListInboundEmpty struct {
|
||||
Head common.TomeeHeader `cmd:"2303" struc:"skip"`
|
||||
}
|
||||
@@ -48,6 +49,7 @@ func (h Controller) GetPetList(
|
||||
return buildPetListOutboundInfo(player.Info.PetList), 0
|
||||
}
|
||||
|
||||
// GetPetListFreeInboundEmpty 定义请求或响应数据结构。
|
||||
type GetPetListFreeInboundEmpty struct {
|
||||
Head common.TomeeHeader `cmd:"2320" struc:"skip"`
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
// IsCollect 处理控制器请求。
|
||||
func (h Controller) IsCollect(
|
||||
data *pet.C2S_IS_COLLECT, c *player.Player) (result *pet.S2C_IS_COLLECT, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
result = &pet.S2C_IS_COLLECT{
|
||||
@@ -49,6 +50,7 @@ var validTypeIDMap = map[int][]uint32{
|
||||
100: {856, 857, 858}, //测试
|
||||
}
|
||||
|
||||
// Collect 处理控制器请求。
|
||||
func (h Controller) Collect(
|
||||
data *pet.C2S_PET_COLLECT, c *player.Player) (result *pet.S2C_PET_COLLECT, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
result = &pet.S2C_PET_COLLECT{ID: data.ID}
|
||||
|
||||
@@ -120,6 +120,7 @@ func canBreedPair(maleID, femaleID uint32) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
// GetEggList 处理控制器请求。
|
||||
func (ctl Controller) GetEggList(
|
||||
data *pet.C2S_GET_EGG_LIST, player *player.Player) (result *pet.S2C_GET_EGG_LIST, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"blazing/logic/service/player"
|
||||
)
|
||||
|
||||
// SystemTimeInfo 处理控制器请求。
|
||||
func (h Controller) SystemTimeInfo(data *InInfo, c *player.Player) (result *OutInfo, err errorcode.ErrorCode) {
|
||||
|
||||
return &OutInfo{
|
||||
|
||||
@@ -171,6 +171,7 @@ func (h Controller) ChangePlayerCloth(data *ChangePlayerClothInboundInfo, player
|
||||
return
|
||||
}
|
||||
|
||||
// ChangePlayerName 处理控制器请求。
|
||||
func (h Controller) ChangePlayerName(data *ChangePlayerNameInboundInfo, c *player.Player) (result *user.ChangePlayerNameOutboundInfo, err errorcode.ErrorCode) {
|
||||
newNickname := cool.Filter.Replace(strings.Trim(data.Nickname, "\x00"), '*')
|
||||
|
||||
@@ -183,6 +184,8 @@ func (h Controller) ChangePlayerName(data *ChangePlayerNameInboundInfo, c *playe
|
||||
|
||||
return result, 0
|
||||
}
|
||||
|
||||
// ChangeTile 处理控制器请求。
|
||||
func (h Controller) ChangeTile(data *ChangeTitleInboundInfo, c *player.Player) (result *user.ChangeTitleOutboundInfo, err errorcode.ErrorCode) {
|
||||
result = &user.ChangeTitleOutboundInfo{
|
||||
|
||||
|
||||
@@ -2,19 +2,18 @@ package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/player"
|
||||
logicplayer "blazing/logic/service/player"
|
||||
"blazing/logic/service/user"
|
||||
"blazing/modules/config/service"
|
||||
"blazing/modules/player/model"
|
||||
configservice "blazing/modules/config/service"
|
||||
playerservice "blazing/modules/player/service"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (h Controller) CDK(data *C2S_GET_GIFT_COMPLETE, player *player.Player) (result *user.S2C_GET_GIFT_COMPLETE, err errorcode.ErrorCode) {
|
||||
// CDK 处理控制器请求。
|
||||
func (h Controller) CDK(data *C2S_GET_GIFT_COMPLETE, player *logicplayer.Player) (result *user.S2C_GET_GIFT_COMPLETE, err errorcode.ErrorCode) {
|
||||
result = &user.S2C_GET_GIFT_COMPLETE{}
|
||||
|
||||
cdkService := service.NewCdkService()
|
||||
rewardPetService := service.NewPetRewardService()
|
||||
itemRewardService := service.NewItemService()
|
||||
cdkService := configservice.NewCdkService()
|
||||
now := time.Now()
|
||||
|
||||
r := cdkService.Get(data.PassText)
|
||||
@@ -24,7 +23,6 @@ func (h Controller) CDK(data *C2S_GET_GIFT_COMPLETE, player *player.Player) (res
|
||||
if r.BindUserId != 0 && r.BindUserId != data.Head.UserID {
|
||||
return nil, errorcode.ErrorCodes.ErrMolecularCodeFrozen
|
||||
}
|
||||
|
||||
if r.ValidEndTime.Compare(now) == -1 {
|
||||
return nil, errorcode.ErrorCodes.ErrMolecularCodeExpired
|
||||
}
|
||||
@@ -35,28 +33,33 @@ func (h Controller) CDK(data *C2S_GET_GIFT_COMPLETE, player *player.Player) (res
|
||||
return nil, errorcode.ErrorCodes.ErrMolecularCodeGiftsGone
|
||||
}
|
||||
|
||||
reward, grantErr := playerservice.NewCdkService(data.Head.UserID).GrantConfigReward(uint32(r.ID))
|
||||
if grantErr != nil {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
|
||||
result.Flag = 1
|
||||
for _, rewardID := range r.ElfRewardIds {
|
||||
pet := rewardPetService.Get(rewardID)
|
||||
if pet == nil {
|
||||
continue
|
||||
appendGift := func(giftID, count int64) {
|
||||
if giftID == 0 || count <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
petInfo := model.GenPetInfo(int(pet.MonID), int(pet.DV), int(pet.Nature), int(pet.Effect), int(pet.Lv), nil, 0)
|
||||
player.Service.Pet.PetAdd(petInfo, 0)
|
||||
result.PetGift = append(result.PetGift, user.PetGiftInfo{PetID: petInfo.ID, CacthTime: petInfo.CatchTime})
|
||||
result.GiftList = append(result.GiftList, user.GiftInfo{GiftID: giftID, Count: count})
|
||||
}
|
||||
|
||||
for _, rewardID := range r.ItemRewardIds {
|
||||
itemInfo := itemRewardService.GetItemCount(rewardID)
|
||||
player.ItemAdd(itemInfo.ItemId, itemInfo.ItemCnt)
|
||||
result.GiftList = append(result.GiftList, user.GiftInfo{GiftID: itemInfo.ItemId, Count: itemInfo.ItemCnt})
|
||||
appendGift(1, reward.Coins)
|
||||
appendGift(3, reward.ExpPool)
|
||||
appendGift(5, reward.Gold)
|
||||
appendGift(9, reward.EVPool)
|
||||
for _, item := range reward.Items {
|
||||
appendGift(item.ItemId, item.ItemCnt)
|
||||
}
|
||||
if r.TitleRewardIds != 0 {
|
||||
player.Service.Title.Give(r.TitleRewardIds)
|
||||
result.Tile = r.TitleRewardIds
|
||||
for _, pet := range reward.Pets {
|
||||
result.PetGift = append(result.PetGift, user.PetGiftInfo{PetID: pet.PetID, CacthTime: pet.CatchTime})
|
||||
}
|
||||
if len(reward.TitleIDs) > 0 {
|
||||
result.Tile = reward.TitleIDs[0]
|
||||
}
|
||||
|
||||
player.Service.Cdk.Log(uint32(r.ID))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"blazing/modules/config/service"
|
||||
)
|
||||
|
||||
// GetTalkCount 处理控制器请求。
|
||||
func (h Controller) GetTalkCount(data *TalkCountInboundInfo, c *player.Player) (result *item.TalkCountOutboundInfo, err errorcode.ErrorCode) {
|
||||
result = &item.TalkCountOutboundInfo{}
|
||||
talkCount, ok := c.Service.Talk.Cheak(c.Info.MapID, int(data.ID))
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"blazing/logic/service/space/info"
|
||||
)
|
||||
|
||||
// PlayerWalk 处理控制器请求。
|
||||
func (h Controller) PlayerWalk(data *WalkInInfo, c *player.Player) (result *info.WalkOutInfo, err errorcode.ErrorCode) {
|
||||
result = &info.WalkOutInfo{
|
||||
Flag: data.Flag,
|
||||
|
||||
Reference in New Issue
Block a user