212 lines
5.9 KiB
Go
212 lines
5.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"
|
||
)
|
||
|
||
// Effect 1518: 消耗自身所有体力,削减对手本场战斗中{0}点体力上限
|
||
type Effect1518 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1518) Skill_Use() bool {
|
||
if len(e.Args()) == 0 || e.Ctx().Our == nil || e.Ctx().Our.CurrentPet == nil || e.Ctx().Opp == nil {
|
||
return true
|
||
}
|
||
|
||
if e.Ctx().Our.CurrentPet.GetHP().Cmp(alpacadecimal.Zero) > 0 {
|
||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: e.Ctx().Our.CurrentPet.GetHP(),
|
||
})
|
||
}
|
||
|
||
loss := e.Args()[0]
|
||
if loss.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
reduceCurrentPetMaxHPFlat(e.Ctx().Opp, loss)
|
||
sub := e.Ctx().Opp.InitEffect(input.EffectType.Sub, 1518, int(loss.IntPart()))
|
||
if sub != nil {
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1518Sub struct{ node.EffectNode }
|
||
|
||
func (e *Effect1518Sub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(-1)
|
||
e.CanStack(false)
|
||
}
|
||
|
||
func (e *Effect1518Sub) SwitchIn(in *input.Input) bool {
|
||
if in != e.Ctx().Opp || len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
reduceCurrentPetMaxHPFlat(in, e.Args()[0])
|
||
return true
|
||
}
|
||
|
||
// Effect 1519: {0}%令对手随机{1}项技能PP值归零,若对手处于能力下降状态则{2}%使对手随机{3}项技能PP值归零
|
||
type Effect1519 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1519) Skill_Use() bool {
|
||
if len(e.Args()) < 4 || e.Ctx().Opp == nil {
|
||
return true
|
||
}
|
||
|
||
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100); ok {
|
||
zeroRandomSkillPP(e.Ctx().Opp, int(e.Args()[1].IntPart()))
|
||
return true
|
||
}
|
||
|
||
if !e.Ctx().Opp.HasPropSub() {
|
||
return true
|
||
}
|
||
|
||
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[2].IntPart()), 100); ok {
|
||
zeroRandomSkillPP(e.Ctx().Opp, int(e.Args()[3].IntPart()))
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1520: 若对手为雄性精灵则附加自身最大体力1/{0}的百分比伤害且下回合攻击技能先制+{1}
|
||
type Effect1520 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1520) Skill_Use() bool {
|
||
if len(e.Args()) < 2 || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil || e.Ctx().Our == nil || e.Ctx().Our.CurrentPet == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().Opp.CurrentPet.Info.Gender != 1 {
|
||
return true
|
||
}
|
||
|
||
denom := e.Args()[0]
|
||
if denom.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
damage := e.Ctx().Our.CurrentPet.GetMaxHP().Div(denom)
|
||
if damage.Cmp(alpacadecimal.Zero) > 0 {
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Percent,
|
||
Damage: damage,
|
||
})
|
||
}
|
||
|
||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1520, int(e.Args()[1].IntPart()))
|
||
if sub != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1520Sub struct{ node.EffectNode }
|
||
|
||
func (e *Effect1520Sub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(1)
|
||
e.CanStack(false)
|
||
}
|
||
|
||
func (e *Effect1520Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
|
||
if current == nil || current.SkillEntity == nil || current.SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
current.SkillEntity.XML.Priority += int(e.Args()[0].IntPart())
|
||
return true
|
||
}
|
||
|
||
// Effect 1521: 若对手雌性精灵则恢复自身最大体力的1/{0}且下回合属性技能先制+{1}
|
||
type Effect1521 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1521) Skill_Use() bool {
|
||
if len(e.Args()) < 2 || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil || e.Ctx().Our == nil || e.Ctx().Our.CurrentPet == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().Opp.CurrentPet.Info.Gender != 2 {
|
||
return true
|
||
}
|
||
|
||
denom := e.Args()[0]
|
||
if denom.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
heal := e.Ctx().Our.CurrentPet.GetMaxHP().Div(denom)
|
||
if heal.Cmp(alpacadecimal.Zero) > 0 {
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, heal)
|
||
}
|
||
|
||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1521, int(e.Args()[1].IntPart()))
|
||
if sub != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1521Sub struct{ node.EffectNode }
|
||
|
||
func (e *Effect1521Sub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(1)
|
||
e.CanStack(false)
|
||
}
|
||
|
||
func (e *Effect1521Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
|
||
if current == nil || current.SkillEntity == nil || current.SkillEntity.Category() != info.Category.STATUS {
|
||
return true
|
||
}
|
||
current.SkillEntity.XML.Priority += int(e.Args()[0].IntPart())
|
||
return true
|
||
}
|
||
|
||
// Effect 1522: 附加{0}点固定伤害,若当回合造成的伤害高于{1}则固伤效果翻倍
|
||
type Effect1522 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1522) OnSkill() bool {
|
||
if len(e.Args()) < 2 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 {
|
||
return true
|
||
}
|
||
|
||
damage := e.Args()[0]
|
||
if damage.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
if e.Ctx().Our.SumDamage.Cmp(e.Args()[1]) > 0 {
|
||
damage = damage.Mul(alpacadecimal.NewFromInt(2))
|
||
}
|
||
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: damage,
|
||
})
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 1518, &Effect1518{})
|
||
input.InitEffect(input.EffectType.Sub, 1518, &Effect1518Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1519, &Effect1519{})
|
||
input.InitEffect(input.EffectType.Skill, 1520, &Effect1520{})
|
||
input.InitEffect(input.EffectType.Sub, 1520, &Effect1520Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1521, &Effect1521{})
|
||
input.InitEffect(input.EffectType.Sub, 1521, &Effect1521Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1522, &Effect1522{})
|
||
}
|