242 lines
6.1 KiB
Go
242 lines
6.1 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 1208: 反转自身能力下降状态,反转成功则令对手下{0}次使用的攻击技能无效
|
|
type Effect1208 struct{ node.EffectNode }
|
|
|
|
func (e *Effect1208) Skill_Use() bool {
|
|
reversed := false
|
|
for i, v := range e.Ctx().Our.Prop[:] {
|
|
if v >= 0 {
|
|
continue
|
|
}
|
|
if e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), -2*v) {
|
|
reversed = true
|
|
}
|
|
}
|
|
if !reversed || len(e.Args()) == 0 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
|
return true
|
|
}
|
|
|
|
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1208, int(e.Args()[0].IntPart()))
|
|
if sub != nil {
|
|
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
|
|
}
|
|
return true
|
|
}
|
|
|
|
type Effect1208Sub struct {
|
|
node.EffectNode
|
|
remaining int
|
|
}
|
|
|
|
func (e *Effect1208Sub) SetArgs(t *input.Input, a ...int) {
|
|
e.EffectNode.SetArgs(t, a...)
|
|
e.Duration(-1)
|
|
if len(a) > 0 {
|
|
e.remaining = a[0]
|
|
}
|
|
}
|
|
|
|
func (e *Effect1208Sub) ActionStart(a, b *action.SelectSkillAction) bool {
|
|
if e.remaining <= 0 {
|
|
e.Alive(false)
|
|
return true
|
|
}
|
|
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
|
return true
|
|
}
|
|
|
|
e.Ctx().SkillEntity.SetMiss()
|
|
e.remaining--
|
|
if e.remaining <= 0 {
|
|
e.Alive(false)
|
|
}
|
|
return true
|
|
}
|
|
|
|
// Effect 1209: 消除双方能力上升、下降状态,消除成功则附加消除总段数乘以{0}的固定伤害
|
|
type Effect1209 struct{ node.EffectNode }
|
|
|
|
func (e *Effect1209) Skill_Use() bool {
|
|
if len(e.Args()) == 0 {
|
|
return true
|
|
}
|
|
|
|
clearedStages := clearAllPropsAndCount(e.Ctx().Our, e.Ctx().Opp)
|
|
if clearedStages <= 0 {
|
|
return true
|
|
}
|
|
|
|
damage := e.Args()[0].Mul(alpacadecimal.NewFromInt(int64(clearedStages)))
|
|
if damage.Cmp(alpacadecimal.Zero) > 0 {
|
|
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
|
Type: info.DamageType.Fixed,
|
|
Damage: damage,
|
|
})
|
|
}
|
|
return true
|
|
}
|
|
|
|
// Effect 1210: {0}%使对手{1},自身体力低于对手时概率翻倍
|
|
type Effect1210 struct{ node.EffectNode }
|
|
|
|
func (e *Effect1210) Skill_Use() bool {
|
|
if len(e.Args()) < 2 {
|
|
return true
|
|
}
|
|
|
|
chance := int(e.Args()[0].IntPart())
|
|
if e.Ctx().Our.CurrentPet.GetHP().Cmp(e.Ctx().Opp.CurrentPet.GetHP()) < 0 {
|
|
chance *= 2
|
|
}
|
|
if chance > 100 {
|
|
chance = 100
|
|
}
|
|
if ok, _, _ := e.Input.Player.Roll(chance, 100); ok {
|
|
applyStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart()))
|
|
}
|
|
return true
|
|
}
|
|
|
|
// Effect 1211: 消除双方能力提升状态及能力下降状态,消除任意一方成功则为自身附加{0}点护盾
|
|
type Effect1211 struct{ node.EffectNode }
|
|
|
|
func (e *Effect1211) Skill_Use() bool {
|
|
if clearAllPropsAndCount(e.Ctx().Our, e.Ctx().Opp) <= 0 || len(e.Args()) == 0 {
|
|
return true
|
|
}
|
|
if e.Args()[0].Cmp(alpacadecimal.Zero) > 0 {
|
|
e.Ctx().Our.AddShield(e.Args()[0])
|
|
}
|
|
return true
|
|
}
|
|
|
|
// Effect 1212: 消耗自身全部体力,使己方下只出战精灵令对手下{0}次使用的攻击技能无效且{1}回合内造成的攻击伤害额外提升{2}%
|
|
type Effect1212 struct{ node.EffectNode }
|
|
|
|
func (e *Effect1212) Skill_Use() bool {
|
|
if len(e.Args()) < 3 {
|
|
return true
|
|
}
|
|
|
|
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
|
Type: info.DamageType.Fixed,
|
|
Damage: e.Ctx().Our.CurrentPet.GetHP(),
|
|
})
|
|
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1212, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
|
|
if sub != nil {
|
|
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
|
}
|
|
return true
|
|
}
|
|
|
|
type Effect1212Sub struct{ node.EffectNode }
|
|
|
|
func (e *Effect1212Sub) SetArgs(t *input.Input, a ...int) {
|
|
e.EffectNode.SetArgs(t, a...)
|
|
e.CanStack(false)
|
|
e.Duration(1)
|
|
}
|
|
|
|
func (e *Effect1212Sub) SwitchIn(in *input.Input) bool {
|
|
if in != e.Ctx().Our || len(e.Args()) < 3 {
|
|
return true
|
|
}
|
|
|
|
lockSub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 12121, int(e.Args()[0].IntPart()))
|
|
if lockSub != nil {
|
|
e.Ctx().Opp.AddEffect(e.Ctx().Our, lockSub)
|
|
}
|
|
damageSub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 12122, int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
|
|
if damageSub != nil {
|
|
e.Ctx().Our.AddEffect(e.Ctx().Our, damageSub)
|
|
}
|
|
e.Alive(false)
|
|
return true
|
|
}
|
|
|
|
type Effect1212LockSub struct {
|
|
node.EffectNode
|
|
remaining int
|
|
}
|
|
|
|
func (e *Effect1212LockSub) SetArgs(t *input.Input, a ...int) {
|
|
e.EffectNode.SetArgs(t, a...)
|
|
e.Duration(-1)
|
|
if len(a) > 0 {
|
|
e.remaining = a[0]
|
|
}
|
|
}
|
|
|
|
func (e *Effect1212LockSub) ActionStart(a, b *action.SelectSkillAction) bool {
|
|
if e.remaining <= 0 {
|
|
e.Alive(false)
|
|
return true
|
|
}
|
|
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
|
return true
|
|
}
|
|
|
|
e.Ctx().SkillEntity.SetMiss()
|
|
e.remaining--
|
|
if e.remaining <= 0 {
|
|
e.Alive(false)
|
|
}
|
|
return true
|
|
}
|
|
|
|
type Effect1212DamageSub struct{ RoundEffectArg0Base }
|
|
|
|
func (e *Effect1212DamageSub) Damage_Mul(zone *info.DamageZone) bool {
|
|
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 2 {
|
|
return true
|
|
}
|
|
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
|
return true
|
|
}
|
|
|
|
zone.Damage = zone.Damage.Mul(hundred.Add(e.Args()[1])).Div(hundred)
|
|
return true
|
|
}
|
|
|
|
func clearAllPropsAndCount(owner, target *input.Input) int {
|
|
total := 0
|
|
for _, current := range []*input.Input{owner, target} {
|
|
for i, v := range current.Prop[:] {
|
|
if v == 0 {
|
|
continue
|
|
}
|
|
if !current.SetProp(owner, int8(i), 0) {
|
|
continue
|
|
}
|
|
if v > 0 {
|
|
total += int(v)
|
|
} else {
|
|
total += int(-v)
|
|
}
|
|
}
|
|
}
|
|
return total
|
|
}
|
|
|
|
func init() {
|
|
input.InitEffect(input.EffectType.Skill, 1208, &Effect1208{})
|
|
input.InitEffect(input.EffectType.Sub, 1208, &Effect1208Sub{})
|
|
input.InitEffect(input.EffectType.Skill, 1209, &Effect1209{})
|
|
input.InitEffect(input.EffectType.Skill, 1210, &Effect1210{})
|
|
input.InitEffect(input.EffectType.Skill, 1211, &Effect1211{})
|
|
input.InitEffect(input.EffectType.Skill, 1212, &Effect1212{})
|
|
input.InitEffect(input.EffectType.Sub, 1212, &Effect1212Sub{})
|
|
input.InitEffect(input.EffectType.Sub, 12121, &Effect1212LockSub{})
|
|
input.InitEffect(input.EffectType.Sub, 12122, &Effect1212DamageSub{})
|
|
}
|