46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package effect
|
|
|
|
import (
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/logic/service/fight/input"
|
|
"blazing/logic/service/fight/node"
|
|
|
|
"github.com/alpacahq/alpacadecimal"
|
|
)
|
|
|
|
// Effect 531: 造成的伤害低于280时每相差2点有1%的概率使对手害怕
|
|
type Effect531 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect531) Skill_Use() bool {
|
|
damageThreshold := alpacadecimal.NewFromInt(280) // 伤害阈值
|
|
|
|
// 检查造成的伤害是否低于阈值
|
|
if e.Ctx().Our.SumDamage.Cmp(damageThreshold) < 0 {
|
|
// 计算差值
|
|
damageDiff := damageThreshold.Sub(e.Ctx().Our.SumDamage)
|
|
|
|
// 每相差2点有1%的概率
|
|
probability := damageDiff.Div(alpacadecimal.NewFromInt(2)).IntPart()
|
|
|
|
// 限制概率不超过100%
|
|
if probability > 100 {
|
|
probability = 100
|
|
}
|
|
|
|
// 按概率使对手害怕
|
|
success, _, _ := e.Input.Player.Roll(int(probability), 100)
|
|
if success {
|
|
|
|
e.Ctx().Opp.AddEffect(e.Ctx().Our, e.Ctx().Opp.InitEffect(input.EffectType.Status, int(info.PetStatus.Fear)))
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
func init() {
|
|
input.InitEffect(input.EffectType.Skill, 531, &Effect531{})
|
|
}
|