refactor(fight/effect): 实现精灵切换相关触发接口并优化效果持续时间处理

This commit is contained in:
1
2025-09-24 20:17:44 +00:00
parent 5a8d84ed40
commit 726a2d6cb5
3 changed files with 28 additions and 10 deletions

View File

@@ -47,7 +47,7 @@ func (e *Effect62) AfterHit(*input.Input, *info.SkillEntity) {
func (e *Effect62) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0]) //激活前无限挂载
e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0])
}

View File

@@ -48,10 +48,10 @@ type Effect interface {
// OnHeal() bool // 治疗生效时触发
// // 精灵切换相关触发
// OnSwitchIn() bool // 精灵出战 / 上场时触发
// OnSwitchOut() bool // 精灵下场时触发
// OnOwnerSwitchIn() bool // 所属玩家精灵出战时触发
// OnOwnerSwitchOut() bool // 所属玩家精灵下场时触发
OnSwitchIn() bool // 精灵出战 / 上场时触发
OnSwitchOut() bool // 精灵下场时触发
OnOwnerSwitchIn() bool // 所属玩家精灵出战时触发
OnOwnerSwitchOut() bool // 所属玩家精灵下场时触发
// PreBattleEnd() bool //战斗结束前
// OnBattleEnd() bool //战斗结束

View File

@@ -4,6 +4,7 @@ import (
"blazing/common/data/xmlres"
"blazing/logic/service/common"
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/player"
"math"
@@ -36,14 +37,31 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) {
BaseAction: NewBaseAction(c.GetInfo().UserID),
}
f.Switch = append(f.Switch, ret)
if c.GetInfo().UserID == f.ownerID {
f.GetInputByPlayer(c, false).Exec(func(t input.Effect) bool {
f.GetInputByPlayer(c, false).CurrentPet, ret.Reason = f.GetInputByPlayer(c, false).GetPet(id)
} else {
t.OnOwnerSwitchOut()
f.GetInputByPlayer(c, true).CurrentPet, ret.Reason = f.GetInputByPlayer(c, true).GetPet(id)
}
return true
})
f.GetInputByPlayer(c, true).Exec(func(t input.Effect) bool {
t.OnSwitchOut()
return true
})
f.GetInputByPlayer(c, false).CurrentPet, ret.Reason = f.GetInputByPlayer(c, false).GetPet(id)
f.GetInputByPlayer(c, false).Exec(func(t input.Effect) bool {
t.OnOwnerSwitchIn()
return true
})
f.GetInputByPlayer(c, true).Exec(func(t input.Effect) bool {
t.OnSwitchIn()
return true
})
f.actionChan <- ret
}