Files
bl/logic/service/fight/effect/none.go
xinian 78a68148ce
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
chore: update fight logic and effect implementations
2026-04-05 02:25:44 +08:00

132 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
}
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{})
}