```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

feat(effect): 移除能力复制操作类型参数并优化属性复制逻辑

移除了 info.AbilityOpType.COPY 操作类型的依赖,简化了能力属性复制的实现方式。
现在直接将对手的正值属性复制到己方,无需指定操作类型参数。同时修正了数组遍历方式,
使用切片语法确保正确的遍历行为。

BREAKING CHANGE: 能力复制相关方法的参数签名发生变化,移除了操作类型参数。
```
This commit is contained in:
昔念
2026-03-08 23:36:16 +08:00
parent 9315fcfa17
commit b48578a7ea
7 changed files with 113 additions and 18 deletions

View File

@@ -2,7 +2,6 @@ package effect
import (
"blazing/logic/service/fight/action"
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
)
@@ -18,12 +17,13 @@ func (e *NewSel70) TurnStart(fattack *action.SelectSkillAction, sattack *action.
}
// 将对手的能力提升同时加给自己
for i := 0; i < 6; i++ {
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), 1, info.AbilityOpType.COPY)
for i, v := range e.Ctx().Opp.Prop[:] {
if v > 0 {
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v)
}
}
}
func init() {

View File

@@ -0,0 +1,32 @@
package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
type Effect143 struct {
node.EffectNode
}
// ----------------------
// 执行时逻辑
// ----------------------
func (e *Effect143) OnSkill() bool {
for i, v := range e.Ctx().Opp.Prop[:] {
if v > 0 {
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), -2*v)
}
}
return true
}
// ----------------------
// 注册所有效果
// ----------------------
func init() {
input.InitEffect(input.EffectType.Skill, 143, &Effect143{})
}

View File

@@ -0,0 +1,32 @@
package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
type Effect63 struct {
node.EffectNode
}
// ----------------------
// 执行时逻辑
// ----------------------
func (e *Effect63) OnSkill() bool {
for i, v := range e.Ctx().Our.Prop[:] {
if v < 0 {
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), v)
}
}
return true
}
// ----------------------
// 注册所有效果
// ----------------------
func init() {
input.InitEffect(input.EffectType.Skill, 63, &Effect63{})
}

View File

@@ -0,0 +1,32 @@
package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
type Effect85 struct {
node.EffectNode
}
// ----------------------
// 执行时逻辑
// ----------------------
func (e *Effect85) OnSkill() bool {
for i, v := range e.Ctx().Opp.Prop[:] {
if v > 0 {
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v)
}
}
return true
}
// ----------------------
// 注册所有效果
// ----------------------
func init() {
input.InitEffect(input.EffectType.Skill, 85, &Effect85{})
}

View File

@@ -180,9 +180,11 @@ func (e *EffectDefeatTrigger) triggerNextEnemyStatusOnDefeat(at model.AttackValu
// triggerTransferBoostsOnDefeat击败对手后复制其所有能力提升效果到自身对应Effect421
func (e *EffectDefeatTrigger) triggerTransferBoostsOnDefeat(at model.AttackValue) {
// 复制被击败对手的能力提升
for i, v := range at.Prop {
for i, v := range at.Prop[:] {
if v > 0 {
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v, info.AbilityOpType.COPY)
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v)
}
}
}

View File

@@ -2,7 +2,6 @@ package effect
import (
"blazing/logic/service/fight/action"
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
@@ -34,9 +33,9 @@ func (e *Effect91) SetArgs(t *input.Input, a ...int) {
}
func (e *Effect91) TurnStart(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) {
for i, v := range e.Ctx().Opp.Prop {
for i, v := range e.Ctx().Opp.Prop[:] {
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v, info.AbilityOpType.COPY)
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v)
}

View File

@@ -1,7 +1,6 @@
package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
@@ -35,7 +34,7 @@ func (e *Effect3) OnSkill() bool {
// ----------------------
// 工厂函数
// ----------------------
func newEffect3(reverse bool, level int) *Effect3 {
func newEffect3(reverse bool, level int8) *Effect3 {
return &Effect3{
Reverse: reverse,
Level: level,
@@ -50,16 +49,15 @@ func init() {
id int
reverse bool
level int8
opType info.EnumAbilityOpType
}{
{3, false, -1, info.AbilityOpType.RESET}, // 解除自身能力下降状态
{33, true, 1, info.AbilityOpType.RESET}, // 消除对手能力提升状态
{63, false, 0, info.AbilityOpType.BounceWeaken}, // 将能力下降反馈给对手
{85, false, -1, info.AbilityOpType.StealStrengthen}, // 将对手提升效果转移到自己
{143, true, 1, info.AbilityOpType.Reverse}, // 反转对手能力提升为下降
{3, false, 0}, // 解除自身能力下降状态
{33, true, 0}, // 消除对手能力提升状态
// {63, false, 0, info.AbilityOpType.BounceWeaken}, // 将能力下降反馈给对手
// {85, false, -1, info.AbilityOpType.StealStrengthen}, // 将对手提升效果转移到自己
// {143, true, 1, info.AbilityOpType.Reverse}, // 反转对手能力提升为下降
}
for _, e := range effects {
input.InitEffect(input.EffectType.Skill, e.id, newEffect3(e.reverse, e.level, e.opType))
input.InitEffect(input.EffectType.Skill, e.id, newEffect3(e.reverse, e.level))
}
}