Files
bl/logic/service/fight/effect/744_748.go
xinian 023128be25
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
feat: 新增战斗效果实现
新增大量战斗效果逻辑实现,包括效果ID 678-708、734-743、744-748,并更新对应的效果描述映射。
2026-03-30 20:19:41 +08:00

137 lines
3.3 KiB
Go

package effect
import (
"blazing/logic/service/fight/action"
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
"github.com/alpacahq/alpacadecimal"
)
var fiveDecimal = alpacadecimal.NewFromInt(5)
// Effect 744: 攻击时若自身体力大于对手体力,则附加{0}点固定伤害
type Effect744 struct {
node.EffectNode
}
func (e *Effect744) Skill_Use() bool {
if len(e.Args()) == 0 || e.Ctx().Our.CurrentPet.GetHP().Cmp(e.Ctx().Opp.CurrentPet.GetHP()) <= 0 {
return true
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: e.Args()[0],
})
return true
}
// Effect 745: 使对手{0},对手处于异常状态时弱化效果翻倍
type Effect745 struct {
node.EffectNode
}
func (e *Effect745) OnSkill() bool {
multiplier := int8(1)
if e.Ctx().Opp.StatEffect_Exist_all() {
multiplier = 2
}
for i, arg := range e.Args() {
if i >= len(e.Ctx().Opp.Prop) {
break
}
level := int8(arg.IntPart()) * multiplier
if level == 0 {
continue
}
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), level)
}
return true
}
// Effect 746: {0}回合内若对手恢复体力则自身也恢复等量体力的{1}/5倍
type Effect746 struct {
node.EffectNode
}
func (e *Effect746) OnSkill() bool {
if len(e.Args()) < 2 {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 746, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
if effect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect746Sub struct {
RoundEffectArg0Base
}
func (e *Effect746Sub) Heal_Pre(ac action.BattleActionI, value *int) bool {
if len(e.Args()) < 2 || value == nil || *value <= 0 {
return true
}
heal := alpacadecimal.NewFromInt(int64(*value)).Mul(e.Args()[1]).Div(fiveDecimal)
if heal.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Opp.Heal(e.Ctx().Opp, &action.SelectSkillAction{}, heal)
return true
}
// Effect 747: 自身处于能力下降时先制+1
type Effect747 struct {
node.EffectNode
}
func (e *Effect747) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
if !e.Ctx().Our.HasPropSub() || len(e.Args()) == 0 {
return true
}
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if current == nil || current.SkillEntity == nil {
return true
}
current.SkillEntity.XML.Priority += int(e.Args()[0].IntPart())
return true
}
// Effect 748: 若打出的伤害在{0}至{1}之间则对手{2}
type Effect748 struct {
node.EffectNode
}
func (e *Effect748) OnSkill() bool {
if len(e.Args()) < 3 || e.Ctx().Our.SumDamage.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
if e.Ctx().Our.SumDamage.Cmp(e.Args()[0]) < 0 || e.Ctx().Our.SumDamage.Cmp(e.Args()[1]) > 0 {
return true
}
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(e.Args()[2].IntPart()))
if statusEffect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 744, &Effect744{})
input.InitEffect(input.EffectType.Skill, 745, &Effect745{})
input.InitEffect(input.EffectType.Skill, 746, &Effect746{})
input.InitEffect(input.EffectType.Sub, 746, &Effect746Sub{})
input.InitEffect(input.EffectType.Skill, 747, &Effect747{})
input.InitEffect(input.EffectType.Skill, 748, &Effect748{})
}