Files
bl/logic/service/fight/effect/none.go
昔念 e161e3626f
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
```
fix(fight): 修复单输入战斗中效果处理逻辑错误

- 在Effect201的OnSkill方法中调整了多输入战斗检查的位置,
  确保单输入战斗中的单目标效果被正确忽略

- 添加了针对单输入战斗中单目标效果的测试用例

- 移除了重复的多输入战斗检查代码

feat(fight): 添加战斗初始化时捕获标识
2026-04-13 09:59:09 +08:00

136 lines
2.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package effect
import (
"blazing/common/data/share"
"blazing/logic/service/fight/action"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// Effect 445: 使用后在战斗结束时可以获得500赛尔豆每日上限5000
type Effect445 struct {
node.EffectNode
}
func (e *Effect445) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.Duration(-1)
}
func (e *Effect445) OnBattleEnd() bool {
player := e.Ctx().Our.Player
if player == nil || player.GetInfo().UserID == 0 {
return true
}
count, err := share.GlobalCounterManager.GetCount(&share.DailyPeriod, player.GetInfo().UserID, 445)
if err != nil && err != share.ErrCacheMiss {
return true
}
if err == share.ErrCacheMiss {
count = 0
}
if count >= 10 {
return true
}
if !player.ItemAdd(1, 500) {
return true
}
_, _ = share.GlobalCounterManager.IncrCount(&share.DailyPeriod, player.GetInfo().UserID, 445)
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 445, &Effect445{})
}
// Effect 201: 对选中对象或本方全体恢复1/{1}的体力
type Effect201 struct {
node.EffectNode
}
func isSameSideTarget(carrier, target *input.Input) bool {
if carrier == nil || target == nil {
return false
}
if carrier == target {
return true
}
for _, ally := range carrier.Team {
if ally == target {
return true
}
}
if carrier.Player != nil && target.Player != nil {
return carrier.Player.GetInfo().UserID == target.Player.GetInfo().UserID
}
return false
}
func (e *Effect201) OnSkill() bool {
args := e.Args()
if len(args) == 0 {
return true
}
carrier := e.CarrierInput()
if carrier == nil {
carrier = e.Ctx().Our
}
if carrier == nil {
return true
}
if !carrier.IsMultiInputBattle() {
return true
}
divisorIndex := len(args) - 1
if len(args) > 1 {
divisorIndex = 1
}
divisor := args[divisorIndex]
if divisor.IntPart() <= 0 {
return true
}
healAll := len(args) > 1 && args[0].IntPart() != 0
if !healAll {
target := e.TargetInput()
if !isSameSideTarget(carrier, target) {
target = carrier
}
current := target.CurrentPet()
if current == nil {
return true
}
target.Heal(
carrier,
&action.SelectSkillAction{},
current.GetMaxHP().Div(divisor),
)
return true
}
team := carrier.Team
if len(team) == 0 {
team = []*input.Input{carrier}
}
for _, ally := range team {
if ally == nil {
continue
}
if current := ally.CurrentPet(); current != nil && current.Alive() {
ally.Heal(carrier, &action.SelectSkillAction{}, current.GetMaxHP().Div(divisor))
}
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 201, &Effect201{})
}