Files
bl/logic/service/fight/effect/none.go
xinian c40430aaa4
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
feat: 实现战斗技能效果
2026-03-29 16:38:34 +08:00

99 lines
1.9 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 (e *Effect201) OnSkill() bool {
args := e.Args()
if len(args) == 0 {
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 {
e.Ctx().Our.Heal(
e.Ctx().Our,
&action.SelectSkillAction{},
e.Ctx().Our.CurrentPet.GetMaxHP().Div(divisor),
)
return true
}
for _, pet := range e.Ctx().Our.AllPet {
if pet == nil || !pet.Alive() {
continue
}
healAmount := pet.GetMaxHP().Div(divisor)
if pet == e.Ctx().Our.CurrentPet {
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, healAmount)
continue
}
pet.Info.ModelHP(healAmount.IntPart())
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 201, &Effect201{})
}