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

60 lines
1.2 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"
"blazing/logic/service/fight/node"
"sync"
"github.com/alpacahq/alpacadecimal"
"github.com/gogf/gf/v2/util/grand"
)
/**
* m~n回合每回合反弹对手1/k的伤害
*/
func init() {
input.InitEffect(input.EffectType.Skill, 21, &Effect21{})
}
// Effect 21: 未在 effectInfo.json 配置说明
type Effect21 struct {
node.EffectNode
l sync.Once
}
// 使用技能时不可被继承继承Miss和Hit就行
func (e *Effect21) OnSkill() bool {
e.l.Do(func() { //保证技能使用后初始化一次就行
statIndex := e.SideEffectArgs[0]
endindex := e.SideEffectArgs[1]
//回合产生
n := grand.Intn(endindex-statIndex+1) + statIndex
e.Duration(n) //产生回合收益
//e.Input.AddEffect(input.Geteffect(input.EffectType.Status, int(info.PetStatus.Tired)))
})
return true
}
// 被攻击时候反弹
func (e *Effect21) Skill_Use_ex() bool {
//不是技能
if e.Ctx().SkillEntity == nil {
return true
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Opp.SumDamage.IntPart())).Div(alpacadecimal.NewFromInt(int64(e.SideEffectArgs[0]))),
})
return true
}