58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
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{})
|
||
}
|