Files
bl/logic/service/fight/effect/selfkill.go
昔念 b9739f7b4e
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
```
refactor(fight/effect): 重构技能效果实现

移除独立的Effect112实现,将其整合到selfkill模块中。
通过继承SelfKill结构体来实现技能112的效果,提高代码复用性。
同时修复了原Effect112中的方法命名规范问题,将OnSkill改为Skill_Use。
删除了无用的Effect59 SwitchIn方法。
```
2026-03-08 22:53:14 +08:00

165 lines
3.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"
)
type SelfKill struct {
node.EffectNode
can bool
}
func (e *SelfKill) SetArgs(t *input.Input, a ...int) {
//e.CanStack(-1)//后续的不会顶掉这个效果
e.EffectNode.SetArgs(t, a...)
e.Duration(-1) //次数类,无限回合
}
func (e *SelfKill) OnSkill() bool {
if e.can {
return true
}
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
})
e.can = true
e.Ctx().Our.CurrentPet.NotAlive = true
return true
}
// 自杀,所以效果不消除
func (e *SelfKill) SwitchOut(in *input.Input) bool {
return true
}
/**
* 消耗自身全部体力(体力降到0), 使下一只出战精灵的 battle_lv1 和 battle_lv2 能力提升1个等级
*/
type Effect59 struct {
SelfKill
}
func init() {
input.InitEffect(input.EffectType.Skill, 59, &Effect59{})
}
func (e *Effect59) TurnStart(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) {
if !e.can {
return
}
e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.Args()[0].IntPart()), 1, info.AbilityOpType.ADD)
e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.Args()[1].IntPart()), 1, info.AbilityOpType.ADD)
e.Alive(false)
return
}
func init() {
input.InitEffect(input.EffectType.Skill, 71, &Effect71{
count: 2,
})
}
/**
* 自己牺牲(体力降到0), 使下一只出战精灵在前两回合内必定致命一击
*/
type Effect71 struct {
SelfKill
count int
}
func (e *Effect71) ActionStart(a, b *action.SelectSkillAction) bool {
if !e.can {
return true
}
//fmt.Println(e.Ctx().SkillEntity)
if e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
if e.count <= 0 {
e.Alive(false)
}
e.count--
e.Ctx().SkillEntity.CritRate = 16
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 144, &Effect144{})
}
// 144 - 消耗自己所有体力使下一个出战的精灵n回合免疫异常状态
type Effect144 struct {
SelfKill
count int
}
func (e *Effect144) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
if !e.can {
return true
}
if int(e.Input.FightC.GetOverInfo().Round) >= e.count+e.SideEffectArgs[0] {
e.Alive(false)
}
if e.count == 0 { //记录开始回合
e.count = int(e.Input.FightC.GetOverInfo().Round)
}
if in != e.Ctx().Opp {
return true
}
if input.IS_Stat(effEffect) {
return false
}
return true
}
/**
* 牺牲全部体力造成对手250~300点伤害造成致命伤害时对手剩下1点体力
*/
type Effect112 struct {
SelfKill
}
func init() {
input.InitEffect(input.EffectType.Skill, 112, &Effect112{})
}
// 命中之后
func (e *Effect112) Skill_Use() bool {
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
})
n := int64(e.Input.FightC.GetRand().Int31n(int32(50+1))) + 250
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: alpacadecimal.Max(alpacadecimal.NewFromInt(n), e.Ctx().Opp.CurrentPet.GetHP().Sub(alpacadecimal.NewFromInt(1))),
})
e.Ctx().Our.CurrentPet.NotAlive = true
return true
}