Files
bl/logic/service/fight/effect/1443_1447.go
xinian 5204615c28
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
feat: 新增战斗效果并优化现有逻辑
2026-04-03 00:22:05 +08:00

171 lines
5.0 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 1443: 连续使用时威力提升{0}%,最高提升{1}%
type Effect1443 struct{ AddLvelEffect }
func (e *Effect1443) SkillHit() bool {
if len(e.Args()) < 2 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
if (e.Skillid != 0 && e.Ctx().SkillEntity.XML.ID != e.Skillid) || e.Ctx().SkillEntity.AttackTime == 0 {
return e.AddLvelEffect.SkillHit()
}
if e.UseSkillCount > 0 {
addSkillPowerPercent(e.Ctx().SkillEntity, e.GetStackOnlyADD(e.Args()[0], e.Args()[1]))
}
return e.AddLvelEffect.SkillHit()
}
// Effect 1444: 威力根据自身体力变化,当前剩余体力越少则威力越大
type Effect1444 struct{ node.EffectNode }
func (e *Effect1444) SkillHit() bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().Our.CurrentPet == nil {
return true
}
maxHP := e.Ctx().Our.CurrentPet.GetMaxHP()
if maxHP.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
power := alpacadecimal.NewFromInt(165).Sub(e.Ctx().Our.CurrentPet.GetHP().Div(maxHP).Mul(alpacadecimal.NewFromInt(65)))
if power.Cmp(alpacadecimal.Zero) > 0 {
e.Ctx().SkillEntity.XML.Power = int(power.IntPart())
}
return true
}
// Effect 1445: 吸取对手能力提升状态,吸取成功则{0}回合内对手属性技能无效,若对手不处于能力提升状态则自身下{1}回合先制+{2}
type Effect1445 struct{ node.EffectNode }
func (e *Effect1445) Skill_Use() bool {
if len(e.Args()) < 3 {
return true
}
absorbed := false
for i, v := range e.Ctx().Opp.Prop[:] {
if v <= 0 {
continue
}
if !e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), 0) {
continue
}
absorbed = true
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v)
}
if absorbed {
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 14450, int(e.Args()[0].IntPart()))
if sub != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
}
return true
}
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 14451, int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1445StatusDisableSub struct{ RoundEffectArg0Base }
func (e *Effect1445StatusDisableSub) ActionStart(a, b *action.SelectSkillAction) bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() != info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.SetMiss()
return true
}
type Effect1445PrioritySub struct{ RoundEffectArg0Base }
func (e *Effect1445PrioritySub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
if !shouldAdjustNextAttackPriority(e, fattack, sattack) || len(e.Args()) < 2 {
return true
}
sattack.SkillEntity.XML.Priority += int(e.Args()[1].IntPart())
return true
}
// Effect 1446: 获得{0}点护罩,护罩消失时使对手全属性-{1}
type Effect1446 struct{ node.EffectNode }
func (e *Effect1446) Skill_Use() bool {
if len(e.Args()) < 2 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Our.AddShield(e.Args()[0])
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1446, int(e.Args()[1].IntPart()))
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1446Sub struct{ node.EffectNode }
func (e *Effect1446Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.Duration(-1)
e.CanStack(false)
}
func (e *Effect1446Sub) ShieldChange(before, after alpacadecimal.Decimal) bool {
if before.Cmp(alpacadecimal.Zero) <= 0 || after.Cmp(alpacadecimal.Zero) > 0 {
return true
}
if len(e.Args()) > 0 {
applyAllPropDown(e.Ctx().Our, e.Ctx().Opp, int8(e.Args()[0].IntPart()))
}
e.Alive(false)
return true
}
// Effect 1447: 自身体力高于最大体力的1/{0}时{1}%令对手{2}
type Effect1447 struct{ node.EffectNode }
func (e *Effect1447) Skill_Use() bool {
if len(e.Args()) < 3 || e.Ctx().Our.CurrentPet == nil || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
return true
}
maxHP := e.Ctx().Our.CurrentPet.GetMaxHP()
if maxHP.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
if e.Ctx().Our.CurrentPet.GetHP().Mul(e.Args()[0]).Cmp(maxHP) <= 0 {
return true
}
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100); ok {
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[2].IntPart()))
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 1443, &Effect1443{})
input.InitEffect(input.EffectType.Skill, 1444, &Effect1444{})
input.InitEffect(input.EffectType.Skill, 1445, &Effect1445{})
input.InitEffect(input.EffectType.Sub, 14450, &Effect1445StatusDisableSub{})
input.InitEffect(input.EffectType.Sub, 14451, &Effect1445PrioritySub{})
input.InitEffect(input.EffectType.Skill, 1446, &Effect1446{})
input.InitEffect(input.EffectType.Sub, 1446, &Effect1446Sub{})
input.InitEffect(input.EffectType.Skill, 1447, &Effect1447{})
}