Files
bl/logic/service/fight/effect/EffectRandomPower.go
昔念 142ef11a99 ```
refactor(fight): 统一战斗系统函数命名规范

统一了boss技能和效果系统中的函数命名规范,将下划线命名方式
改为驼峰命名方式,提高代码一致性和可读性。

函数名变更包括:
- Prop_Befer -> PropBefer
- Damage_DIV_ex -> DamageDivEx
- Compare_Pre -> ComparePre
- Skill_Hit_ex -> SkillHit_ex
- Damage_SUB_ex -> DamageSubEx
- Skill_Hit -> SkillHit
- DamageLock_ex -> DamageLock_ex

同时更新了相关注释中的函数名引用,
2026-01-04 22:10:34 +08:00

59 lines
1.6 KiB
Go

package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
"github.com/gogf/gf/v2/util/grand"
)
// -----------------------------------------------------------
// 威力随机效果
// -----------------------------------------------------------
// 威力将在 [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) SkillHit() 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 = grand.Intn(e.Max-e.Min+1) + e.Min
// }
n := grand.N(e.Min, e.Max)
e.Ctx().SkillEntity.Power = n
return true
}