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

36 lines
873 B
Go

package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
"github.com/alpacahq/alpacadecimal"
)
// Effect 140: 随机降低对手1/{0}至1/{1}的当前体力值
type Effect140 struct {
node.EffectNode
}
func (e *Effect140) Skill_Use() bool {
maxHp := e.Ctx().Opp.CurrentPet.GetMaxHP()
// 随机降低1/n 到 1/m 的体力
minRatio := alpacadecimal.NewFromFloat(1.0).Div(e.Args()[0]) // 1/n
maxRatio := alpacadecimal.NewFromFloat(1.0).Div(e.Args()[1]) // 1/m
randDamage := minRatio.Add(maxRatio.Sub(minRatio).Div(alpacadecimal.NewFromInt(2)))
damageZone := &info.DamageZone{
Type: info.DamageType.Percent,
Damage: maxHp.Mul(randDamage),
}
e.Ctx().Opp.Damage(e.Ctx().Our, damageZone)
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 140, &Effect140{})
}