``` fix(fight): 重构切换动作逻辑,将CanChange改为状态值并优化切换条件检查

This commit is contained in:
1
2025-12-10 16:42:23 +00:00
parent e30f0b7860
commit f6043fd9b9
3 changed files with 25 additions and 8 deletions

View File

@@ -332,7 +332,7 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
}
}
attacker.CanChange = true
//attacker.CanAction = true
break
}
@@ -342,7 +342,7 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
attacker.CurrentPet.Info.Hp = 1
}
defender.CanChange = true //被打死就可以切精灵了
//defender.CanAction = true //被打死就可以切精灵了
// AI自动技能
if f.IsWin(attacker, defender.CurrentPet.Info.CatchTime) { //然后检查是否战斗结束
@@ -403,6 +403,6 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
}
f.Broadcast(func(ff *input.Input) {
ff.Player.SendPackCmd(2505, &ret)
ff.CanChange = true
ff.CanChange = 0
})
}

View File

@@ -14,7 +14,8 @@ import (
)
type Input struct {
CanChange bool //是否可以死亡切换CanChange
CanChange uint32 //是否可以死亡切换CanChange
// CanAction bool //是否可以行动
CurrentPet *info.BattlePetEntity //当前精灵
AllPet []*info.BattlePetEntity
Player common.PlayerI

View File

@@ -139,11 +139,18 @@ func (f *FightC) collectPlayerActions(ourID, oppID uint32) map[uint32]action.Bat
// fmt.Printf("玩家%d 已经提交过动作,忽略重复\n", pid)
// continue
// }
selfinput := f.GetInputByAction(paction, false)
if ret, ok := paction.(*action.ActiveSwitchAction); ok {
selfinput := f.GetInputByAction(paction, false)
if selfinput.CanChange {
selfinput.CanChange = false
if selfinput.CanChange == 0 {
if selfinput.CurrentPet.Info.Hp > 0 { //非死亡切换
selfinput.CanChange = 1
} else {
selfinput.CanChange = 2
}
InitAttackValue := *selfinput.AttackValue
oldpet := selfinput.CurrentPet
f.Switch[selfinput.UserID] = ret
@@ -162,6 +169,15 @@ func (f *FightC) collectPlayerActions(ourID, oppID uint32) map[uint32]action.Bat
})
}
} else {
if selfinput.CurrentPet.Info.Hp <= 0 { //0血执行非切换动作
//todo 记录异常操作
continue
}
if selfinput.CanChange == 1 { //非被动死亡情况下,不能执行额外动作,0允许切2是死亡可以额外动作
continue
}
}
// AI自动技能
if pid != 0 && (f.Info.Status == info.BattleMode.FIGHT_WITH_NPC) {