```
feat(fight): 增加战斗模式枚举并重构战斗逻辑判断 - 引入完整的 BattleMode 枚举定义,替代原有的 BattleStatus,明确区分各类战斗场景 - 在多个控制器中替换对旧 Status 字段的依赖,统一使用 Mode 判断战斗状态 - 修复部分函数调用前未检查 FightC 是否为空的问题,增加 ErrBattleEnded 错误返回 - 调整
This commit is contained in:
@@ -105,10 +105,6 @@ func (f *FightC) LoadPercent(c common.PlayerI, percent int32) {
|
||||
}
|
||||
|
||||
func (f *FightC) initplayer(c common.PlayerI) (*input.Input, errorcode.ErrorCode) {
|
||||
if len(c.GetInfo().PetList) == 0 {
|
||||
return nil, errorcode.ErrorCodes.ErrNoEligiblePokemon
|
||||
|
||||
}
|
||||
|
||||
if !c.CanFight() {
|
||||
return nil, errorcode.ErrorCodes.ErrNoEligiblePokemon
|
||||
@@ -221,12 +217,12 @@ func NewFight(p1, p2 common.PlayerI, fn func(*info.FightOverInfo)) (*FightC, err
|
||||
|
||||
f.ReadyInfo.OurInfo, f.ReadyInfo.OurPetList = initfightready(f.Our)
|
||||
f.ReadyInfo.OpponentInfo, f.ReadyInfo.OpponentPetList = initfightready(f.Opp)
|
||||
var loadtime time.Duration = 120 * time.Second
|
||||
//说明是PVE
|
||||
if f.Info.Mode == info.BattleMode.FIGHT_WITH_NPC {
|
||||
|
||||
switch f.Info.Mode {
|
||||
case info.BattleStatus.FIGHT_WITH_PLAYER:
|
||||
|
||||
default:
|
||||
f.Opp.Finished = true //PVE 默认boss数据直接加载完成
|
||||
loadtime = 60 * time.Second
|
||||
}
|
||||
|
||||
f.Broadcast(func(ff *input.Input) {
|
||||
@@ -240,16 +236,7 @@ func NewFight(p1, p2 common.PlayerI, fn func(*info.FightOverInfo)) (*FightC, err
|
||||
|
||||
})
|
||||
|
||||
var t time.Duration
|
||||
// 60秒后判断战斗是否开始
|
||||
switch f.Info.Mode {
|
||||
case info.BattleMode.PET_MELEE:
|
||||
t = 120 * time.Second
|
||||
|
||||
default:
|
||||
t = 60 * time.Second
|
||||
}
|
||||
cool.Cron.AfterFunc(t, func() {
|
||||
cool.Cron.AfterFunc(loadtime, func() {
|
||||
if !f.Our.Finished || !f.Opp.Finished { //如果有任一没有加载完成
|
||||
f.closefight = true //阻止继续添加action
|
||||
f.Reason = info.BattleOverReason.PlayerOVerTime
|
||||
|
||||
Reference in New Issue
Block a user