feat(controller): 增强命令注册逻辑并修复试炼塔关卡限制 - 在命令注册时检查重复方法,如果存在则panic提示错误 - 移除CurrentFreshStage和CurrentStage的默认值设置逻辑 - 添加关卡等级验证,确保用户不能挑战超过最大关卡数的关卡 - 修复试炼之塔和勇者之塔的关卡计算逻辑 fix(item): 修复道具
This commit is contained in:
@@ -98,10 +98,14 @@ func Init(isGame bool) {
|
||||
cmdInfo.NewReqFunc = func() interface{} {
|
||||
return reflect.New(reqType).Interface()
|
||||
}
|
||||
cool.CmdCache[cmd] = cmdInfo
|
||||
// if exists { // 方法已存在
|
||||
// glog.Error(context.Background(), "命令处理方法已存在,跳过注册", cmd, method.Name)
|
||||
// }
|
||||
_, exists := cool.CmdCache[cmd]
|
||||
|
||||
if exists { // 方法已存在
|
||||
panic(fmt.Sprintf("命令处理方法已存在,跳过注册 %d %s", cmd, method.Name))
|
||||
|
||||
} else {
|
||||
cool.CmdCache[cmd] = cmdInfo
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
51
logic/controller/action_超时空隧道.go
Normal file
51
logic/controller/action_超时空隧道.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/modules/config/service"
|
||||
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
// 进入超时空隧道
|
||||
func (h Controller) TimeMap(data *C2s_SP, c *player.Player) (result *S2C_SP, err errorcode.ErrorCode) {
|
||||
result = &S2C_SP{}
|
||||
maps := service.NewMapService().GetTimeMap()
|
||||
result.MapList = make([]ServerInfo, len(maps))
|
||||
for i, v := range maps {
|
||||
result.MapList[i].ID = v.MapID
|
||||
result.MapList[i].DropItemIds = v.DropItemIds
|
||||
pits := service.NewMapPitService().GetDataALL(v.MapID)
|
||||
|
||||
for _, v := range pits {
|
||||
|
||||
result.MapList[i].Pet = append(result.MapList[i].Pet, v.RefreshID...)
|
||||
|
||||
}
|
||||
result.MapList[i].Pet = lo.Union(result.MapList[i].Pet)
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
type C2s_SP struct {
|
||||
Head common.TomeeHeader `cmd:"60002" struc:"skip"` //超时空地图
|
||||
}
|
||||
|
||||
// OutInfo 表示地图热度的出站消息
|
||||
type S2C_SP struct {
|
||||
MapListLen uint32 `struc:"sizeof=MapList"`
|
||||
MapList []ServerInfo
|
||||
}
|
||||
|
||||
type ServerInfo struct {
|
||||
ID uint32 //地图ID
|
||||
PetLen uint32 `struc:"sizeof=Pet"`
|
||||
Pet []uint32 //拥有的精灵
|
||||
DropItemIdsLen uint32 `struc:"sizeof=DropItemIds"`
|
||||
DropItemIds []uint32 //掉落物
|
||||
GameLen uint32 `struc:"sizeof=Game"`
|
||||
Game string
|
||||
}
|
||||
@@ -21,8 +21,8 @@ import (
|
||||
func (h Controller) FreshOpen(data *fight.C2S_OPEN_DARKPORTAL, c *player.Player) (result *fight.S2C_OPEN_DARKPORTAL, err errorcode.ErrorCode) {
|
||||
|
||||
result = &fight.S2C_OPEN_DARKPORTAL{}
|
||||
c.Info.CurrentFreshStage = utils.Max(c.Info.CurrentFreshStage, 1)
|
||||
c.Info.CurrentStage = utils.Max(c.Info.CurrentStage, 1)
|
||||
// c.Info.CurrentFreshStage = utils.Max(c.Info.CurrentFreshStage, 1)
|
||||
// c.Info.CurrentStage = utils.Max(c.Info.CurrentStage, 1)
|
||||
boss := service.NewTower110Service().Boss(uint32(data.Level))
|
||||
if len(boss) == 0 {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
@@ -59,11 +59,16 @@ func (h Controller) FreshChoiceFightLevel(data *fight.C2S_FRESH_CHOICE_FIGHT_LEV
|
||||
if data.Level > 0 {
|
||||
switch data.Head.CMD {
|
||||
case 2428: //试炼之塔
|
||||
if data.Level > uint(c.Info.MaxFreshStage) {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
|
||||
c.Info.CurrentFreshStage = uint32((data.Level-1)*10) + 1
|
||||
c.Info.CurrentFreshStage = uint32(data.Level)
|
||||
case 2414: //勇者之塔
|
||||
|
||||
c.Info.CurrentStage = uint32((data.Level-1)*10) + 1
|
||||
if data.Level > uint(c.Info.MaxStage) {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
c.Info.CurrentStage = uint32(data.Level)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -179,14 +179,16 @@ func (h Controller) UseSpeedupItem(data *item.C2S_USE_SPEEDUP_ITEM, c *player.Pl
|
||||
return nil, errorcode.ErrorCodes.ErrItemInUse
|
||||
}
|
||||
c.Info.ThreeTimes += 30 // 玩家对象新增 ThreeTimesExp 字段存储三倍剩余次数
|
||||
|
||||
default:
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError // 未知道具ID
|
||||
}
|
||||
|
||||
// 3. 扣减道具(数量-1)
|
||||
c.Service.Item.UPDATE(data.ItemID, -1)
|
||||
result.ThreeTimes = c.Info.ThreeTimes // 返回三倍经验剩余次数
|
||||
result.TwoTimes = c.Info.TwoTimes // 返回双倍经验剩余次数
|
||||
result.ThreeTimes = uint32(c.Info.ThreeTimes) // 返回三倍经验剩余次数
|
||||
result.TwoTimes = uint32(c.Info.TwoTimes) // 返回双倍经验剩余次数
|
||||
|
||||
// 4. (可选)持久化玩家经验次数(根据你的项目存储逻辑补充)
|
||||
// c.Service.Player.SaveExpTimes(c)
|
||||
|
||||
@@ -218,6 +220,9 @@ func (h Controller) UseEnergyXishou(data *item.C2S_USE_ENERGY_XISHOU, c *player.
|
||||
|
||||
// 3. 扣减道具(数量-1)
|
||||
c.Service.Item.UPDATE(data.ItemID, -1)
|
||||
result = &item.S2C_USE_ENERGY_XISHOU{
|
||||
EnergyTimes: uint32(c.Info.EnergyTime),
|
||||
}
|
||||
|
||||
// 4. (可选)持久化玩家能量次数
|
||||
// c.Service.Player.SaveEnergyTimes(c)
|
||||
|
||||
Reference in New Issue
Block a user