Files
bl/logic/service/fight/effect/1548_1552.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

216 lines
6.2 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 (
"math"
"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 1548: 当回合未击败对手则使自身下回合受到的伤害降低{0}%
type Effect1548 struct{ node.EffectNode }
func (e *Effect1548) Skill_Use() bool {
if len(e.Args()) == 0 || e.Ctx().Opp == nil || e.Ctx().Opp.CurPet[0] == nil || e.Ctx().Opp.CurPet[0].Info.Hp <= 0 {
return true
}
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1548, int(e.Args()[0].IntPart()))
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1548Sub struct{ node.EffectNode }
func (e *Effect1548Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.Duration(1)
e.CanStack(false)
}
func (e *Effect1548Sub) DamageDivEx(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) == 0 {
return true
}
zone.Damage = zone.Damage.Mul(hundred.Sub(e.Args()[0])).Div(hundred)
return true
}
// Effect 1549: 后出手时下回合攻击技能先制+{0}
type Effect1549 struct{ node.EffectNode }
func (e *Effect1549) Skill_Use() bool {
if len(e.Args()) == 0 || e.IsFirst() {
return true
}
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1549, int(e.Args()[0].IntPart()))
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1549Sub struct {
node.EffectNode
remaining int
priority int
}
func (e *Effect1549Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.Duration(-1)
e.CanStack(false)
e.remaining = 1
if len(a) > 0 {
e.priority = a[0]
}
}
func (e *Effect1549Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
if e.remaining <= 0 {
e.Alive(false)
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 += e.priority
e.remaining--
if e.remaining <= 0 {
e.Alive(false)
}
return true
}
// Effect 1550: 减少自身最大体力的1/2最多减少至1并附加减少量2/3的真实伤害自身的蓄力层数≥8层时不减少自身体力
type Effect1550 struct{ node.EffectNode }
func (e *Effect1550) Skill_Use() bool {
if e.Ctx().Our == nil || e.Ctx().Our.CurPet[0] == nil || e.Ctx().Opp == nil || e.Ctx().Opp.CurPet[0] == nil {
return true
}
layers := 0
if rec := getChargeRecord(e.Ctx().Our); rec != nil {
layers = rec.getLayers()
}
if layers >= 8 {
return true
}
maxHP := e.Ctx().Our.CurPet[0].GetMaxHP()
loss := maxHP.Div(alpacadecimal.NewFromInt(2))
if loss.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
newMax := maxHP.Sub(loss)
if newMax.Cmp(alpacadecimal.NewFromInt(1)) < 0 {
loss = maxHP.Sub(alpacadecimal.NewFromInt(1))
newMax = alpacadecimal.NewFromInt(1)
}
if loss.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Our.CurPet[0].Info.MaxHp = uint32(newMax.IntPart())
if e.Ctx().Our.CurPet[0].Info.Hp > e.Ctx().Our.CurPet[0].Info.MaxHp {
e.Ctx().Our.CurPet[0].Info.Hp = e.Ctx().Our.CurPet[0].Info.MaxHp
}
damage := loss.Mul(alpacadecimal.NewFromInt(2)).Div(alpacadecimal.NewFromInt(3))
if damage.Cmp(alpacadecimal.Zero) > 0 {
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.True,
Damage: damage,
})
}
return true
}
// Effect 1551: {0}%消耗自身全部体力,{1}%消耗敌方全部体力若自身触发效果则消除敌方所有PP值若敌方触发效果则消除自身所有PP值均未触发则恢复自身全部体力
type Effect1551 struct{ node.EffectNode }
func (e *Effect1551) Skill_Use() bool {
if len(e.Args()) < 2 || e.Ctx().Our == nil || e.Ctx().Our.CurPet[0] == nil || e.Ctx().Opp == nil || e.Ctx().Opp.CurPet[0] == nil {
return true
}
selfTriggered, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100)
oppTriggered, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100)
if selfTriggered {
damage := e.Ctx().Our.CurPet[0].GetHP()
if damage.Cmp(alpacadecimal.Zero) > 0 {
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: damage})
}
zeroAllSkillPP(e.Ctx().Opp)
}
if oppTriggered {
damage := e.Ctx().Opp.CurPet[0].GetHP()
if damage.Cmp(alpacadecimal.Zero) > 0 {
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: damage})
}
zeroAllSkillPP(e.Ctx().Our)
}
if selfTriggered || oppTriggered {
return true
}
e.Ctx().Our.Heal(
e.Ctx().Our,
&action.SelectSkillAction{BaseAction: action.BaseAction{PlayerID: e.Ctx().Our.UserID}},
e.Ctx().Our.CurPet[0].GetMaxHP(),
)
return true
}
// Effect 1552: 集结天幕四龙之神力使自身下2回合攻击必定先手、必定命中、必定致命
type Effect1552 struct{ node.EffectNode }
func (e *Effect1552) Skill_Use() bool {
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1552)
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1552Sub struct{ FixedDuration2Base }
func (e *Effect1552Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
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 = math.MaxInt
return true
}
func (e *Effect1552Sub) ActionStart(a, b *action.SelectSkillAction) bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.XML.MustHit = 1
e.Ctx().SkillEntity.XML.CritRate = 16
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 1548, &Effect1548{})
input.InitEffect(input.EffectType.Sub, 1548, &Effect1548Sub{})
input.InitEffect(input.EffectType.Skill, 1549, &Effect1549{})
input.InitEffect(input.EffectType.Sub, 1549, &Effect1549Sub{})
input.InitEffect(input.EffectType.Skill, 1550, &Effect1550{})
input.InitEffect(input.EffectType.Skill, 1551, &Effect1551{})
input.InitEffect(input.EffectType.Skill, 1552, &Effect1552{})
input.InitEffect(input.EffectType.Sub, 1552, &Effect1552Sub{})
}