Files
bl/logic/service/fight/effect/1523_1527.go

203 lines
4.5 KiB
Go
Raw Normal View History

2026-04-04 01:04:58 +08:00
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"
"github.com/gogf/gf/v2/util/grand"
)
// Effect 1523: 清除对手回合类效果后吸取固定体力
type Effect1523 struct{ node.EffectNode }
func (e *Effect1523) Skill_Use() bool {
if len(e.Args()) == 0 || e.Ctx().Opp == nil {
return true
}
before := activeTurnEffectCount(e.Ctx().Opp)
e.Ctx().Opp.CancelTurn(e.Ctx().Our)
if before <= 0 {
return true
}
drain := e.Args()[0]
if drain.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: drain,
})
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, drain)
return true
}
// Effect 1524: 反馈自身能力下降并恢复体力,否则清除自身能力下降
type Effect1524 struct{ node.EffectNode }
func transferSelfStatDowns(owner, target *input.Input) bool {
if owner == nil || target == nil {
return false
}
transferred := false
for idx, level := range owner.Prop[:] {
if level >= 0 {
continue
}
if target.SetProp(owner, int8(idx), level) {
transferred = true
}
}
return transferred
}
func clearOwnStatDowns(owner *input.Input) {
if owner == nil {
return
}
for idx, level := range owner.Prop[:] {
if level >= 0 {
continue
}
owner.SetProp(owner, int8(idx), 0)
}
}
func (e *Effect1524) Skill_Use() bool {
if e.Ctx().Our == nil {
return true
}
if transferSelfStatDowns(e.Ctx().Our, e.Ctx().Opp) {
if e.Ctx().Our.CurrentPet != nil {
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.CurrentPet.GetMaxHP())
}
return true
}
clearOwnStatDowns(e.Ctx().Our)
return true
}
// Effect 1525: 概率提升伤害,满血时概率翻倍
type Effect1525 struct {
node.EffectNode
boosted bool
}
func (e *Effect1525) SkillHit() bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || len(e.Args()) < 2 {
return true
}
chance := int(e.Args()[0].IntPart())
if e.Ctx().Our.CurrentPet != nil && e.Ctx().Our.CurrentPet.GetHP().Cmp(e.Ctx().Our.CurrentPet.GetMaxHP()) >= 0 {
chance *= 2
if chance > 100 {
chance = 100
}
}
if chance <= 0 {
return true
}
ok, _, _ := e.Input.Player.Roll(chance, 100)
if ok {
e.boosted = true
}
return true
}
func (e *Effect1525) Damage_Mul(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || !e.boosted || len(e.Args()) < 2 {
return true
}
percent := e.Args()[1]
if percent.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
zone.Damage = zone.Damage.Mul(hundred.Add(percent)).Div(hundred)
e.boosted = false
return true
}
// Effect 1526: 附加固定伤害,技能无效时降低对手所有 PP
type Effect1526 struct{ node.EffectNode }
func (e *Effect1526) OnSkill() bool {
if len(e.Args()) < 2 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
min := int64(e.Args()[0].IntPart())
max := int64(e.Args()[1].IntPart())
if max < min {
min, max = max, min
}
if max < min {
return true
}
rangeSize := int(max - min + 1)
if rangeSize <= 0 {
return true
}
damage := alpacadecimal.NewFromInt(min + int64(grand.Intn(rangeSize)))
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: damage,
})
return true
}
func (e *Effect1526) Skill_Use_ex() bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.AttackTime != 0 {
return true
}
if e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil {
return true
}
for idx := range e.Ctx().Opp.CurrentPet.Info.SkillList {
skill := &e.Ctx().Opp.CurrentPet.Info.SkillList[idx]
if skill.PP > 0 {
skill.PP--
}
}
return true
}
// Effect 1527: 后出手必定致命一击
type Effect1527 struct{ node.EffectNode }
func (e *Effect1527) SkillHit() bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
if e.Ctx().Our == nil || e.Ctx().Our.FightC == nil {
return true
}
if e.Ctx().Our.FightC.IsFirst(e.Ctx().Our.Player) {
return true
}
e.Ctx().SkillEntity.XML.CritRate = 16
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 1523, &Effect1523{})
input.InitEffect(input.EffectType.Skill, 1524, &Effect1524{})
input.InitEffect(input.EffectType.Skill, 1525, &Effect1525{})
input.InitEffect(input.EffectType.Skill, 1526, &Effect1526{})
input.InitEffect(input.EffectType.Skill, 1527, &Effect1527{})
}