refactor: 重、、、、

This commit is contained in:
xinian
2026-04-04 06:11:01 +08:00
committed by cnb
parent 28d92c1e18
commit 3a9932e307
18 changed files with 665 additions and 680 deletions

View File

@@ -2,11 +2,49 @@ package input
import "blazing/logic/service/fight/info"
type LegacySides struct {
Our *Input // 兼容旧 effect当前执行侧
Opp *Input // 兼容旧 effect当前执行侧的对位
}
type EffectBinding struct {
Source *Input // effect 绑定的输入源,等价于 e.GetInput()
Carrier *Input // 当前持有该 effect 的输入源
Target *Input // 当前 effect 实际作用/挂载的输入源
}
type Ctx struct {
Our *Input //施加方
Opp *Input //被施加方
LegacySides
EffectBinding
*info.SkillEntity //action本身
// *info.DamageZone //伤害
}
func (c *Ctx) Self() *Input {
if c == nil {
return nil
}
if c.Source != nil {
return c.Source
}
return c.Our
}
func (c *Ctx) Receiver() *Input {
if c == nil {
return nil
}
if c.Target != nil {
return c.Target
}
if c.Carrier != nil {
return c.Carrier
}
return c.Our
}

View File

@@ -171,6 +171,17 @@ func equalInts(a, b []alpacadecimal.Decimal) bool {
// 返回被替换eddect
func (our *Input) AddEffect(in *Input, e Effect) Effect {
if e == nil {
return nil
}
ctx := e.Ctx()
if ctx != nil {
if ctx.Source == nil {
ctx.Source = in
}
ctx.Carrier = our
ctx.Target = our
}
if in != our {
canuseskill := our.Exec(func(t Effect) bool { //这个是能否使用技能
@@ -233,8 +244,15 @@ func (our *Input) Exec(fn func(Effect) bool) bool {
result := true
for _, value := range our.Effects {
if value.Alive() {
value.Ctx().Our = our
value.Ctx().Opp = our.Opp
ctx := value.Ctx()
ctx.Our = our
ctx.Opp = our.Opp
ctx.Carrier = our
ctx.Target = our
ctx.Source = value.GetInput()
if ctx.Source == nil {
ctx.Source = our
}
//value.Ctx().DamageZone = &info.DamageZone{}
if !fn(value) { //存在false,但是仍然要向下执行
result = false //如果是false,说明存在阻止向下执行的effect比如免疫能力提升效果