Files
bl/logic/service/fight/effect/1413_1417.go
2026-04-02 16:24:16 +08:00

185 lines
5.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"
"github.com/gogf/gf/v2/util/grand"
)
// Effect 1413: {0}%的概率打出致命一击,未触发则下{1}回合自身先制+{2}
type Effect1413 struct{ node.EffectNode }
func (e *Effect1413) SkillHit() bool {
if len(e.Args()) < 3 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100)
if ok {
e.Ctx().SkillEntity.XML.CritRate = 16
return true
}
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1413, int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1413Sub struct{ RoundEffectArg0Base }
func (e *Effect1413Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
if len(e.Args()) < 2 {
return true
}
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if current == nil || current.SkillEntity == nil {
return true
}
current.SkillEntity.XML.Priority += int(e.Args()[1].IntPart())
return true
}
// Effect 1414: 消除敌我双方回合类效果,消除任意一项成功则敌我双方同时进入{0}状态
type Effect1414 struct{ node.EffectNode }
func (e *Effect1414) Skill_Use() bool {
if len(e.Args()) == 0 {
return true
}
ourTurn := activeTurnEffectCount(e.Ctx().Our)
oppTurn := activeTurnEffectCount(e.Ctx().Opp)
e.Ctx().Our.CancelTurn(e.Ctx().Our)
e.Ctx().Opp.CancelTurn(e.Ctx().Our)
if ourTurn+oppTurn <= 0 {
return true
}
statusID := int(e.Args()[0].IntPart())
addStatusByID(e.Ctx().Our, e.Ctx().Our, statusID)
addStatusByID(e.Ctx().Our, e.Ctx().Opp, statusID)
return true
}
// Effect 1415: 造成伤害的{0}%恢复自身体力,若自身体力低于对手则效果提升至{1}%
type Effect1415 struct{ node.EffectNode }
func (e *Effect1415) Skill_Use() bool {
if len(e.Args()) < 2 || e.Ctx().Our.SumDamage.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
percent := e.Args()[0]
if e.Ctx().Our.CurrentPet.GetHP().Cmp(e.Ctx().Opp.CurrentPet.GetHP()) < 0 {
percent = e.Args()[1]
}
heal := e.Ctx().Our.SumDamage.Mul(percent).Div(hundred)
if heal.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, heal)
return true
}
// Effect 1416: 消耗自身全部体力使对手受到自身最大体力1/{0}的百分比伤害,同时使自身下只出场精灵前{1}回合{2}%闪避对手的攻击技能
type Effect1416 struct{ node.EffectNode }
func (e *Effect1416) Skill_Use() bool {
if len(e.Args()) < 3 || e.Ctx().Our.CurrentPet == nil || e.Ctx().Opp.CurrentPet == nil || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
return true
}
maxHP := e.Ctx().Our.CurrentPet.GetMaxHP()
selfHP := e.Ctx().Our.CurrentPet.GetHP()
if selfHP.Cmp(alpacadecimal.Zero) > 0 {
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: selfHP})
}
damage := maxHP.Div(e.Args()[0])
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, 1416, e.SideEffectArgs...)
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1416Sub struct {
node.EffectNode
pending bool
}
func (e *Effect1416Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.Duration(-1)
e.CanStack(false)
e.pending = true
}
func (e *Effect1416Sub) SwitchIn(in *input.Input) bool {
if !e.pending || in != e.Ctx().Our || len(e.Args()) < 3 {
return true
}
e.pending = false
e.Duration(int(e.Args()[1].IntPart()))
if e.Duration() <= 0 {
e.Alive(false)
}
return true
}
func (e *Effect1416Sub) SkillHit_ex() bool {
if e.pending || len(e.Args()) < 3 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
ok, _, _ := e.Input.Player.Roll(int(e.Args()[2].IntPart()), 100)
if ok {
e.Ctx().SkillEntity.SetMiss()
}
return true
}
// Effect 1417: 对手不处于能力下降状态则使对手随机{0}项能力值-{1}
type Effect1417 struct{ node.EffectNode }
func (e *Effect1417) OnSkill() bool {
if len(e.Args()) < 2 || e.Ctx().Opp.HasPropSub() {
return true
}
count := int(e.Args()[0].IntPart())
level := int8(e.Args()[1].IntPart())
if count <= 0 || level <= 0 {
return true
}
indexes := grand.Perm(len(e.Ctx().Opp.Prop))
if count > len(indexes) {
count = len(indexes)
}
for _, idx := range indexes[:count] {
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(idx), -level)
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 1413, &Effect1413{})
input.InitEffect(input.EffectType.Sub, 1413, &Effect1413Sub{})
input.InitEffect(input.EffectType.Skill, 1414, &Effect1414{})
input.InitEffect(input.EffectType.Skill, 1415, &Effect1415{})
input.InitEffect(input.EffectType.Skill, 1416, &Effect1416{})
input.InitEffect(input.EffectType.Sub, 1416, &Effect1416Sub{})
input.InitEffect(input.EffectType.Skill, 1417, &Effect1417{})
}