refactor: 重构效果 150、196、437 实现
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-03-08 16:22:54 +08:00
committed by cnb
parent f6570c7e40
commit 069d961585
5 changed files with 94 additions and 87 deletions

View File

@@ -0,0 +1,28 @@
package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 150 - n回合内对手每回合防御和特防等级m
type Effect150 struct {
node.EffectNode
}
func (e *Effect150) Action_end() bool {
e.Ctx().Opp.SetProp(e.Ctx().Opp, 1, int8(e.SideEffectArgs[1]), info.AbilityOpType.SUB)
e.Ctx().Opp.SetProp(e.Ctx().Opp, 3, int8(e.SideEffectArgs[1]), info.AbilityOpType.SUB)
return true
}
func (e *Effect150) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(a[0]) // 持续m回合
}
func init() {
input.InitEffect(input.EffectType.Skill, 150, &Effect150{})
}

View File

@@ -0,0 +1,36 @@
package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 196 - n%令对方XX等级-m若先出手则j%使对方XX等级-k
type Effect196 struct {
node.EffectNode
}
func (e *Effect196) OnSkill() bool {
if e.Input.FightC.IsFirst(e.Input.Player) { // 先出手
chance := e.Args()[4].IntPart() // j%
effectValue := e.Args()[5].IntPart() // 等级-k
success, _, _ := e.Input.Player.Roll(int(chance), 100)
if success {
e.Ctx().Opp.SetProp(e.Ctx().Opp, int8(e.Args()[3].IntPart()), int8(effectValue), info.AbilityOpType.SUB)
}
} else { // 后出手
chance := e.Args()[1].IntPart() // j%
effectValue := e.Args()[2].IntPart() // 等级-k
success, _, _ := e.Input.Player.Roll(int(chance), 100)
if success {
e.Ctx().Opp.SetProp(e.Ctx().Opp, int8(e.Args()[0].IntPart()), int8(effectValue), info.AbilityOpType.SUB)
}
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 196, &Effect196{})
}

View File

@@ -0,0 +1,30 @@
package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 437 - 若对手处于能力强化状态则对手XX等级m
type Effect437 struct {
node.EffectNode
}
func (e *Effect437) OnSkill() bool {
for _, v := range e.Ctx().Opp.Prop[:] {
if v > 0 {
e.Ctx().Opp.SetProp(e.Ctx().Opp, int8(e.SideEffectArgs[0]), int8(e.SideEffectArgs[1]), info.AbilityOpType.SUB)
return true
}
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 437, &Effect437{})
}

View File

@@ -36,10 +36,6 @@ func (e *Effect497) OnSkill() bool {
return true
}
func (e *Effect497) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
}
func init() {
t := &Effect497{}
t.Duration(-1) //次数类无限回合

View File

@@ -773,27 +773,6 @@ func (e *Effect156) SetArgs(t *input.Input, a ...int) {
e.EffectNode.Duration(a[0]) // 持续n回合
}
// 437 - 若对手处于能力强化状态则对手XX等级m
type Effect437 struct {
node.EffectNode
}
func (e *Effect437) OnSkill() bool {
if e.Ctx().Opp.CurrentPet.HasPositiveBuff() { // 对手处于能力强化状态
effectType := int(e.Args()[0].IntPart()) // XX类型
effectValue := int(e.Args()[1].IntPart()) // 等级m
// 应用负面效果来抵消强化
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, effectType)
if statusEffect != nil {
statusEffect.SetArgs(e.Ctx().Our, -effectValue) // 负值表示降低
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
}
}
return true
}
// 486 - 下n回合若自身选择使用技能则无视对手能力提升状态
type Effect486 struct {
node.EffectNode
@@ -845,43 +824,6 @@ func (e *Effect429) SetArgs(t *input.Input, a ...int) {
e.incrementPerUse = a[1] // 每次增加n点
}
// 196 - n%令对方XX等级-m若先出手则j%使对方XX等级-k
type Effect196 struct {
node.EffectNode
}
func (e *Effect196) OnSkill() bool {
if e.Ctx().Our.Speed > e.Ctx().Opp.Speed { // 先出手
chance := e.Args()[2].IntPart() // j%
effectValue := e.Args()[3].IntPart() // 等级-k
success, _, _ := e.Input.Player.Roll(int(chance), 100)
if success {
effectType := int(e.Args()[4].IntPart()) // XX类型
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, effectType)
if statusEffect != nil {
statusEffect.SetArgs(e.Ctx().Our, -effectValue) // 负值表示降低
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
}
}
} else { // 后出手
chance := e.Args()[0].IntPart() // n%
effectValue := e.Args()[1].IntPart() // 等级-m
success, _, _ := e.Input.Player.Roll(int(chance), 100)
if success {
effectType := int(e.Args()[4].IntPart()) // XX类型
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, effectType)
if statusEffect != nil {
statusEffect.SetArgs(e.Ctx().Our, -effectValue) // 负值表示降低
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
}
}
}
return true
}
// 471 - 先出手时n回合内免疫异常状态
type Effect471 struct {
node.EffectNode
@@ -899,31 +841,6 @@ func (e *Effect471) OnSkill() bool {
return true
}
// 150 - n回合内对手每回合防御和特防等级m
type Effect150 struct {
node.EffectNode
}
func (e *Effect150) OnSkill() bool {
// 降低对手防御
defDownEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.DefDown))
if defDownEffect != nil {
defDownEffect.SetArgs(e.Ctx().Our, int(e.Args()[1].IntPart())) // m
defDownEffect.Duration(int(e.Args()[0].IntPart())) // n回合
e.Ctx().Opp.AddEffect(e.Ctx().Our, defDownEffect)
}
// 降低对手特防
spDefDownEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.SpDefDown))
if spDefDownEffect != nil {
spDefDownEffect.SetArgs(e.Ctx().Our, int(e.Args()[1].IntPart())) // m
spDefDownEffect.Duration(int(e.Args()[0].IntPart())) // n回合
e.Ctx().Opp.AddEffect(e.Ctx().Our, spDefDownEffect)
}
return true
}
// 197 - n回合内若被对方击败则对手所有能力加强状态消失
type Effect197 struct {
node.EffectNode