Files
bl/logic/service/fight/effect/1173_1177.go
2026-03-31 10:40:22 +08:00

170 lines
4.4 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 1173: 未击败对手则回合结束后附加百分比伤害
type Effect1173 struct{ node.EffectNode }
func (e *Effect1173) Skill_Use() bool {
if len(e.Args()) == 0 || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil || e.Ctx().Opp.CurrentPet.Info.Hp <= 0 {
return true
}
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1173, int(e.Args()[0].IntPart()))
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1173Sub struct{ FixedDuration1Base }
func (e *Effect1173Sub) TurnEnd() {
defer e.Alive(false)
if len(e.Args()) == 0 || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil {
return
}
divisor := e.Args()[0]
if divisor.Cmp(alpacadecimal.Zero) <= 0 {
return
}
damage := e.Ctx().Opp.CurrentPet.GetMaxHP().Div(divisor)
if damage.Cmp(alpacadecimal.Zero) <= 0 {
return
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Percent, Damage: damage})
}
// Effect 1174: 自身处于能力提升状态则先制+2
type Effect1174 struct{ node.EffectNode }
func (e *Effect1174) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
if !e.Ctx().Our.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
}
// Effect 1175: 获得护盾,护盾消失时恢复生命
type Effect1175 struct{ node.EffectNode }
func (e *Effect1175) Skill_Use() bool {
if len(e.Args()) < 2 || e.Ctx().Our == nil || e.Ctx().Our.CurrentPet == nil {
return true
}
if e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Our.AddShield(e.Args()[0])
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1175, int(e.Args()[1].IntPart()))
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1175Sub struct{ node.EffectNode }
func (e *Effect1175Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.CanStack(false)
e.Duration(-1)
}
func (e *Effect1175Sub) ShieldChange(before, after alpacadecimal.Decimal) bool {
if len(e.Args()) == 0 || e.Ctx().Our == nil || e.Ctx().Our.CurrentPet == nil {
return true
}
if before.Cmp(alpacadecimal.Zero) <= 0 || after.Cmp(alpacadecimal.Zero) > 0 {
return true
}
if e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
return true
}
heal := e.Ctx().Our.CurrentPet.GetMaxHP().Div(e.Args()[0])
if heal.Cmp(alpacadecimal.Zero) > 0 {
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, heal)
}
e.Alive(false)
return true
}
// Effect 1176: 概率倍伤,未触发则附加固伤
type Effect1176 struct {
node.EffectNode
multiplied bool
}
func (e *Effect1176) SkillHit() bool {
e.multiplied = false
if len(e.Args()) < 3 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 {
return true
}
e.multiplied, _, _ = e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100)
return true
}
func (e *Effect1176) Damage_Mul(zone *info.DamageZone) bool {
if !e.multiplied || zone == nil || zone.Type != info.DamageType.Red {
return true
}
zone.Damage = zone.Damage.Mul(e.Args()[1])
return true
}
func (e *Effect1176) OnSkill() bool {
if e.multiplied || len(e.Args()) < 3 || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil {
return true
}
if e.Args()[2].Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: e.Args()[2]})
return true
}
// Effect 1177: 自身能力提升状态翻倍
type Effect1177 struct{ node.EffectNode }
func (e *Effect1177) Skill_Use() bool {
for i, v := range e.Ctx().Our.Prop[:] {
if v <= 0 {
continue
}
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v)
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 1173, &Effect1173{})
input.InitEffect(input.EffectType.Sub, 1173, &Effect1173Sub{})
input.InitEffect(input.EffectType.Skill, 1174, &Effect1174{})
input.InitEffect(input.EffectType.Skill, 1175, &Effect1175{})
input.InitEffect(input.EffectType.Sub, 1175, &Effect1175Sub{})
input.InitEffect(input.EffectType.Skill, 1176, &Effect1176{})
input.InitEffect(input.EffectType.Skill, 1177, &Effect1177{})
}