Files
bl/logic/service/fight/effect/1588_1592.go
xinian 9c6f3988de
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
refactor: 重构 CurrentPet 为 CurPet
2026-04-04 04:34:43 +08:00

153 lines
4.3 KiB
Go

package effect
import (
"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 1588: 自身体力低于对手则为自身附加{0}点护盾且附加等量的固定伤害
type Effect1588 struct{ node.EffectNode }
func (e *Effect1588) Skill_Use() bool {
if len(e.Args()) == 0 || e.Ctx().Our == nil || e.Ctx().Opp == nil || e.Ctx().Our.CurPet[0] == nil || e.Ctx().Opp.CurPet[0] == nil {
return true
}
if e.Ctx().Our.CurPet[0].GetHP().Cmp(e.Ctx().Opp.CurPet[0].GetHP()) >= 0 {
return true
}
shield := e.Args()[0]
if shield.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Our.AddShield(shield)
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: shield})
return true
}
// Effect 1589: 若对手处于异常状态则令对手随机{0}项技能PP值归零
type Effect1589 struct{ node.EffectNode }
func (e *Effect1589) Skill_Use() bool {
if len(e.Args()) == 0 || e.Ctx().Opp == nil || !e.Ctx().Opp.StatEffect_Exist_all() {
return true
}
zeroRandomSkillPP(e.Ctx().Opp, int(e.Args()[0].IntPart()))
return true
}
// Effect 1590: 自身体力低于对手时100%的概率打出致命一击
type Effect1590 struct{ node.EffectNode }
func (e *Effect1590) SkillHit() bool {
if e.Ctx().Our == nil || e.Ctx().Opp == nil || e.Ctx().Our.CurPet[0] == nil || e.Ctx().Opp.CurPet[0] == nil || e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
if e.Ctx().Our.CurPet[0].GetHP().Cmp(e.Ctx().Opp.CurPet[0].GetHP()) >= 0 {
return true
}
e.Ctx().SkillEntity.XML.CritRate = 16
return true
}
// Effect 1591: {0}%秒杀对手,未触发则自身全属性+{1}
type Effect1591 struct{ node.EffectNode }
func (e *Effect1591) Skill_Use() bool {
if len(e.Args()) < 2 || e.Ctx().Opp == nil || e.Ctx().Opp.CurPet[0] == nil {
return true
}
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100); ok {
damage := e.Ctx().Opp.CurPet[0].GetMaxHP()
if damage.Cmp(alpacadecimal.Zero) > 0 {
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.True, Damage: damage})
}
return true
}
applyAllPropUp(e.Ctx().Our, int8(e.Args()[1].IntPart()))
return true
}
// Effect 1592: 风之力量觉醒,使自身下{0}次攻击获得蚀骨之风效果
type Effect1592 struct{ node.EffectNode }
func (e *Effect1592) Skill_Use() bool {
if len(e.Args()) == 0 {
return true
}
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1592, int(e.Args()[0].IntPart()))
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1592Sub struct {
node.EffectNode
remaining int
}
func (e *Effect1592Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.Duration(-1)
e.CanStack(false)
if len(a) > 0 {
e.remaining = a[0]
}
}
func (e *Effect1592Sub) DamageAdd(zone *info.DamageZone) bool {
if e.remaining <= 0 || zone == nil || zone.Type != info.DamageType.Red || e.Ctx().Opp == nil || e.Ctx().Opp.CurPet[0] == nil {
return true
}
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 {
return true
}
extra := e.Ctx().Opp.CurPet[0].GetMaxHP().Div(alpacadecimal.NewFromInt(4))
if extra.Cmp(alpacadecimal.Zero) > 0 {
zone.Damage = zone.Damage.Add(extra)
}
if ok, _, _ := e.Input.Player.Roll(50, 100); ok {
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(info.PetStatus.IceBound))
}
e.absorbRandomProps(2)
e.remaining--
if e.remaining <= 0 {
e.Alive(false)
}
return true
}
func (e *Effect1592Sub) absorbRandomProps(count int) {
if e.Ctx().Our == nil || e.Ctx().Opp == nil || count <= 0 {
return
}
if count > 6 {
count = 6
}
for _, idx := range grand.Perm(6)[:count] {
prop := int8(idx)
if !e.Ctx().Opp.SetProp(e.Ctx().Our, prop, -1) {
continue
}
e.Ctx().Our.SetProp(e.Ctx().Our, prop, 1)
}
}
func init() {
input.InitEffect(input.EffectType.Skill, 1588, &Effect1588{})
input.InitEffect(input.EffectType.Skill, 1589, &Effect1589{})
input.InitEffect(input.EffectType.Skill, 1590, &Effect1590{})
input.InitEffect(input.EffectType.Skill, 1591, &Effect1591{})
input.InitEffect(input.EffectType.Skill, 1592, &Effect1592{})
input.InitEffect(input.EffectType.Sub, 1592, &Effect1592Sub{})
}