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

feat(fight): 实现技能PP消耗Hook机制并优化效果处理

- 在Effect475中添加子效果时通过Ctx().Our.AddEffect正确添加效果
- 删除已废弃的Effect407、Effect440和Effect412效果类型
- 在fightc.go中实现技能使用后的PP消耗Hook机制,支持效果修改PP消耗数量
- 添加HookPP接口方法用于处理技能使用的PP消耗逻辑
- 在SkillInfo中添加Use方法用于实际消耗PP值
```
This commit is contained in:
昔念
2026-03-09 23:44:09 +08:00
parent 0961dc43e3
commit 1fa1ae848d
9 changed files with 121 additions and 54 deletions

View File

@@ -0,0 +1,42 @@
package effect
import (
"blazing/logic/service/fight/action"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 407 - 下回合起每回合XX等级+n持续m回合
type Effect407 struct {
node.EffectNode
}
func (e *Effect407) Skill_Use() bool {
// 创建一个延迟生效的效果,在下一回合开始生效
effectType := int8(e.Args()[0].IntPart()) // XX类型
effectValue := int8(e.Args()[1].IntPart()) // 等级+n
duration := int(e.Args()[2].IntPart()) // 持续m回合
e.GenSub(&Effect407_sub{
effectType: effectType,
effectValue: effectValue,
}, duration)
return true
}
type Effect407_sub struct {
node.EffectNode
effectType int8
effectValue int8
}
func (e *Effect407_sub) ActionStart(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
e.Ctx().Our.SetProp(e.Ctx().Our, e.effectType, e.effectValue)
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 138, &Effect407{})
}

View File

@@ -0,0 +1,27 @@
package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 412 - 若自身体力小于1/n则每次攻击不消耗PP值
type Effect412 struct {
node.EffectNode
}
func (e *Effect412) HookPP(count *int) bool {
maxHp := e.Ctx().Our.CurrentPet.GetMaxHP()
currentHp := e.Ctx().Our.CurrentPet.GetHP()
threshold := maxHp.Div(e.Args()[0]) // 1/n
if currentHp.Cmp(threshold) < 0 {
*count = 0
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 412, &Effect412{})
}

View File

@@ -0,0 +1,35 @@
package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 440 - n回合内对手使用技能消耗的PP值变为m倍
type Effect440 struct {
node.EffectNode
}
func (e *Effect440) Skill_Use() bool {
// 创建一个延迟生效的效果,在下一回合开始生效
e.Ctx().Opp.AddEffect(e.Ctx().Our, e.GenSub(&Effect440_sub{
m: int(e.Args()[1].IntPart()),
}, int(e.Args()[0].IntPart())))
return true
}
type Effect440_sub struct {
node.EffectNode
m int
}
func (e *Effect440_sub) HookPP(count *int) bool {
*count *= e.m // 把t指向的值取反直接作用于外部变量
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 138, &Effect407{})
}

View File

@@ -20,7 +20,8 @@ func (e *Effect475) Skill_Use() bool {
if damageDone.IntPart() < int64(damageThreshold) { if damageDone.IntPart() < int64(damageThreshold) {
critDuration := int(e.Args()[1].IntPart()) critDuration := int(e.Args()[1].IntPart())
e.GenSub(&Effect475_sub{}, critDuration)
e.Ctx().Our.AddEffect(e.Ctx().Our, e.GenSub(&Effect475_sub{}, critDuration))
} }

View File

@@ -6,29 +6,6 @@ import (
"blazing/logic/service/fight/node" "blazing/logic/service/fight/node"
) )
// 407 - 下回合起每回合XX等级+n持续m回合
type Effect407 struct {
node.EffectNode
}
func (e *Effect407) OnSkill() bool {
// 创建一个延迟生效的效果,在下一回合开始生效
go func() {
effectType := int(e.Args()[0].IntPart()) // XX类型
effectValue := int(e.Args()[1].IntPart()) // 等级+n
duration := int(e.Args()[2].IntPart()) // 持续m回合
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, effectType)
if statusEffect != nil {
statusEffect.SetArgs(e.Ctx().Our, effectValue)
statusEffect.Duration(duration)
e.Ctx().Our.AddEffect(e.Ctx().Our, statusEffect)
}
}()
return true
}
// 523 - 若当回合未击败对手则自身1 1 1 1 1 1能力+1 // 523 - 若当回合未击败对手则自身1 1 1 1 1 1能力+1
type Effect523 struct { type Effect523 struct {
node.EffectNode node.EffectNode
@@ -59,16 +36,6 @@ func (e *Effect523) Action_end_ex() bool {
return true return true
} }
// 440 - n回合内对手使用技能消耗的PP值变为m倍
type Effect440 struct {
node.EffectNode
}
func (e *Effect440) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(a[0]) // 持续n回合
}
// 457 - 复制对手释放的技能(组队对战时无效) // 457 - 复制对手释放的技能(组队对战时无效)
type Effect457 struct { type Effect457 struct {
node.EffectNode node.EffectNode
@@ -105,24 +72,6 @@ func (e *Effect197) SetArgs(t *input.Input, a ...int) {
e.EffectNode.Duration(a[0]) // 持续n回合 e.EffectNode.Duration(a[0]) // 持续n回合
} }
// 412 - 若自身体力小于1/n则每次攻击不消耗PP值
type Effect412 struct {
node.EffectNode
}
func (e *Effect412) SkillHit() bool {
maxHp := e.Ctx().Our.CurrentPet.GetMaxHP()
currentHp := e.Ctx().Our.CurrentPet.GetHP()
threshold := maxHp.Div(e.Args()[0]) // 1/n
if currentHp.Cmp(threshold) < 0 {
// 本次攻击不消耗PP
e.Ctx().Our.SkipPpConsumption = true
}
return true
}
// 199 - 下次被击败后下一个出场的精灵xx等级+k // 199 - 下次被击败后下一个出场的精灵xx等级+k
type Effect199 struct { type Effect199 struct {
node.EffectNode node.EffectNode

View File

@@ -244,7 +244,13 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
return item.ID == currentSkill.Info.ID return item.ID == currentSkill.Info.ID
}) })
if ok { if ok {
skill.PP-- usecount := 1
attacker.Exec(func(effect input.Effect) bool { //技能使用后的我方效果
effect.Ctx().SkillEntity = currentSkill
effect.HookPP(&usecount)
return true
})
skill.Use(usecount)
} }
} }
if defender.CurrentPet.Info.Hp > 0 { if defender.CurrentPet.Info.Hp > 0 {

View File

@@ -47,7 +47,7 @@ type Effect interface {
//OnSwitchOut() bool // 精灵下场时触发 //OnSwitchOut() bool // 精灵下场时触发
// OnOwnerSwitchIn() bool // 所属玩家精灵出战时触发 // OnOwnerSwitchIn() bool // 所属玩家精灵出战时触发
// OnOwnerSwitchOut() bool // 所属玩家精灵下场时触发 // OnOwnerSwitchOut() bool // 所属玩家精灵下场时触发
HookPP(count *int) bool
TurnEnd() //回合结束计算 TurnEnd() //回合结束计算
HookAction() bool //出手前的hook参数返回false阻止继续出手 HookAction() bool //出手前的hook参数返回false阻止继续出手
//PreBattleEnd() bool //战斗结束前 //PreBattleEnd() bool //战斗结束前

View File

@@ -23,6 +23,9 @@ func (e *EffectNode) CalculatePre() bool {
return true return true
} }
func (e *EffectNode) HookPP(count *int) bool {
return true
}
func (e *EffectNode) OnSkill() bool { func (e *EffectNode) OnSkill() bool {
// if e.Effect != nil { // if e.Effect != nil {
// if e.Hit() { //没命中 // if e.Hit() { //没命中

View File

@@ -459,6 +459,10 @@ type SkillInfo struct {
PP uint32 PP uint32
} }
func (s *SkillInfo) Use(count int) {
s.PP -= uint32(count)
}
// TableName Pet's table name // TableName Pet's table name
func (*Pet) TableName() string { func (*Pet) TableName() string {
return TableNamePet return TableNamePet