diff --git a/logic/controller/Controller.go b/logic/controller/Controller.go index bc99f791..d04d385c 100644 --- a/logic/controller/Controller.go +++ b/logic/controller/Controller.go @@ -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 + } } } } diff --git a/logic/controller/action_超时空隧道.go b/logic/controller/action_超时空隧道.go new file mode 100644 index 00000000..8e8620bf --- /dev/null +++ b/logic/controller/action_超时空隧道.go @@ -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 +} diff --git a/logic/controller/fight_塔.go b/logic/controller/fight_塔.go index f4e52e02..c448b3fb 100644 --- a/logic/controller/fight_塔.go +++ b/logic/controller/fight_塔.go @@ -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) } diff --git a/logic/controller/item_use.go b/logic/controller/item_use.go index 8af584ef..223a626d 100644 --- a/logic/controller/item_use.go +++ b/logic/controller/item_use.go @@ -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) diff --git a/logic/service/fight/cmd.go b/logic/service/fight/cmd.go index c321f5b5..9c09ee23 100644 --- a/logic/service/fight/cmd.go +++ b/logic/service/fight/cmd.go @@ -134,12 +134,7 @@ type ChatInfo struct { } type C2S_FRESH_CHOICE_FIGHT_LEVEL struct { Head common.TomeeHeader `cmd:"2428|2414" struc:"skip"` - // Level 挑战层数选择标识 - // 0: 继续挑战(从数据库存储的当前通关层数开始) - // 1: 从1层开始 - // 2: 从11层开始 - // 3: 从21层开始 - // 4: 从31层开始 + Level uint `json:"level"` // 若使用JSON序列化,添加tag;若用protobuf可替换为对应的tag } type C2S_OPEN_DARKPORTAL struct { diff --git a/logic/service/fight/info/info.go b/logic/service/fight/info/info.go index 02cd955c..ddaf9639 100644 --- a/logic/service/fight/info/info.go +++ b/logic/service/fight/info/info.go @@ -301,7 +301,7 @@ type FightOverInfo struct { // 3=isDraw 双方平手 // 4=isSysError 系统错误 // 5=isNpcEscape 精灵主动逃跑 - + Winpet *model.PetInfo `struc:"skip"` Round uint32 `struc:"skip"` LastAttavue AttackValue `struc:"skip"` @@ -311,7 +311,7 @@ type FightOverInfo struct { TwoTimes uint32 // 双倍经验剩余次数 ThreeTimes uint32 // 三倍经验剩余次数 AutoFightTimes uint32 // 自动战斗剩余次数 - EnergyTimes uint32 // 能量吸收器剩余次数 + EnergyTime uint32 // 能量吸收器剩余次数 LearnTimes uint32 // 双倍学习器剩余次数 } diff --git a/logic/service/item/petuse.go b/logic/service/item/petuse.go index 6e51de39..f8362adc 100644 --- a/logic/service/item/petuse.go +++ b/logic/service/item/petuse.go @@ -145,6 +145,9 @@ func init() { PetItemRegistry.RegisterSet([]uint32{300119, 300120}, nvfunc) PetItemRegistry.RegisterExact(300790, func(itemid uint32, onpet *model.PetInfo) bool { + if onpet.Dv >= 31 { + return false + } r := grand.Intn(2) if r == 0 { if onpet.Dv > 0 { diff --git a/logic/service/player/save.go b/logic/service/player/save.go index cf8b94b7..e8575d31 100644 --- a/logic/service/player/save.go +++ b/logic/service/player/save.go @@ -81,12 +81,12 @@ func (p *Player) CanGet() bool { func (p *Player) CanGetExp() (float32, float32) { var base float32 = 1 - if p.Info.TwoTimes != 0 { + if p.Info.TwoTimes > 0 { p.Info.TwoTimes-- base *= 2 } - if p.Info.ThreeTimes != 0 { + if p.Info.ThreeTimes > 0 { p.Info.ThreeTimes-- base *= 3 @@ -95,7 +95,7 @@ func (p *Player) CanGetExp() (float32, float32) { } func (p *Player) CanGetXUAN() bool { var base = 1 - if p.Info.EnergyTime != 0 { + if p.Info.EnergyTime > 0 { base = 2 p.Info.EnergyTime-- } @@ -106,7 +106,7 @@ func (p *Player) CanGetXUAN() bool { } func (p *Player) CanGetItem() bool { var base = 3 - if p.Info.EnergyTime != 0 { + if p.Info.EnergyTime > 0 { base = 6 p.Info.EnergyTime-- } diff --git a/modules/config/controller/admin/map.go b/modules/config/controller/admin/map.go index 98dddd1e..728afa73 100644 --- a/modules/config/controller/admin/map.go +++ b/modules/config/controller/admin/map.go @@ -3,7 +3,6 @@ package admin import ( "blazing/cool" "blazing/modules/config/service" - "context" "github.com/gogf/gf/v2/frame/g" ) @@ -28,16 +27,16 @@ type TimeMapReq struct { g.Meta `path:"/timemap" method:"GET"` } -func (this *MapController) TimeMap(ctx context.Context, req *TimeMapReq) (res *cool.BaseRes, err error) { - res = &cool.BaseRes{} - res.Data = service.NewMapService().GetTimeMap() - // re := service.NewMapService().GetTimeMap() - // for _, v := range re { - // v. +// func (this *MapController) TimeMap(ctx context.Context, req *TimeMapReq) (res *cool.BaseRes, err error) { +// res = &cool.BaseRes{} +// res.Data = service.NewMapService().GetTimeMap() +// // re := service.NewMapService().GetTimeMap() +// // for _, v := range re { +// // v. - // } - return res, nil -} +// // } +// return res, nil +// } // type MapTipReq struct { // g.Meta `path:"/maptip" method:"GET"` diff --git a/modules/player/model/info.go b/modules/player/model/info.go index 6223b240..2430f9af 100644 --- a/modules/player/model/info.go +++ b/modules/player/model/info.go @@ -173,11 +173,11 @@ type PlayerInfo struct { CurrentFreshStage uint32 `struc:"uint32" default:"1" json:"current_fresh_stage"` // 当前试炼层数 MaxFreshStage uint32 `struc:"uint32" json:"max_fresh_stage"` // 最高试炼层 MaxArenaWins uint32 `struc:"uint32" json:"max_arena_wins"` // 星际擂台连胜 - TwoTimes uint32 `struc:"uint32" default:"0" json:"two_times"` // 双倍经验加速器剩余使用次数 - ThreeTimes uint32 `struc:"uint32" default:"0" json:"three_times"` // 三倍经验加速器剩余使用次数 + TwoTimes int32 `struc:"uint32" default:"0" json:"two_times"` // 双倍经验加速器剩余使用次数 + ThreeTimes int32 `struc:"uint32" default:"0" json:"three_times"` // 三倍经验加速器剩余使用次数 AutoFight uint32 `struc:"uint32" default:"0" json:"auto_fight"` // 是否自动战斗 AutoFightTime uint32 `struc:"uint32" default:"0" json:"auto_fight_time"` // 自动战斗剩余的场次 - EnergyTime uint32 `struc:"uint32" default:"0" json:"energy_time"` // 能量吸收仪剩余次数 + EnergyTime int32 `struc:"uint32" default:"0" json:"energy_time"` // 能量吸收仪剩余次数 LearnTimes uint32 `struc:"uint32" default:"0" json:"learn_times"` // 学习力吸收仪剩余次数 MonBattleMedal uint32 `struc:"uint32" default:"0" json:"mon_battle_medal"` // 默认0 RecordCount uint32 `struc:"uint32" default:"0" json:"record_count"` // 默认0