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

158 lines
4.3 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 1117: 若自身体力低于最大体力的1/2则先制+2
type Effect1117 struct{ node.EffectNode }
func (e *Effect1117) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
if e.Ctx().Our.CurPet[0].GetHP().Mul(alpacadecimal.NewFromInt(2)).Cmp(e.Ctx().Our.CurPet[0].GetMaxHP()) >= 0 {
return true
}
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if current != nil && current.SkillEntity != nil {
current.SkillEntity.XML.Priority += 2
}
return true
}
// Effect 1118: {0}回合内对手若使用攻击技能则{1}%{2},若使用属性技能则全属性-{3}
type Effect1118 struct{ node.EffectNode }
func (e *Effect1118) Skill_Use() bool {
if len(e.Args()) < 4 {
return true
}
sub := e.Ctx().Our.InitEffect(
input.EffectType.Sub,
1118,
int(e.Args()[0].IntPart()),
int(e.Args()[1].IntPart()),
int(e.Args()[2].IntPart()),
int(e.Args()[3].IntPart()),
)
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1118Sub struct{ RoundEffectArg0Base }
func (e *Effect1118Sub) Skill_Use_ex() bool {
if len(e.Args()) < 4 || e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
applyAllPropDown(e.Ctx().Our, e.Ctx().Opp, int8(e.Args()[3].IntPart()))
return true
}
success, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100)
if success {
applyStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[2].IntPart()))
}
return true
}
// Effect 1119: 消除双方能力提升状态,消除任意一方成功则使自身下{0}回合先制+{1}
type Effect1119 struct{ node.EffectNode }
func (e *Effect1119) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
cleared := clearPositiveProps(e.Ctx().Our, e.Ctx().Our)
if clearPositiveProps(e.Ctx().Opp, e.Ctx().Our) {
cleared = true
}
if !cleared {
return true
}
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1119, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1119Sub struct{ RoundEffectArg0Base }
func (e *Effect1119Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if current != nil && current.SkillEntity != nil && len(e.Args()) > 1 {
current.SkillEntity.XML.Priority += int(e.Args()[1].IntPart())
}
return true
}
// Effect 1120: 造成的伤害低于{0}则为自身附加{1}点护盾
type Effect1120 struct{ node.EffectNode }
func (e *Effect1120) Skill_Use() bool {
if len(e.Args()) < 2 || e.Ctx().Our.SumDamage.Cmp(e.Args()[0]) >= 0 {
return true
}
e.Ctx().Our.AddShield(e.Args()[1])
return true
}
// Effect 1121: 下{0}次受到的固定伤害和百分比伤害减少{1}%
type Effect1121 struct{ node.EffectNode }
func (e *Effect1121) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1121, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1121Sub struct {
node.EffectNode
remaining int
}
func (e *Effect1121Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.Duration(-1)
if len(a) > 0 {
e.remaining = a[0]
}
}
func (e *Effect1121Sub) DamageDivEx(zone *info.DamageZone) bool {
if zone == nil || e.remaining <= 0 || len(e.Args()) < 2 {
return true
}
if zone.Type != info.DamageType.Fixed && zone.Type != info.DamageType.Percent {
return true
}
zone.Damage = zone.Damage.Mul(hundred.Sub(e.Args()[1])).Div(hundred)
e.remaining--
if e.remaining <= 0 {
e.Alive(false)
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 1117, &Effect1117{})
input.InitEffect(input.EffectType.Skill, 1118, &Effect1118{})
input.InitEffect(input.EffectType.Sub, 1118, &Effect1118Sub{})
input.InitEffect(input.EffectType.Skill, 1119, &Effect1119{})
input.InitEffect(input.EffectType.Sub, 1119, &Effect1119Sub{})
input.InitEffect(input.EffectType.Skill, 1120, &Effect1120{})
input.InitEffect(input.EffectType.Skill, 1121, &Effect1121{})
input.InitEffect(input.EffectType.Sub, 1121, &Effect1121Sub{})
}