Files
bl/logic/service/fight/effect/EffectRandomPower.go
昔念 f224bef17a feat(fight): 移除无用代码并优化技能效果逻辑
- 删除了多个未使用的技能效果文件(effect_10-16_94_99_14.go、effect_61_70_118.go、
  effect_66.go、effect_67.go、effect_78_86_106.go、effect_84_92.go、prop.go)
- 修正了部分技能效果中的错误逻辑判断和数值计算方式
- 调整了伤害计算与治疗效果的参数使用顺序,使其符合预期行为
- 注释掉调试打印语句及测试调用,减少冗余输出
- 修复了部分效果中对技能分类的错误比较条件

此次修改提升了战斗系统代码的整洁性和准确性。
2025-11-14 02:04:19 +08:00

58 lines
1.5 KiB
Go

package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
"math/rand"
)
// -----------------------------------------------------------
// 威力随机效果
// -----------------------------------------------------------
// 威力将在 [Min, Max] 区间内随机取值
type EffectRandomPower struct {
node.EffectNode
Min int
Max int
}
// -----------------------------------------------------------
// 初始化注册
// -----------------------------------------------------------
func init() {
registerRandomPower(61, 50, 150)
registerRandomPower(70, 140, 220)
registerRandomPower(118, 140, 180)
}
// -----------------------------------------------------------
// 工厂函数:注册不同威力范围的技能效果
// -----------------------------------------------------------
func registerRandomPower(effectID, min, max int) {
input.InitEffect(input.EffectType.Skill, effectID, &EffectRandomPower{
Min: min,
Max: max,
})
}
// -----------------------------------------------------------
// 命中时触发
// -----------------------------------------------------------
func (e *EffectRandomPower) Skill_Hit() bool {
if e.Max <= e.Min {
e.Ctx().SkillEntity.Power = e.Min
return true
}
// 如果 FightC 没提供随机器,使用 math/rand 兜底
var n int
if e.Input != nil && e.Input.FightC != nil {
n = int(e.Input.FightC.GetRand().Int31n(int32(e.Max-e.Min+1))) + e.Min
} else {
n = rand.Intn(e.Max-e.Min+1) + e.Min
}
e.Ctx().SkillEntity.Power = n
return true
}