Files
bl/logic/service/fight/effect/709_713.go
xinian c40430aaa4
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
feat: 实现战斗技能效果
2026-03-29 16:38:34 +08:00

199 lines
4.2 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 709: 击败对手时若自身处于能力提升状态,则将所处的能力提升状态翻倍
type Effect709 struct {
FixedDuration1Base
}
func (e *Effect709) SwitchOut(in *input.Input) bool {
if in == e.Ctx().Our {
e.Alive(false)
return true
}
if in != e.Ctx().Opp || e.Ctx().Opp.CurrentPet.Info.Hp > 0 {
return true
}
for i, v := range e.Ctx().Our.Prop[:] {
if v > 0 {
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v)
}
}
e.Alive(false)
return true
}
// Effect 710: 解除自身能力下降状态,若解除成功则{0}回合内免疫能力下降状态
type Effect710 struct {
node.EffectNode
}
func (e *Effect710) OnSkill() bool {
cleared := false
for i, v := range e.Ctx().Our.Prop[:] {
if v < 0 && e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), 0) {
cleared = true
}
}
if !cleared {
return true
}
addSubEffect(e.Ctx().Our, e.Ctx().Our, &e.EffectNode, &Effect47{}, -1)
return true
}
// Effect 711: 下{0}回合若自身能力提升状态被消除则必定致命一击
type Effect711 struct {
node.EffectNode
}
func (e *Effect711) SetArgs(t *input.Input, a ...int) {
setArgsWithFixedDuration(&e.EffectNode, t, -1, a...)
}
func (e *Effect711) PropBefer(source *input.Input, prop int8, level int8) bool {
if source != e.Ctx().Opp {
return true
}
if prop < 0 || int(prop) >= len(e.Ctx().Our.Prop) {
return true
}
if level != 0 || e.Ctx().Our.Prop[prop] <= 0 {
return true
}
addSubEffect(e.Ctx().Our, e.Ctx().Our, &e.EffectNode, &Effect711Sub{}, -1)
e.Alive(false)
return true
}
type Effect711Sub struct {
RoundEffectArg0Base
}
func (e *Effect711Sub) ActionStart(a, b *action.SelectSkillAction) bool {
if e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.XML.CritRate = 16
return true
}
// Effect 712: {0}回合内将对手的{1}能力降为0点
type Effect712 struct {
node.EffectNode
}
func (e *Effect712) OnSkill() bool {
sub := &Effect712Sub{}
addSubEffect(e.Ctx().Our, e.Ctx().Opp, &e.EffectNode, sub, -1)
sub.applyToTarget(e.Ctx().Opp.CurrentPet)
return true
}
type Effect712Sub struct {
node.EffectNode
target *info.BattlePetEntity
oldProp [5]uint32
oldHP uint32
applied bool
hpZeroed bool
}
func (e *Effect712Sub) SetArgs(t *input.Input, a ...int) {
setArgsWithDuration0(&e.EffectNode, t, a...)
}
func (e *Effect712Sub) applyToTarget(target *info.BattlePetEntity) {
if e.applied || target == nil {
return
}
e.target = target
e.oldProp = target.Info.Prop
e.oldHP = target.Info.Hp
for i := 0; i < len(target.Info.Prop) && i+1 < len(e.SideEffectArgs); i++ {
if e.SideEffectArgs[i+1] != 0 {
target.Info.Prop[i] = 0
}
}
if len(e.SideEffectArgs) > 6 && e.SideEffectArgs[6] != 0 && target.Info.Hp > 0 {
target.Info.Hp = 0
e.hpZeroed = true
}
e.applied = true
}
func (e *Effect712Sub) restore() {
if !e.applied || e.target == nil {
return
}
e.target.Info.Prop = e.oldProp
if e.hpZeroed && e.target.Info.Hp > 0 {
e.target.Info.Hp = e.oldHP
}
e.applied = false
}
func (e *Effect712Sub) Alive(t ...bool) bool {
if len(t) > 0 && !t[0] {
e.restore()
}
return e.EffectNode.Alive(t...)
}
func (e *Effect712Sub) TurnEnd() {
if e.Duration() <= 1 {
e.Alive(false)
return
}
e.EffectNode.TurnEnd()
}
// Effect 713: 附加自身能力提升等级总和X{0}的固定伤害
type Effect713 struct {
node.EffectNode
}
func (e *Effect713) OnSkill() bool {
total := int64(0)
for _, v := range e.Ctx().Our.Prop[:] {
if v > 0 {
total += int64(v)
}
}
if total <= 0 {
return true
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: e.Args()[0].Mul(alpacadecimal.NewFromInt(total)),
})
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 709, &Effect709{})
input.InitEffect(input.EffectType.Skill, 710, &Effect710{})
input.InitEffect(input.EffectType.Skill, 711, &Effect711{})
input.InitEffect(input.EffectType.Skill, 712, &Effect712{})
input.InitEffect(input.EffectType.Skill, 713, &Effect713{})
}