222 lines
5.0 KiB
Go
222 lines
5.0 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 clearStatusEffects(target *input.Input, statusID int) bool {
|
|
cleared := false
|
|
for _, eff := range target.Effects {
|
|
if eff == nil || !eff.Alive() {
|
|
continue
|
|
}
|
|
effID := eff.ID()
|
|
if effID.GetEffectType() != input.EffectType.Status || int(effID.Suffix()) != statusID {
|
|
continue
|
|
}
|
|
eff.Alive(false)
|
|
cleared = true
|
|
}
|
|
return cleared
|
|
}
|
|
|
|
func shouldAdjustNextAttackPriority(e input.Effect, fattack, sattack *action.SelectSkillAction) bool {
|
|
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
|
return false
|
|
}
|
|
if fattack == nil || fattack.PlayerID == e.Ctx().Our.UserID {
|
|
return false
|
|
}
|
|
if sattack == nil || sattack.SkillEntity == nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
// Effect 627: 对手处于能力提升状态时附加其{0}值{1}%的百分比伤害
|
|
type Effect627 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect627) OnSkill() bool {
|
|
if !e.Ctx().Opp.HasPropADD() {
|
|
return true
|
|
}
|
|
|
|
propID := int(e.Args()[0].IntPart())
|
|
if propID < 0 || propID >= 6 {
|
|
return true
|
|
}
|
|
|
|
damage := e.Ctx().Opp.GetProp(propID).Mul(e.Args()[1]).Div(alpacadecimal.NewFromInt(100))
|
|
if damage.Cmp(alpacadecimal.Zero) <= 0 {
|
|
return true
|
|
}
|
|
|
|
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
|
Type: info.DamageType.Fixed,
|
|
Damage: damage,
|
|
})
|
|
return true
|
|
}
|
|
|
|
// Effect 628: 若对手处于能力下降状态则造成伤害的{0}%恢复体力
|
|
type Effect628 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect628) Skill_Use() bool {
|
|
if !e.Ctx().Opp.HasPropSub() {
|
|
return true
|
|
}
|
|
if e.Ctx().Our.SumDamage.Cmp(alpacadecimal.Zero) <= 0 {
|
|
return true
|
|
}
|
|
|
|
heal := e.Ctx().Our.SumDamage.Mul(e.Args()[0]).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 629: 消除{0}状态,消除成功下回合自身先制+{1}
|
|
type Effect629 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect629) Skill_Use() bool {
|
|
if !clearStatusEffects(e.Ctx().Our, int(e.Args()[0].IntPart())) {
|
|
return true
|
|
}
|
|
|
|
addSubEffect(e.Ctx().Our, e.Ctx().Our, &e.EffectNode, &Effect629Sub{}, -1)
|
|
return true
|
|
}
|
|
|
|
type Effect629Sub struct {
|
|
FixedDuration1Base
|
|
}
|
|
|
|
func (e *Effect629Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
|
if !shouldAdjustNextAttackPriority(e, fattack, sattack) {
|
|
return true
|
|
}
|
|
|
|
sattack.SkillEntity.XML.Priority += int(e.Args()[1].IntPart())
|
|
return true
|
|
}
|
|
|
|
// Effect 630: {0}回合内{1}状态被消除,则有{2}%概率使对手{3}
|
|
type Effect630 struct {
|
|
RoundEffectArg0Base
|
|
initialized bool
|
|
lastExists bool
|
|
triggered bool
|
|
}
|
|
|
|
func (e *Effect630) observeStatusRemoval() {
|
|
if e.triggered {
|
|
return
|
|
}
|
|
|
|
statusID := int(e.Args()[1].IntPart())
|
|
exists := e.Ctx().Our.StatEffect_Exist(info.EnumPetStatus(statusID))
|
|
if !e.initialized {
|
|
e.initialized = true
|
|
e.lastExists = exists
|
|
return
|
|
}
|
|
|
|
if e.lastExists && !exists {
|
|
e.triggered = true
|
|
success, _, _ := e.Input.Player.Roll(int(e.Args()[2].IntPart()), 100)
|
|
if success {
|
|
applyEffectPropChanges(e.Ctx().Opp, e.Ctx().Our, e.SideEffectArgs[3:], false)
|
|
}
|
|
e.Alive(false)
|
|
return
|
|
}
|
|
|
|
e.lastExists = exists
|
|
}
|
|
|
|
func (e *Effect630) TurnStart(fattack, sattack *action.SelectSkillAction) {
|
|
e.observeStatusRemoval()
|
|
}
|
|
|
|
func (e *Effect630) ActionStart(fattack, sattack *action.SelectSkillAction) bool {
|
|
e.observeStatusRemoval()
|
|
return true
|
|
}
|
|
|
|
func (e *Effect630) OnSkill() bool {
|
|
e.observeStatusRemoval()
|
|
return true
|
|
}
|
|
|
|
func (e *Effect630) Skill_Use() bool {
|
|
e.observeStatusRemoval()
|
|
return true
|
|
}
|
|
|
|
func (e *Effect630) Skill_Use_ex() bool {
|
|
e.observeStatusRemoval()
|
|
return true
|
|
}
|
|
|
|
func (e *Effect630) Action_end() bool {
|
|
e.observeStatusRemoval()
|
|
return true
|
|
}
|
|
|
|
func (e *Effect630) Action_end_ex() bool {
|
|
e.observeStatusRemoval()
|
|
return true
|
|
}
|
|
|
|
// Effect 631: 消除{0}状态,消除成功下回合造成伤害提升{1}%
|
|
type Effect631 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect631) Skill_Use() bool {
|
|
if !clearStatusEffects(e.Ctx().Our, int(e.Args()[0].IntPart())) {
|
|
return true
|
|
}
|
|
|
|
addSubEffect(e.Ctx().Our, e.Ctx().Our, &e.EffectNode, &Effect631Sub{}, -1)
|
|
return true
|
|
}
|
|
|
|
type Effect631Sub struct {
|
|
FixedDuration1Base
|
|
}
|
|
|
|
func (e *Effect631Sub) Damage_Mul(zone *info.DamageZone) bool {
|
|
if zone == nil || zone.Type != info.DamageType.Red {
|
|
return true
|
|
}
|
|
|
|
bonus := zone.Damage.Mul(e.Args()[1]).Div(alpacadecimal.NewFromInt(100))
|
|
zone.Damage = zone.Damage.Add(bonus)
|
|
return true
|
|
}
|
|
|
|
func init() {
|
|
input.InitEffect(input.EffectType.Skill, 627, &Effect627{})
|
|
input.InitEffect(input.EffectType.Skill, 628, &Effect628{})
|
|
input.InitEffect(input.EffectType.Skill, 629, &Effect629{})
|
|
input.InitEffect(input.EffectType.Sub, 629, &Effect629Sub{})
|
|
input.InitEffect(input.EffectType.Skill, 630, &Effect630{})
|
|
input.InitEffect(input.EffectType.Skill, 631, &Effect631{})
|
|
input.InitEffect(input.EffectType.Sub, 631, &Effect631Sub{})
|
|
}
|