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

63 lines
1.8 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"
)
// -----------------------------------------------------------
// 通用效果n回合内指定类型的攻击对自身必定miss
// -----------------------------------------------------------
type EffectAttackMiss struct {
RoundEffectSideArg0Minus1CanStackBase
targetCategory info.EnumCategory // 差异化:目标攻击类型(物理/特殊等)
can bool
}
// 工厂函数:创建"指定攻击类型必定miss"效果实例
func newEffectAttackMiss(category info.EnumCategory) *EffectAttackMiss {
return &EffectAttackMiss{
targetCategory: category,
}
}
// 初始化:批量注册所有"攻击类型必定miss"类效果
func init() {
registerAttackMissEffects()
}
// 批量注册绑定效果ID与对应的目标攻击类型
func registerAttackMissEffects() {
// 效果ID与目标攻击类型的映射
categoryMap := map[int]info.EnumCategory{
78: info.Category.PHYSICAL, // Effect78物理攻击必定miss
86: info.Category.STATUS, // Effect86状态攻击必定miss
106: info.Category.SPECIAL, // Effect106特殊攻击必定miss
}
// 循环注册所有效果
for effectID, category := range categoryMap {
input.InitEffect(input.EffectType.Skill, effectID, newEffectAttackMiss(category))
}
}
// -----------------------------------------------------------
// 核心逻辑技能命中时若为目标攻击类型则强制miss
// -----------------------------------------------------------
func (e *EffectAttackMiss) SkillHit_ex() bool {
// 技能为空时不处理
skill := e.Ctx().SkillEntity
if skill == nil {
return true
}
// 若攻击类型匹配目标类型则强制miss设置AttackTime=0
if skill.Category() == e.targetCategory {
skill.SetMiss()
}
return true
}