Files
bl/logic/service/fight/effect/632_636.go

168 lines
3.9 KiB
Go

package effect
import (
"blazing/logic/service/fight/action"
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
"github.com/alpacahq/alpacadecimal"
)
func effectCompareByMode(mode int, left, right alpacadecimal.Decimal) bool {
switch mode {
case 0:
return left.Cmp(right) < 0
case 1:
return left.Cmp(right) > 0
default:
return false
}
}
// Effect 632: 造成伤害{0}{1},则下{2}回合必定暴击
type Effect632 struct {
node.EffectNode
}
func (e *Effect632) Skill_Use() bool {
if !effectCompareByMode(int(e.Args()[0].IntPart()), e.Ctx().Our.SumDamage, e.Args()[1]) {
return true
}
addSubEffect(e.Ctx().Our, e.Ctx().Our, &e.EffectNode, &Effect632Sub{}, -1)
return true
}
type Effect632Sub struct {
node.EffectNode
}
func (e *Effect632Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
if len(a) > 2 {
e.Duration(a[2])
}
}
func (e *Effect632Sub) ActionStart(a, b *action.SelectSkillAction) bool {
if !e.IsOwner() {
return true
}
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.XML.CritRate = 16
return true
}
// Effect 633: 造成伤害{0}{1},则造成伤害的{2}%恢复体力
type Effect633 struct {
node.EffectNode
}
func (e *Effect633) Skill_Use() bool {
if !effectCompareByMode(int(e.Args()[0].IntPart()), e.Ctx().Our.SumDamage, e.Args()[1]) {
return true
}
if e.Ctx().Our.SumDamage.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
heal := e.Ctx().Our.SumDamage.Mul(e.Args()[2]).Div(alpacadecimal.NewFromInt(100))
if heal.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, heal)
return true
}
// Effect 634: 若当前体力{0}对手,则造成伤害的{1}%恢复体力
type Effect634 struct {
node.EffectNode
}
func (e *Effect634) Skill_Use() bool {
if !effectCompareByMode(int(e.Args()[0].IntPart()), e.Ctx().Our.CurPet[0].GetHP(), e.Ctx().Opp.CurPet[0].GetHP()) {
return true
}
if e.Ctx().Our.SumDamage.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
heal := e.Ctx().Our.SumDamage.Mul(e.Args()[1]).Div(alpacadecimal.NewFromInt(100))
if heal.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, heal)
return true
}
// Effect 635: 吸收对手能力上升状态,吸收成功,下回合先制+{0}
type Effect635 struct {
node.EffectNode
}
func (e *Effect635) Skill_Use() bool {
absorbed := false
for i, v := range e.Ctx().Opp.Prop[:] {
if v <= 0 {
continue
}
if !e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), 0) {
continue
}
absorbed = true
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v)
}
if !absorbed {
return true
}
addSubEffect(e.Ctx().Our, e.Ctx().Our, &e.EffectNode, &Effect635Sub{}, -1)
return true
}
type Effect635Sub struct {
FixedDuration1Base
}
func (e *Effect635Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
if !shouldAdjustNextAttackPriority(e, fattack, sattack) {
return true
}
sattack.SkillEntity.XML.Priority += int(e.Args()[0].IntPart())
return true
}
// Effect 636: 消除{0}状态,消除成功则令对手{1}
type Effect636 struct {
node.EffectNode
}
func (e *Effect636) Skill_Use() bool {
if !clearStatusEffects(e.Ctx().Our, int(e.Args()[0].IntPart())) {
return true
}
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(e.Args()[1].IntPart()))
if statusEffect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 632, &Effect632{})
input.InitEffect(input.EffectType.Sub, 632, &Effect632Sub{})
input.InitEffect(input.EffectType.Skill, 633, &Effect633{})
input.InitEffect(input.EffectType.Skill, 634, &Effect634{})
input.InitEffect(input.EffectType.Skill, 635, &Effect635{})
input.InitEffect(input.EffectType.Sub, 635, &Effect635Sub{})
input.InitEffect(input.EffectType.Skill, 636, &Effect636{})
}