52 lines
1.3 KiB
Go
52 lines
1.3 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, 150, 220)
|
|
registerRandomPower(118, 150, 220)
|
|
}
|
|
|
|
// -----------------------------------------------------------
|
|
// 工厂函数:注册不同威力范围的技能效果
|
|
// -----------------------------------------------------------
|
|
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.XML.Power = e.Min
|
|
return true
|
|
}
|
|
|
|
n := grand.N(e.Min, e.Max)
|
|
e.Ctx().SkillEntity.XML.Power = n
|
|
return true
|
|
}
|