2025-12-13 21:47:07 +08:00
|
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/common/socket/errorcode"
|
|
|
|
|
|
"blazing/common/utils"
|
|
|
|
|
|
"blazing/logic/service/fight"
|
|
|
|
|
|
"blazing/logic/service/player"
|
2025-12-18 23:57:17 +08:00
|
|
|
|
"blazing/logic/service/space/info"
|
2025-12-13 21:47:07 +08:00
|
|
|
|
"sync/atomic"
|
2025-12-18 23:57:17 +08:00
|
|
|
|
|
|
|
|
|
|
"github.com/jinzhu/copier"
|
2025-12-13 21:47:07 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
2025-12-24 19:03:11 +08:00
|
|
|
|
// FreshChoiceFightLevel 处理玩家选择挑战模式(试炼之塔或勇者之塔)
|
|
|
|
|
|
// 根据不同的CMD值设置玩家的挑战状态和地图信息,并返回当前挑战层级信息
|
|
|
|
|
|
// 参数:
|
2025-12-26 05:41:51 +08:00
|
|
|
|
//
|
|
|
|
|
|
// data: 客户端发送的挑战层级选择请求数据,包含CMD和挑战层级
|
|
|
|
|
|
// c: 玩家对象,包含玩家的详细信息
|
|
|
|
|
|
//
|
2025-12-24 19:03:11 +08:00
|
|
|
|
// 返回值:
|
2025-12-26 05:41:51 +08:00
|
|
|
|
//
|
|
|
|
|
|
// result: 服务器返回给客户端的挑战层级信息,包含当前战斗层级和Boss ID
|
|
|
|
|
|
// err: 错误码,表示处理过程中是否出现错误
|
2025-12-24 19:03:11 +08:00
|
|
|
|
func (h Controller) FreshChoiceFightLevel(data *fight.C2S_FRESH_CHOICE_FIGHT_LEVEL, c *player.Player) (result *fight.S2C_FreshChoiceLevelRequestInfo, err errorcode.ErrorCode) {
|
2025-12-13 21:47:07 +08:00
|
|
|
|
|
|
|
|
|
|
result = &fight.S2C_FreshChoiceLevelRequestInfo{}
|
|
|
|
|
|
|
|
|
|
|
|
switch data.Head.CMD {
|
|
|
|
|
|
case 2428: //试炼之塔
|
|
|
|
|
|
c.Info.CurrentFreshStage = utils.Max(c.Info.CurrentFreshStage, 1)
|
|
|
|
|
|
result.CurFightLevel = uint(c.Info.CurrentFreshStage)
|
|
|
|
|
|
case 2414: //勇者之塔
|
|
|
|
|
|
c.Info.CurrentStage = utils.Max(c.Info.CurrentStage, 1)
|
|
|
|
|
|
result.CurFightLevel = uint(c.Info.CurrentStage)
|
|
|
|
|
|
}
|
2025-12-24 19:03:11 +08:00
|
|
|
|
// 设置Boss ID为固定值10
|
2025-12-13 21:47:07 +08:00
|
|
|
|
result.BossId = []uint32{10}
|
2025-12-24 19:03:11 +08:00
|
|
|
|
// 重置玩家的Canmon标志位为0,表示可以刷怪
|
2025-12-13 21:47:07 +08:00
|
|
|
|
atomic.StoreUint32(&c.Canmon, 0)
|
2025-12-24 19:03:11 +08:00
|
|
|
|
// 在函数结束时将玩家传送到对应地图
|
2025-12-26 05:41:51 +08:00
|
|
|
|
defer c.GetSpace().LeaveMap(c)
|
2025-12-13 21:47:07 +08:00
|
|
|
|
return result, 0
|
|
|
|
|
|
}
|
2025-12-23 10:46:17 +08:00
|
|
|
|
func (h Controller) FreshLeaveFightLevel(data *fight.FRESH_LEAVE_FIGHT_LEVEL, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-12-13 21:47:07 +08:00
|
|
|
|
|
2025-12-18 23:57:17 +08:00
|
|
|
|
defer c.GetSpace().EnterMap(c)
|
|
|
|
|
|
|
|
|
|
|
|
out := info.NewOutInfo()
|
|
|
|
|
|
copier.CopyWithOption(out, c.GetInfo(), copier.Option{DeepCopy: true})
|
|
|
|
|
|
|
|
|
|
|
|
c.SendPackCmd(2001, out)
|
2025-12-13 21:47:07 +08:00
|
|
|
|
return result, 0
|
|
|
|
|
|
}
|