2025-12-13 21:47:07 +08:00
|
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/common/socket/errorcode"
|
|
|
|
|
|
"blazing/common/utils"
|
|
|
|
|
|
"blazing/logic/service/fight"
|
2026-01-01 05:32:56 +08:00
|
|
|
|
fightinfo "blazing/logic/service/fight/info"
|
2025-12-13 21:47:07 +08:00
|
|
|
|
"blazing/logic/service/player"
|
2025-12-18 23:57:17 +08:00
|
|
|
|
"blazing/logic/service/space/info"
|
2026-01-01 05:32:56 +08:00
|
|
|
|
configmodel "blazing/modules/config/model"
|
|
|
|
|
|
"blazing/modules/config/service"
|
2026-01-19 18:51:56 +08:00
|
|
|
|
"blazing/modules/player/model"
|
2026-01-05 01:04:52 +08:00
|
|
|
|
|
2025-12-13 21:47:07 +08:00
|
|
|
|
"sync/atomic"
|
2025-12-18 23:57:17 +08:00
|
|
|
|
|
2026-01-01 19:57:39 +08:00
|
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
2025-12-18 23:57:17 +08:00
|
|
|
|
"github.com/jinzhu/copier"
|
2025-12-13 21:47:07 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
2026-02-05 23:44:07 +08:00
|
|
|
|
// 暗黑门进入boss
|
|
|
|
|
|
func (h Controller) FreshOpen(data *fight.C2S_OPEN_DARKPORTAL, c *player.Player) (result *fight.S2C_OPEN_DARKPORTAL, err errorcode.ErrorCode) {
|
2026-01-02 04:11:37 +08:00
|
|
|
|
|
|
|
|
|
|
result = &fight.S2C_OPEN_DARKPORTAL{}
|
2026-03-03 19:28:59 +08:00
|
|
|
|
// c.Info.CurrentFreshStage = utils.Max(c.Info.CurrentFreshStage, 1)
|
|
|
|
|
|
// c.Info.CurrentStage = utils.Max(c.Info.CurrentStage, 1)
|
2026-01-02 04:11:37 +08:00
|
|
|
|
boss := service.NewTower110Service().Boss(uint32(data.Level))
|
2026-02-26 17:21:43 +08:00
|
|
|
|
if len(boss) == 0 {
|
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
|
|
|
|
}
|
|
|
|
|
|
if len(boss[0].BossIds) == 0 {
|
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
|
|
|
|
}
|
2026-01-02 04:11:37 +08:00
|
|
|
|
result = &fight.S2C_OPEN_DARKPORTAL{}
|
2026-02-25 21:16:36 +08:00
|
|
|
|
r := service.NewBossService().Get(boss[0].BossIds[0])
|
2026-02-25 16:18:10 +08:00
|
|
|
|
result.CurBossID = uint32(r[0].MonID)
|
2026-01-02 04:11:37 +08:00
|
|
|
|
|
|
|
|
|
|
c.CurDark = uint32(data.Level)
|
|
|
|
|
|
defer c.GetSpace().LeaveMap(c)
|
|
|
|
|
|
return result, 0
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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{}
|
2026-01-01 05:32:56 +08:00
|
|
|
|
c.Info.CurrentFreshStage = utils.Max(c.Info.CurrentFreshStage, 1)
|
|
|
|
|
|
c.Info.CurrentStage = utils.Max(c.Info.CurrentStage, 1)
|
2026-01-02 04:11:37 +08:00
|
|
|
|
|
2026-01-01 05:32:56 +08:00
|
|
|
|
if data.Level > 0 {
|
|
|
|
|
|
switch data.Head.CMD {
|
|
|
|
|
|
case 2428: //试炼之塔
|
2026-03-04 17:11:57 +08:00
|
|
|
|
if data.Level > uint(c.Info.MaxFreshStage) && data.Level != 1 {
|
2026-03-03 19:28:59 +08:00
|
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
|
|
|
|
}
|
2026-01-01 05:32:56 +08:00
|
|
|
|
|
2026-03-03 19:28:59 +08:00
|
|
|
|
c.Info.CurrentFreshStage = uint32(data.Level)
|
2026-01-01 05:32:56 +08:00
|
|
|
|
case 2414: //勇者之塔
|
2026-03-04 17:11:57 +08:00
|
|
|
|
if data.Level > uint(c.Info.MaxStage) && data.Level != 1 {
|
2026-03-03 19:28:59 +08:00
|
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
|
|
|
|
}
|
|
|
|
|
|
c.Info.CurrentStage = uint32(data.Level)
|
2026-01-02 04:11:37 +08:00
|
|
|
|
|
2026-01-01 05:32:56 +08:00
|
|
|
|
}
|
2026-01-02 04:11:37 +08:00
|
|
|
|
|
2026-01-01 05:32:56 +08:00
|
|
|
|
}
|
2026-02-25 21:16:36 +08:00
|
|
|
|
var boss []configmodel.BaseTowerConfig
|
2025-12-13 21:47:07 +08:00
|
|
|
|
switch data.Head.CMD {
|
|
|
|
|
|
case 2428: //试炼之塔
|
2026-01-01 05:32:56 +08:00
|
|
|
|
|
2026-01-02 04:11:37 +08:00
|
|
|
|
result.CurFightLevel = uint32(c.Info.CurrentFreshStage)
|
2026-01-01 15:37:43 +08:00
|
|
|
|
boss = service.NewTower600Service().Boss(c.Info.CurrentFreshStage)
|
|
|
|
|
|
|
|
|
|
|
|
case 2414: //勇者之塔
|
|
|
|
|
|
|
2026-01-02 04:11:37 +08:00
|
|
|
|
result.CurFightLevel = uint32(c.Info.CurrentStage)
|
2026-01-01 19:57:39 +08:00
|
|
|
|
boss = service.NewTower500Service().Boss(c.Info.CurrentStage)
|
2026-01-01 05:32:56 +08:00
|
|
|
|
//next := service.NewTower600Service().Boss(c.Info.CurrentFreshStage + 1)
|
|
|
|
|
|
|
2026-01-01 15:37:43 +08:00
|
|
|
|
}
|
2026-02-26 17:21:43 +08:00
|
|
|
|
if len(boss) != 0 && len(boss[0].BossIds) != 0 {
|
2026-02-25 21:16:36 +08:00
|
|
|
|
//单节点,取获取到的一个,然后因为不是剧情,所以只有一层
|
|
|
|
|
|
r := service.NewBossService().Get(boss[0].BossIds[0])
|
2026-02-25 16:18:10 +08:00
|
|
|
|
for _, v := range r {
|
|
|
|
|
|
result.BossId = append(result.BossId, uint32(v.MonID))
|
2026-01-01 05:32:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-13 21:47:07 +08:00
|
|
|
|
}
|
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})
|
|
|
|
|
|
|
2026-02-07 20:50:02 +08:00
|
|
|
|
//c.SendPackCmd(2001, out)
|
2025-12-13 21:47:07 +08:00
|
|
|
|
return result, 0
|
|
|
|
|
|
}
|
2026-01-01 05:32:56 +08:00
|
|
|
|
|
|
|
|
|
|
func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player) (result *fight.S2C_ChoiceLevelRequestInfo, err errorcode.ErrorCode) {
|
2026-02-25 16:18:10 +08:00
|
|
|
|
r := c.CanFight()
|
|
|
|
|
|
if c.CanFight() != 0 {
|
|
|
|
|
|
return nil, r
|
2026-01-01 05:32:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
c.Fightinfo.Mode = fightinfo.BattleMode.MULTI_MODE
|
|
|
|
|
|
c.Fightinfo.Status = fightinfo.BattleMode.FIGHT_WITH_NPC
|
|
|
|
|
|
monsterInfo := &model.PlayerInfo{}
|
2026-02-25 21:16:36 +08:00
|
|
|
|
var boss []configmodel.BaseTowerConfig
|
|
|
|
|
|
|
2026-01-01 05:32:56 +08:00
|
|
|
|
result = &fight.S2C_ChoiceLevelRequestInfo{}
|
|
|
|
|
|
switch data.Head.CMD {
|
|
|
|
|
|
case 2429: //试炼之塔
|
2026-02-25 21:16:36 +08:00
|
|
|
|
boss = service.NewTower600Service().Boss(c.Info.CurrentFreshStage, c.Info.CurrentFreshStage+1)
|
2026-01-01 05:32:56 +08:00
|
|
|
|
|
|
|
|
|
|
result.CurFightLevel = uint32(c.Info.CurrentFreshStage)
|
|
|
|
|
|
case 2415: //勇者之塔
|
2026-02-26 00:33:56 +08:00
|
|
|
|
boss = service.NewTower500Service().Boss(c.Info.CurrentStage, c.Info.CurrentStage+1)
|
2026-01-01 15:37:43 +08:00
|
|
|
|
|
2026-01-01 05:32:56 +08:00
|
|
|
|
result.CurFightLevel = uint32(c.Info.CurrentStage)
|
2026-01-02 04:11:37 +08:00
|
|
|
|
case 2425:
|
|
|
|
|
|
boss = service.NewTower110Service().Boss(c.CurDark)
|
2026-02-25 21:16:36 +08:00
|
|
|
|
|
2026-01-01 05:32:56 +08:00
|
|
|
|
}
|
2026-02-25 21:16:36 +08:00
|
|
|
|
if len(boss) > 1 {
|
2026-02-26 01:02:30 +08:00
|
|
|
|
r := service.NewBossService().Get(boss[1].BossIds[0])
|
2026-02-25 16:18:10 +08:00
|
|
|
|
for _, v := range r {
|
|
|
|
|
|
result.BossID = append(result.BossID, uint32(v.MonID))
|
2026-01-01 15:37:43 +08:00
|
|
|
|
}
|
2026-02-25 16:18:10 +08:00
|
|
|
|
|
2026-01-01 15:37:43 +08:00
|
|
|
|
}
|
2026-01-01 05:32:56 +08:00
|
|
|
|
|
2026-02-25 21:16:36 +08:00
|
|
|
|
bosss := service.NewBossService().Get(boss[0].BossIds[0])
|
|
|
|
|
|
monsterInfo.Nick = boss[0].Name
|
2026-02-25 16:18:10 +08:00
|
|
|
|
for i, r := range bosss {
|
2026-01-01 05:32:56 +08:00
|
|
|
|
|
2026-02-25 16:18:10 +08:00
|
|
|
|
monster := model.GenPetInfo(int(r.MonID), 24, int(r.Nature), 0, int(r.Lv), nil, 0)
|
|
|
|
|
|
if r.Hp != 0 {
|
|
|
|
|
|
monster.Hp = uint32(r.Hp)
|
|
|
|
|
|
monster.MaxHp = uint32(r.Hp)
|
2026-01-01 05:32:56 +08:00
|
|
|
|
|
2026-02-25 16:18:10 +08:00
|
|
|
|
}
|
2026-01-01 05:32:56 +08:00
|
|
|
|
|
2026-02-25 16:18:10 +08:00
|
|
|
|
for i, v := range r.Prop {
|
|
|
|
|
|
if v != 0 {
|
|
|
|
|
|
monster.Prop[i] = v
|
2026-01-01 05:32:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-25 16:18:10 +08:00
|
|
|
|
}
|
2026-01-01 05:32:56 +08:00
|
|
|
|
|
2026-02-25 16:18:10 +08:00
|
|
|
|
if len(r.SKill) != 0 {
|
|
|
|
|
|
for i := 0; i < len(monster.SkillList); i++ {
|
|
|
|
|
|
if r.SKill[i] != 0 {
|
|
|
|
|
|
monster.SkillList[i].ID = r.SKill[i]
|
2026-01-01 05:32:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2026-01-01 19:57:39 +08:00
|
|
|
|
|
2026-02-25 16:18:10 +08:00
|
|
|
|
}
|
2026-01-01 19:57:39 +08:00
|
|
|
|
|
2026-02-25 21:16:36 +08:00
|
|
|
|
effects := service.NewEffectService().Args(r.Effect)
|
2026-02-25 16:18:10 +08:00
|
|
|
|
|
2026-02-25 21:16:36 +08:00
|
|
|
|
for _, v := range effects {
|
|
|
|
|
|
monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{
|
|
|
|
|
|
Idx: uint16(v.SeIdx),
|
|
|
|
|
|
EID: gconv.Uint16(v.Eid),
|
|
|
|
|
|
Args: gconv.Ints(v.Args),
|
|
|
|
|
|
})
|
2026-01-01 05:32:56 +08:00
|
|
|
|
}
|
2026-02-25 16:18:10 +08:00
|
|
|
|
monster.CatchTime = uint32(i)
|
|
|
|
|
|
monsterInfo.PetList = append(monsterInfo.PetList, *monster)
|
2026-01-01 05:32:56 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ai := player.NewAI_player(monsterInfo)
|
2026-03-04 22:47:21 +08:00
|
|
|
|
_, err = fight.NewFight(c, ai, func(foi model.FightOverInfo) {
|
2026-01-01 05:32:56 +08:00
|
|
|
|
if foi.Reason == 0 && foi.WinnerId == c.Info.UserID { //我放获胜
|
|
|
|
|
|
switch data.Head.CMD {
|
|
|
|
|
|
case 2429: //试炼之塔
|
2026-01-20 04:40:36 +08:00
|
|
|
|
c.TawerCompletedTask(600, int(c.Info.CurrentFreshStage))
|
2026-01-01 05:32:56 +08:00
|
|
|
|
c.Info.CurrentFreshStage++
|
2026-01-01 19:57:39 +08:00
|
|
|
|
if c.Info.CurrentFreshStage >= c.Info.MaxFreshStage {
|
|
|
|
|
|
c.Info.MaxFreshStage = c.Info.CurrentFreshStage
|
|
|
|
|
|
}
|
2026-01-01 05:32:56 +08:00
|
|
|
|
|
|
|
|
|
|
case 2415: //勇者之塔
|
2026-01-20 04:40:36 +08:00
|
|
|
|
c.TawerCompletedTask(500, int(c.Info.CurrentStage))
|
2026-01-01 15:37:43 +08:00
|
|
|
|
c.Info.CurrentStage++
|
2026-01-01 19:57:39 +08:00
|
|
|
|
if c.Info.CurrentStage >= c.Info.MaxStage {
|
|
|
|
|
|
c.Info.MaxStage = c.Info.CurrentStage
|
|
|
|
|
|
}
|
2026-01-02 04:11:37 +08:00
|
|
|
|
case 2425:
|
2026-01-20 04:40:36 +08:00
|
|
|
|
c.TawerCompletedTask(110, int(c.CurDark))
|
2026-01-01 05:32:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}) ///开始对战,房主方以及被邀请方
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|