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

164 lines
3.8 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"
"math"
"github.com/alpacahq/alpacadecimal"
)
// Effect 774: 若自身当前体力高于对手则附加对手最大体力1/{0}的百分比伤害
type Effect774 struct {
node.EffectNode
}
func (e *Effect774) OnSkill() bool {
if len(e.Args()) == 0 || e.Ctx().Our.CurPet[0].GetHP().Cmp(e.Ctx().Opp.CurPet[0].GetHP()) <= 0 {
return true
}
if e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
return true
}
damage := e.Ctx().Opp.CurPet[0].GetMaxHP().Div(e.Args()[0])
if damage.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Percent,
Damage: damage,
})
return true
}
// Effect 775: {0}回合内若受到的伤害大于{1},则恢复自身所有体力
type Effect775 struct {
node.EffectNode
}
func (e *Effect775) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 775, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect775Sub struct {
RoundEffectArg0Base
pendingHeal bool
}
func (e *Effect775Sub) DamageLockEx(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 2 {
return true
}
if zone.Damage.Cmp(e.Args()[1]) <= 0 {
return true
}
e.pendingHeal = true
return true
}
func (e *Effect775Sub) Action_end_ex() bool {
if !e.pendingHeal {
return true
}
e.pendingHeal = false
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.CurPet[0].GetMaxHP())
return true
}
// Effect 777: 消除对手能力上升状态,消除成功下{0}回合必定先出手
type Effect777 struct {
node.EffectNode
}
func (e *Effect777) Skill_Use() bool {
if len(e.Args()) == 0 || !clearPositiveProps(e.Ctx().Opp, e.Ctx().Our) {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 777, int(e.Args()[0].IntPart()))
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect777Sub struct {
RoundEffectArg0Base
}
func (e *Effect777Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if current == nil || current.SkillEntity == nil {
return true
}
current.SkillEntity.XML.Priority = math.MaxInt
return true
}
// Effect 778: 反转对手的能力提升状态,反转成功则恢复自身所有体力
type Effect778 struct {
node.EffectNode
}
func (e *Effect778) Skill_Use() bool {
reversed := false
for i, v := range e.Ctx().Opp.Prop[:] {
if v <= 0 {
continue
}
if e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), -2*v) {
reversed = true
}
}
if !reversed {
return true
}
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.CurPet[0].GetMaxHP())
return true
}
// Effect 779: 若对手处于能力提升状态则先制+2
type Effect779 struct {
node.EffectNode
}
func (e *Effect779) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
if !e.Ctx().Opp.HasPropADD() {
return true
}
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if current == nil || current.SkillEntity == nil {
return true
}
current.SkillEntity.XML.Priority += 2
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 774, &Effect774{})
input.InitEffect(input.EffectType.Skill, 775, &Effect775{})
input.InitEffect(input.EffectType.Sub, 775, &Effect775Sub{})
input.InitEffect(input.EffectType.Skill, 777, &Effect777{})
input.InitEffect(input.EffectType.Sub, 777, &Effect777Sub{})
input.InitEffect(input.EffectType.Skill, 778, &Effect778{})
input.InitEffect(input.EffectType.Skill, 779, &Effect779{})
}