Files
bl/logic/service/fight/effect/effect_131.go
xinian 875ad668aa
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
feat: 实现战斗效果逻辑和接口重构
2026-03-28 21:57:22 +08:00

45 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
"github.com/alpacahq/alpacadecimal"
)
/**
* 131 对方为X性则免疫当前回合伤害
* 参数说明:
* Args[0] = X性别的数值定义例如0=无性别1=雄性2=雌性,根据业务实际枚举值调整)
*/
// 初始化效果注册
func init() {
// 注册效果类型Skill与134保持一致、效果ID=131、效果实例
input.InitEffect(input.EffectType.Skill, 131, &Effect131{})
}
// Effect 131: 对方为{0}则免疫当前回合伤害
type Effect131 struct {
node.EffectNode
}
// DamageDivEx 受击前触发(核心伤害拦截节点)
// 该方法在伤害计算前执行,适合修改/清零伤害实现免疫效果
func (e *Effect131) DamageLockEx(t *info.DamageZone) bool {
// 3. 获取配置的目标性别XArgs[0]存储X性别的数值
xGender := e.Args()[0].IntPart()
// 4. 对比对手性别与目标性别,匹配则免疫伤害
// 注需确保BattlePetEntity的Gender字段类型为int/int8与xGender类型匹配
if int(e.Ctx().Opp.CurrentPet.Info.Gender) == int(xGender) {
// 将伤害置为0实现当前回合伤害免疫
t.Damage = alpacadecimal.Zero
}
// 返回true表示允许后续流程继续仅修改伤害值不阻断流程
return true
}