Files
bl/logic/service/fight/boss/NewSeIdx_81.go
xinian 9c6f3988de
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
refactor: 重构 CurrentPet 为 CurPet
2026-04-04 04:34:43 +08:00

58 lines
1.4 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"
"github.com/alpacahq/alpacadecimal"
)
// 81. 体力低于n%时每次受到伤害都会使自身进入山神守护状态接下来m回合受到伤害减免90%a1: n, a2: m
type NewSel81 struct {
NewSel0
damageReduceTurns int
}
func (e *NewSel81) DamageDivEx(t *info.DamageZone) bool {
if e.ID().GetCatchTime() != e.Ctx().Our.CurPet[0].Info.CatchTime {
return true
}
// 检查当前是否处于山神守护状态
if e.damageReduceTurns > 0 {
// 减免90%伤害
reduction := t.Damage.Mul(alpacadecimal.NewFromInt(90)).Div(alpacadecimal.NewFromInt(100))
t.Damage = t.Damage.Sub(reduction)
return true
}
// 计算当前体力百分比
currentHP := e.Ctx().Our.CurPet[0].GetHP()
maxHP := e.Ctx().Our.CurPet[0].GetMaxHP()
hpPercent := currentHP.Mul(alpacadecimal.NewFromInt(100)).Div(maxHP)
// 检查是否低于阈值
if hpPercent.Cmp(e.Args()[0]) == -1 {
// 进入山神守护状态持续m回合
e.damageReduceTurns = int(e.Args()[1].IntPart())
}
return true
}
func (e *NewSel81) TurnEnd() {
// 魂印特性有不在场的情况,绑定时候将精灵和特性绑定
if e.ID().GetCatchTime() != e.Ctx().Our.CurPet[0].Info.CatchTime {
return
}
// 减少山神守护状态回合数
if e.damageReduceTurns > 0 {
e.damageReduceTurns--
}
}
func init() {
input.InitEffect(input.EffectType.NewSel, 81, &NewSel81{})
}