refactor(fight): 增加战斗控制器空指针检查,优化逃跑和切换精灵逻辑

This commit is contained in:
1
2025-11-05 13:37:01 +00:00
parent e398c31834
commit ed08006786

View File

@@ -164,15 +164,17 @@ func (h Controller) UseSkill(data *fight.UseSkillInInfo, c *player.Player) (resu
// 战斗逃跑
func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
c.FightC.Over(c, info.BattleOverReason.PlayerEscape)
if c.FightC != nil {
c.FightC.Over(c, info.BattleOverReason.PlayerEscape)
}
return nil, 0
}
// 切换精灵
func (h Controller) ChangePet(data *fight.ChangePetInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
c.FightC.ChangePet(c, data.CatchTime)
if c.FightC != nil {
c.FightC.ChangePet(c, data.CatchTime)
}
return nil, -1
}