Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
fix(fight): 修复技能实体属性访问问题 - 修改所有技能实体的ID、Power、CritRate、MustHit、Priority等属性访问方式 从直接访问改为通过XML字段访问,确保数据一致性 - 更新多个boss技能效果处理逻辑中的属性引用路径 - 移除已废弃的effect/486文件 - 在New
59 lines
1.6 KiB
Go
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.XML.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.XML.Power = n
|
|
return true
|
|
}
|