Files
bl/logic/service/fight/effect/1660_1664.go
昔念 4cf1bcc07f ```
feat(effect): 实现effects 1770-1794战斗效果

- 实现Effect 1770: 开启战魂附体效果,免疫对手下1次攻击技能伤害,
  若对手攻击技能PP值为满则额外免疫下1次固定伤害和百分比伤害

- 实现Effect 1771-1779相关战斗效果,包括能力状态反转、固定伤害计算等功能

- 实现Effect 1780-1794系列效果,包含伤害计算、护盾机制、切换限制等功能
2026-03-31 08:28:37 +08:00

209 lines
5.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"
)
// Effect 1660: {0}%令对手{1},未触发则降低对手所有技能{2}点PP值
type Effect1660 struct {
node.EffectNode
}
func (e *Effect1660) Skill_Use() bool {
if len(e.Args()) < 3 {
return true
}
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100); ok {
if !addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart())) {
e.Ctx().Opp.DelPP(int(e.Args()[2].IntPart()))
}
return true
}
e.Ctx().Opp.DelPP(int(e.Args()[2].IntPart()))
return true
}
// Effect 1661: 获得{0}点护盾,护盾消失时{1}%的概率使对手{2}
type Effect1661 struct {
node.EffectNode
}
func (e *Effect1661) Skill_Use() bool {
if len(e.Args()) < 3 {
return true
}
shield := e.Args()[0]
if shield.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Our.AddShield(shield)
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1661, int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1661Sub struct {
node.EffectNode
}
func (e *Effect1661Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.CanStack(false)
e.Duration(-1)
}
func (e *Effect1661Sub) ShieldChange(before, after alpacadecimal.Decimal) bool {
if len(e.Args()) < 2 {
return true
}
if before.Cmp(alpacadecimal.Zero) <= 0 || after.Cmp(alpacadecimal.Zero) > 0 {
return true
}
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100); ok {
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart()))
}
return true
}
// Effect 1662: 消耗自身所有护盾值并附加等量固定伤害,若对手体力未变化则恢复自身等量体力
type Effect1662 struct {
node.EffectNode
}
func (e *Effect1662) Skill_Use() bool {
shield := e.Ctx().Our.ConsumeAllShield()
if shield.Cmp(alpacadecimal.Zero) <= 0 || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil {
return true
}
before := e.Ctx().Opp.CurrentPet.GetHP()
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: shield,
})
if e.Ctx().Opp.CurrentPet.GetHP().Cmp(before) == 0 {
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, shield)
}
return true
}
// Effect 1663: 当回合击败对手则令对手下只登场精灵随机{0}个技能PP值归零
type Effect1663 struct {
node.EffectNode
}
func (e *Effect1663) Skill_Use() bool {
if len(e.Args()) < 1 || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil || e.Ctx().Opp.CurrentPet.Info.Hp > 0 {
return true
}
sub := e.Ctx().Opp.InitEffect(input.EffectType.Sub, 1663, int(e.Args()[0].IntPart()))
if sub != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1663Sub struct {
node.EffectNode
}
func (e *Effect1663Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.CanStack(false)
e.Duration(1)
}
func (e *Effect1663Sub) SwitchIn(in *input.Input) bool {
if in != e.Ctx().Opp || len(e.Args()) < 1 {
return true
}
randomSkillPPZero(e.Ctx().Opp, int(e.Args()[0].IntPart()))
e.Alive(false)
return true
}
// Effect 1664: 当回合若自身先出手则令对手使用的威力低于{0}的攻击技能无效,若击败对手则攻击无效效果延续至下回合
type Effect1664 struct {
node.EffectNode
}
func (e *Effect1664) ActionStart(a, b *action.SelectSkillAction) bool {
if !e.IsFirst() || len(e.Args()) < 1 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
sub := e.Ctx().Opp.InitEffect(input.EffectType.Sub, 1664, int(e.Args()[0].IntPart()))
if sub != nil {
if s, ok := sub.(*Effect1664Sub); ok {
s.Duration(1)
}
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
}
return true
}
func (e *Effect1664) Skill_Use() bool {
if !e.IsFirst() || len(e.Args()) < 1 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
if e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil || e.Ctx().Opp.CurrentPet.Info.Hp > 0 {
return true
}
if sub := e.Ctx().Opp.GetEffect(input.EffectType.Sub, 1664); sub != nil {
if s, ok := sub.(*Effect1664Sub); ok && s.Duration() < 2 {
s.Duration(2)
}
}
return true
}
type Effect1664Sub struct {
node.EffectNode
}
func (e *Effect1664Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.CanStack(false)
e.Duration(1)
}
func (e *Effect1664Sub) ActionStart(a, b *action.SelectSkillAction) bool {
if len(e.Args()) < 1 {
return true
}
skill := e.Ctx().SkillEntity
if skill == nil || skill.Category() == info.Category.STATUS {
return true
}
if skill.XML.Power < int(e.Args()[0].IntPart()) {
skill.SetMiss()
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 1660, &Effect1660{})
input.InitEffect(input.EffectType.Skill, 1661, &Effect1661{})
input.InitEffect(input.EffectType.Sub, 1661, &Effect1661Sub{})
input.InitEffect(input.EffectType.Skill, 1662, &Effect1662{})
input.InitEffect(input.EffectType.Skill, 1663, &Effect1663{})
input.InitEffect(input.EffectType.Sub, 1663, &Effect1663Sub{})
input.InitEffect(input.EffectType.Skill, 1664, &Effect1664{})
input.InitEffect(input.EffectType.Sub, 1664, &Effect1664Sub{})
}