```
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed

refactor(fight): 统一技能执行方法命名并修复战斗逻辑错误

- 将多个boss技能结构体中的OnSkill()方法重命名为Skill_Use()以保持一致性
- 修改fightc.go中的战斗回合逻辑,修复attacker和defender的执行顺序错误
- 将Effect126的TurnStart方法改为Skill_Use方法并返回bool值
- 为Effect499添加缺失的方法实现
- 移除effect_124_126.go中未
This commit is contained in:
昔念
2026-03-09 17:42:52 +08:00
parent 36f7aae476
commit 99ef152434
36 changed files with 147 additions and 98 deletions

View File

@@ -11,7 +11,7 @@ type NewSel116 struct {
NewSel0 NewSel0
} }
func (e *NewSel116) OnSkill() bool { func (e *NewSel116) Skill_Use() bool {
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime { if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
return true return true
} }

View File

@@ -12,7 +12,7 @@ type NewSel223 struct {
NewSel0 NewSel0
} }
func (e *NewSel223) OnSkill() bool { func (e *NewSel223) Skill_Use() bool {
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime { if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
return true return true
} }

View File

@@ -12,7 +12,7 @@ type NewSel323 struct {
NewSel0 NewSel0
} }
func (e *NewSel323) OnSkill() bool { func (e *NewSel323) Skill_Use() bool {
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime { if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
return true return true
} }

View File

@@ -11,7 +11,7 @@ type NewSel66 struct {
NewSel0 NewSel0
} }
func (e *NewSel66) OnSkill() bool { func (e *NewSel66) Skill_Use() bool {
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime { if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
return true return true
} }

View File

@@ -11,7 +11,7 @@ type NewSel67 struct {
NewSel0 NewSel0
} }
func (e *NewSel67) OnSkill() bool { func (e *NewSel67) Skill_Use() bool {
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime { if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
return true return true
} }

View File

@@ -0,0 +1,22 @@
package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 486 - 下n回合若自身选择使用技能则无视对手能力提升状态
type Effect486 struct {
node.EffectNode
}
func (e *Effect486) OnSkill() bool {
// 设置标志接下来n回合内无视对手能力提升
e.Ctx().Our.IgnoreOpponentPositiveBuffsForNDuration(int(e.Args()[0].IntPart()))
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 486, &Effect486{})
}

View File

@@ -0,0 +1,36 @@
package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
"github.com/alpacahq/alpacadecimal"
)
// 491 - 3回合内对手造成的伤害降低m%
type Effect491 struct {
node.EffectNode
}
func (e *Effect491) DamageDivEx(t *info.DamageZone) bool {
if t.Type != info.DamageType.Red {
return true
}
damageReduction := alpacadecimal.NewFromInt(int64(e.Args()[1].IntPart())).Mul(t.Damage)
if t.Damage.Cmp(damageReduction) > 0 {
t.Damage = t.Damage.Sub(damageReduction)
} else {
t.Damage = alpacadecimal.Zero
}
return true
}
func (e *Effect491) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(a[0]) // 持续n回合
}
func init() {
input.InitEffect(input.EffectType.Skill, 491, &Effect491{})
}

View File

@@ -0,0 +1,33 @@
package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 506 - 下回合受到致命伤害时残留m点体力
type Effect506 struct {
node.EffectNode
triggered bool
}
func (e *Effect506) Skill_Use() bool {
e.triggered = true
return true
}
func (e *Effect506) Action_end() bool {
if !e.triggered {
return true
}
minHealth := uint32(e.Args()[0].IntPart()) // m点体力
if e.Ctx().Our.CurrentPet.GetHP().IntPart() == 0 {
e.Ctx().Our.CurrentPet.Info.Hp = minHealth
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 506, &Effect506{})
}

View File

@@ -102,23 +102,6 @@ func (e *Effect407) OnSkill() bool {
return true return true
} }
// 491 - 3回合内对手造成的伤害降低m%
type Effect491 struct {
node.EffectNode
}
func (e *Effect491) OnSkill() bool {
// 创建一个降低对手伤害的效果
damageReduceEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.ReduceDamageTaken))
if damageReduceEffect != nil {
damageReduceEffect.SetArgs(e.Ctx().Our, int(e.Args()[0].IntPart()))
damageReduceEffect.Duration(3) // 持续3回合
e.Ctx().Opp.AddEffect(e.Ctx().Our, damageReduceEffect)
}
return true
}
// 462 - n回合内受攻击时反弹m点固定伤害 // 462 - n回合内受攻击时反弹m点固定伤害
type Effect462 struct { type Effect462 struct {
node.EffectNode node.EffectNode
@@ -527,18 +510,6 @@ func (e *Effect156) SetArgs(t *input.Input, a ...int) {
e.EffectNode.Duration(a[0]) // 持续n回合 e.EffectNode.Duration(a[0]) // 持续n回合
} }
// 486 - 下n回合若自身选择使用技能则无视对手能力提升状态
type Effect486 struct {
node.EffectNode
}
func (e *Effect486) OnSkill() bool {
// 设置标志接下来n回合内无视对手能力提升
e.Ctx().Our.IgnoreOpponentPositiveBuffsForNDuration(int(e.Args()[0].IntPart()))
return true
}
// 197 - n回合内若被对方击败则对手所有能力加强状态消失 // 197 - n回合内若被对方击败则对手所有能力加强状态消失
type Effect197 struct { type Effect197 struct {
node.EffectNode node.EffectNode
@@ -697,22 +668,3 @@ func (e *Effect461) OnSkill() bool {
return true return true
} }
// 506 - 下回合受到致命伤害时残留m点体力
type Effect506 struct {
node.EffectNode
}
func (e *Effect506) OnSkill() bool {
minHealth := int(e.Args()[0].IntPart()) // m点体力
// 设置保护效果下回合受到致命伤害时保留m点体力
protectEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.ProtectFromKO))
if protectEffect != nil {
protectEffect.SetArgs(e.Ctx().Our, minHealth)
protectEffect.Duration(1) // 仅下回合有效
e.Ctx().Our.AddEffect(e.Ctx().Our, protectEffect)
}
return true
}

View File

@@ -21,7 +21,7 @@ func init() {
} }
func (e *Effect101) OnSkill() bool { func (e *Effect101) Skill_Use() bool {
e.Input.Heal( e.Input.Heal(
e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.SumDamage.Mul(e.Args()[0].Div(alpacadecimal.NewFromInt(100))), e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.SumDamage.Mul(e.Args()[0].Div(alpacadecimal.NewFromInt(100))),

View File

@@ -50,7 +50,7 @@ func (e *Effect104) SetArgs(t *input.Input, a ...int) {
// ----------------------------------------------------------- // -----------------------------------------------------------
// 技能触发时调用 // 技能触发时调用
// ----------------------------------------------------------- // -----------------------------------------------------------
func (e *Effect104) OnSkill() bool { func (e *Effect104) Skill_Use() bool {
if !e.can { if !e.can {
e.can = true e.can = true

View File

@@ -20,7 +20,7 @@ func init() {
} }
// 命中之后 // 命中之后
func (e *Effect105) OnSkill() bool { func (e *Effect105) Skill_Use() bool {
e.Input.Heal( e.Input.Heal(
e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.SumDamage.Div(e.Args()[0]), e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.SumDamage.Div(e.Args()[0]),

View File

@@ -23,7 +23,7 @@ type Effect115 struct {
node.EffectNode node.EffectNode
} }
func (e *Effect115) OnSkill() bool { func (e *Effect115) Skill_Use() bool {
// 概率判定 // 概率判定
ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100) ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100)

View File

@@ -17,7 +17,7 @@ type Effect119 struct {
can bool can bool
} }
func (e *Effect119) OnSkill() bool { func (e *Effect119) Skill_Use() bool {
e.can = true e.can = true
return true return true
@@ -64,7 +64,7 @@ type Effect120 struct {
node.EffectNode node.EffectNode
} }
func (e *Effect120) OnSkill() bool { func (e *Effect120) Skill_Use() bool {
// 50%概率 // 50%概率
ok, _, _ := e.Input.Player.Roll(50, 100) ok, _, _ := e.Input.Player.Roll(50, 100)
@@ -99,7 +99,7 @@ type Effect121 struct {
node.EffectNode node.EffectNode
} }
func (e *Effect121) OnSkill() bool { func (e *Effect121) Skill_Use() bool {
// 检查属性是否相同 // 检查属性是否相同
if e.Ctx().Our.CurrentPet.PetInfo.Type == e.Ctx().Opp.CurrentPet.PetInfo.Type { if e.Ctx().Our.CurrentPet.PetInfo.Type == e.Ctx().Opp.CurrentPet.PetInfo.Type {

View File

@@ -1,7 +1,6 @@
package effect package effect
import ( import (
"blazing/logic/service/fight/action"
"blazing/logic/service/fight/input" "blazing/logic/service/fight/input"
"blazing/logic/service/fight/node" "blazing/logic/service/fight/node"
) )
@@ -43,7 +42,7 @@ func (e *Effect126) SetArgs(t *input.Input, a ...int) {
e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0]) e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0])
} }
func (e *Effect126) TurnStart(_, _ *action.SelectSkillAction) { func (e *Effect126) Skill_Use() bool {
changeAmount := int(e.Args()[1].IntPart()) changeAmount := int(e.Args()[1].IntPart())
// 攻击等级+1 (属性索引0) // 攻击等级+1 (属性索引0)
@@ -51,6 +50,7 @@ func (e *Effect126) TurnStart(_, _ *action.SelectSkillAction) {
// 速度等级+1 (属性索引4) // 速度等级+1 (属性索引4)
e.Ctx().Our.SetProp(e.Ctx().Our, 4, int8(changeAmount)) e.Ctx().Our.SetProp(e.Ctx().Our, 4, int8(changeAmount))
return true
} }
// ----------------------------------------------------------- // -----------------------------------------------------------

View File

@@ -15,7 +15,7 @@ type Effect130 struct {
// ----------------------------------------------------------- // -----------------------------------------------------------
// 核心共性逻辑:命中且满足条件时,附加固定伤害 // 核心共性逻辑:命中且满足条件时,附加固定伤害
// ----------------------------------------------------------- // -----------------------------------------------------------
func (e *Effect130) OnSkill() bool { func (e *Effect130) Skill_Use() bool {
// 1. 命中判定失败,不触发 // 1. 命中判定失败,不触发
if e.Ctx().Opp.CurrentPet.Info.Gender != int(e.Args()[0].IntPart()) { if e.Ctx().Opp.CurrentPet.Info.Gender != int(e.Args()[0].IntPart()) {

View File

@@ -13,7 +13,7 @@ type Effect140 struct {
node.EffectNode node.EffectNode
} }
func (e *Effect140) OnSkill() bool { func (e *Effect140) Skill_Use() bool {
maxHp := e.Ctx().Opp.CurrentPet.GetMaxHP() maxHp := e.Ctx().Opp.CurrentPet.GetMaxHP()
// 随机降低1/n 到 1/m 的体力 // 随机降低1/n 到 1/m 的体力

View File

@@ -19,7 +19,7 @@ func init() {
} }
// 命中之后 // 命中之后
func (e *Effect145) OnSkill() bool { func (e *Effect145) Skill_Use() bool {
if e.Ctx().Opp.StatEffect_Exist(info.PetStatus.Poisoned) { if e.Ctx().Opp.StatEffect_Exist(info.PetStatus.Poisoned) {
heal := e.Ctx().Our.CurrentPet.GetMaxHP().Div(e.Args()[0]) heal := e.Ctx().Our.CurrentPet.GetMaxHP().Div(e.Args()[0])

View File

@@ -13,7 +13,7 @@ type Effect147 struct {
can bool can bool
} }
func (e *Effect147) OnSkill() bool { func (e *Effect147) Skill_Use() bool {
if e.IsFirst() { if e.IsFirst() {
return true return true
@@ -42,7 +42,7 @@ type Effect148 struct {
can bool can bool
} }
func (e *Effect148) OnSkill() bool { func (e *Effect148) Skill_Use() bool {
if e.IsFirst() { if e.IsFirst() {
return true return true
@@ -67,7 +67,7 @@ type Effect159 struct {
node.EffectNode node.EffectNode
} }
func (e *Effect159) OnSkill() bool { func (e *Effect159) Skill_Use() bool {
// 检查自身体力是否小于最大值的1/{0} // 检查自身体力是否小于最大值的1/{0}
maxHP := int64(e.Ctx().Our.CurrentPet.Info.MaxHp) maxHP := int64(e.Ctx().Our.CurrentPet.Info.MaxHp)

View File

@@ -18,7 +18,7 @@ func init() {
} }
// 命中之后 // 命中之后
func (e *Effect151) OnSkill() bool { func (e *Effect151) Skill_Use() bool {
if e.Ctx().Opp.StatEffect_Exist(info.PetStatus.Burned) { if e.Ctx().Opp.StatEffect_Exist(info.PetStatus.Burned) {
chance := e.EffectNode.SideEffectArgs[0] chance := e.EffectNode.SideEffectArgs[0]

View File

@@ -13,7 +13,7 @@ type Effect161 struct {
node.EffectNode node.EffectNode
} }
func (e *Effect161) OnSkill() bool { func (e *Effect161) Skill_Use() bool {
chance := e.Args()[0].IntPart() chance := e.Args()[0].IntPart()
success, _, _ := e.Input.Player.Roll(int(chance), 100) success, _, _ := e.Input.Player.Roll(int(chance), 100)

View File

@@ -11,7 +11,7 @@ type Effect172 struct {
node.EffectNode node.EffectNode
} }
func (e *Effect172) OnSkill() bool { func (e *Effect172) Skill_Use() bool {
if e.IsFirst() { if e.IsFirst() {
return true return true
} }

View File

@@ -20,7 +20,7 @@ func init() {
} }
// 命中之后 // 命中之后
func (e *Effect180) OnSkill() bool { func (e *Effect180) Skill_Use() bool {
e.Ctx().Opp.CancelTurn(e.Ctx().Our) e.Ctx().Opp.CancelTurn(e.Ctx().Our)
return true return true

View File

@@ -20,7 +20,7 @@ type Effect182 struct {
node.EffectNode node.EffectNode
} }
func (e *Effect182) OnSkill() bool { func (e *Effect182) Skill_Use() bool {
if e.Ctx().Opp.StatEffect_Exist(info.EnumPetStatus(e.Args()[0].IntPart())) { if e.Ctx().Opp.StatEffect_Exist(info.EnumPetStatus(e.Args()[0].IntPart())) {
// 3. 概率判定Args()[1]为触发概率) // 3. 概率判定Args()[1]为触发概率)

View File

@@ -20,7 +20,7 @@ type Effect467 struct {
node.EffectNode node.EffectNode
} }
func (e *Effect467) OnSkill() bool { func (e *Effect467) Skill_Use() bool {
if e.Ctx().Opp.StatEffect_Exist(info.EnumPetStatus(e.Args()[0].IntPart())) { if e.Ctx().Opp.StatEffect_Exist(info.EnumPetStatus(e.Args()[0].IntPart())) {
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{ e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{

View File

@@ -22,7 +22,7 @@ func init() {
} }
// 命中之后 // 命中之后
func (e *Effect478) OnSkill() bool { func (e *Effect478) Skill_Use() bool {
e.can = true e.can = true
return true return true

View File

@@ -27,14 +27,20 @@ func (e *Effect499) ActionStartEx(fattack, sattack *action.SelectSkillAction) bo
e.Alive(false) e.Alive(false)
return true return true
} }
func (e *Effect499) OnSkill() bool { func (e *Effect499) Skill_Use() bool {
if e.IsFirst() { if e.IsFirst() {
return true return true
} }
e.can = true e.can = true
e.Duration(1)
return true return true
} }
func (e *Effect104) Effect499(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(1)
}
func init() { func init() {
input.InitEffect(input.EffectType.Skill, 499, &Effect499{}) input.InitEffect(input.EffectType.Skill, 499, &Effect499{})

View File

@@ -36,7 +36,7 @@ type EffectStat struct {
// ----------------------------------------------------------- // -----------------------------------------------------------
// 技能触发时调用 // 技能触发时调用
// ----------------------------------------------------------- // -----------------------------------------------------------
func (e *EffectStat) OnSkill() bool { func (e *EffectStat) Skill_Use() bool {
// 参数解构 (防止 SideEffectArgs 长度不足) // 参数解构 (防止 SideEffectArgs 长度不足)
var ( var (

View File

@@ -11,7 +11,7 @@ type Effect520 struct {
node.EffectNode node.EffectNode
} }
func (e *Effect520) OnSkill() bool { func (e *Effect520) Skill_Use() bool {
chance := e.Args()[0].IntPart() chance := e.Args()[0].IntPart()
success, _, _ := e.Input.Player.Roll(int(chance), 100) success, _, _ := e.Input.Player.Roll(int(chance), 100)
if success { if success {

View File

@@ -23,7 +23,7 @@ func init() {
// 命中之后 // 命中之后
// 特攻+2速度+1命中+1 // 特攻+2速度+1命中+1
func (e *Effect79) OnSkill() bool { func (e *Effect79) Skill_Use() bool {
e.Ctx().Our.SetProp(e.Ctx().Our, 2, 2) e.Ctx().Our.SetProp(e.Ctx().Our, 2, 2)
e.Ctx().Our.SetProp(e.Ctx().Our, 4, 1) e.Ctx().Our.SetProp(e.Ctx().Our, 4, 1)

View File

@@ -21,7 +21,7 @@ func init() {
} }
func (e *Effect80) OnSkill() bool { func (e *Effect80) Skill_Use() bool {
att := e.Ctx().Our.CurrentPet.GetMaxHP().Div(alpacadecimal.NewFromInt(2)) att := e.Ctx().Our.CurrentPet.GetMaxHP().Div(alpacadecimal.NewFromInt(2))
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{ e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{

View File

@@ -19,7 +19,7 @@ type Effect81 struct {
can bool can bool
} }
func (e *Effect81) OnSkill() bool { func (e *Effect81) Skill_Use() bool {
e.can = true e.can = true

View File

@@ -22,7 +22,7 @@ type Effect83 struct {
can bool can bool
} }
func (e *Effect83) OnSkill() bool { func (e *Effect83) Skill_Use() bool {
e.can = true e.can = true

View File

@@ -18,7 +18,7 @@ type Effect87 struct {
node.EffectNode node.EffectNode
} }
func (e *Effect87) OnSkill() bool { func (e *Effect87) Skill_Use() bool {
e.Ctx().Our.HealPP(-1) e.Ctx().Our.HealPP(-1)
return true return true

View File

@@ -52,7 +52,7 @@ func registerStatusEffects() {
// ----------------------------------------------------------- // -----------------------------------------------------------
// 技能触发时调用 // 技能触发时调用
// ----------------------------------------------------------- // -----------------------------------------------------------
func (e *Effect10) OnSkill() bool { func (e *Effect10) Skill_Use() bool {
// n% 触发概率(默认 SideEffectArgs[0] // n% 触发概率(默认 SideEffectArgs[0]
chance := e.EffectNode.SideEffectArgs[0] chance := e.EffectNode.SideEffectArgs[0]

View File

@@ -259,6 +259,19 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
if defender.CurrentPet.Info.Hp <= 0 && attacker.CurrentPet.Info.Hp <= 0 { //先手方死亡,触发反同归于尽 if defender.CurrentPet.Info.Hp <= 0 && attacker.CurrentPet.Info.Hp <= 0 { //先手方死亡,触发反同归于尽
attacker.CurrentPet.Info.Hp = 1 attacker.CurrentPet.Info.Hp = 1
} }
if defender.CurrentPet.Info.Hp <= 0 {
f.TURNOVER(defender)
break
} else {
//技能使用后
defender.Exec(func(effect input.Effect) bool { //技能使用后的我方效果
effect.Ctx().SkillEntity = currentSkill
effect.Skill_Use_ex()
return true
})
}
if attacker.CurrentPet.Info.Hp <= 0 { if attacker.CurrentPet.Info.Hp <= 0 {
f.TURNOVER(attacker) f.TURNOVER(attacker)
@@ -273,19 +286,6 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
} }
if defender.CurrentPet.Info.Hp <= 0 {
f.TURNOVER(defender)
break
} else {
//技能使用后
defender.Exec(func(effect input.Effect) bool { //技能使用后的我方效果
effect.Ctx().SkillEntity = currentSkill
effect.Skill_Use_ex()
return true
})
}
//技能使用后 //技能使用后
attacker.Exec(func(effect input.Effect) bool { //技能使用后的我方效果 attacker.Exec(func(effect input.Effect) bool { //技能使用后的我方效果
effect.Ctx().SkillEntity = currentSkill effect.Ctx().SkillEntity = currentSkill