```
feat(fight): 增加战斗模式枚举并重构战斗逻辑判断 - 引入完整的 BattleMode 枚举定义,替代原有的 BattleStatus,明确区分各类战斗场景 - 在多个控制器中替换对旧 Status 字段的依赖,统一使用 Mode 判断战斗状态 - 修复部分函数调用前未检查 FightC 是否为空的问题,增加 ErrBattleEnded 错误返回 - 调整
This commit is contained in:
@@ -3,6 +3,7 @@ package controller
|
||||
import (
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/common/socket/errorcode"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"strings"
|
||||
|
||||
@@ -97,17 +98,23 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *pla
|
||||
|
||||
}
|
||||
|
||||
c.Fightinfo.Status = info.BattleStatus.FIGHT_WITH_BOSS
|
||||
c.Fightinfo.Status = info.BattleMode.FIGHT_WITH_NPC
|
||||
c.Fightinfo.Mode = info.BattleMode.MULTI_MODE
|
||||
|
||||
ai := player.NewAI_player(moinfo)
|
||||
//给予打过一次的奖励
|
||||
event := c.Done.SPT(c.Info.MapID, data.BossId, 1, func() {
|
||||
|
||||
event := c.Done.SPT(c.Info.MapID, data.BossId, 1, func() bool {
|
||||
fmt.Println("触发事件", "第一次奖励")
|
||||
return true
|
||||
})
|
||||
event1 := c.Done.SPT(c.Info.MapID, data.BossId, 2, func() bool {
|
||||
fmt.Println("触发事件", "第二次奖励")
|
||||
return true
|
||||
})
|
||||
fight.NewFight(c, ai, func(foi *info.FightOverInfo) {
|
||||
c.Done.Exec(model.MilestoneMode.BOSS, []uint32{data.BossId})
|
||||
c.Done.Exec(model.MilestoneMode.BOSS, []uint32{c.Info.MapID, data.BossId})
|
||||
event.Cancel() //取消事件
|
||||
event1.Cancel()
|
||||
|
||||
})
|
||||
|
||||
@@ -133,9 +140,10 @@ func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundIn
|
||||
moinfo.Nick = xmlres.PetMAP[int(mo.ID)].DefName
|
||||
moinfo.PetList = append(moinfo.PetList, *mo)
|
||||
ai := player.NewAI_player(moinfo)
|
||||
ai.CanCapture = handleNPCFightSpecial(mo.ID)
|
||||
|
||||
c.Fightinfo.Status = info.BattleStatus.FIGHT_WITH_NPC
|
||||
c.Fightinfo.Mode = info.BattleMode.MULTI_MODE
|
||||
c.Fightinfo.Status = info.BattleMode.FIGHT_WITH_NPC //打野怪
|
||||
c.Fightinfo.Mode = info.BattleMode.MULTI_MODE //多人模式
|
||||
|
||||
fight.NewFight(c, ai, func(foi *info.FightOverInfo) {
|
||||
|
||||
@@ -143,3 +151,15 @@ func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundIn
|
||||
|
||||
return nil, -1
|
||||
}
|
||||
func handleNPCFightSpecial(petid uint32) int {
|
||||
|
||||
npcPetID := int(petid)
|
||||
petCfg, ok := xmlres.PetMAP[npcPetID]
|
||||
if !ok {
|
||||
// log.Error(context.Background(), "NPC宠物配置不存在", "petID", npcPetID)
|
||||
return 0
|
||||
}
|
||||
|
||||
catchRate := gconv.Int(petCfg.CatchRate)
|
||||
return catchRate
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user