Files
bl/logic/service/fight/effect/effect_4_5.go
昔念 99ef152434
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中未
2026-03-09 17:42:52 +08:00

74 lines
1.7 KiB
Go

package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// -----------------------------------------------------------
// 注册
// -----------------------------------------------------------
func init() {
initskill(4, newEffectStat(false))
initskill(5, newEffectStat(true))
}
// -----------------------------------------------------------
// 构造
// -----------------------------------------------------------
func newEffectStat(targetOpponent bool) input.Effect {
e := &EffectStat{
Etype: targetOpponent,
}
//e.CanStack(-1) // 无限叠加
return e
}
// -----------------------------------------------------------
// 主体结构
// -----------------------------------------------------------
type EffectStat struct {
node.EffectNode
Etype bool // false: 作用自身, true: 作用对方
}
// -----------------------------------------------------------
// 技能触发时调用
// -----------------------------------------------------------
func (e *EffectStat) Skill_Use() bool {
// 参数解构 (防止 SideEffectArgs 长度不足)
var (
statIndex int // 哪个属性
chance int // 触发概率
level int // 增减值
)
if len(e.SideEffectArgs) > 0 {
statIndex = e.SideEffectArgs[0]
}
if len(e.SideEffectArgs) > 1 {
chance = e.SideEffectArgs[1]
}
if len(e.SideEffectArgs) > 2 {
level = e.SideEffectArgs[2]
}
// 概率判定
ok, _, _ := e.Input.Player.Roll(chance, 100)
if !ok {
return true
}
// 执行属性变化
if e.Etype {
// 对方属性变化
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(statIndex), int8(level))
} else {
// 自身属性变化
e.Ctx().Our.SetProp(e.Ctx().Our, int8(statIndex), int8(level))
}
return true
}