Files
bl/logic/service/fight/effect/1433_1437.go
xinian 9c6f3988de
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
refactor: 重构 CurrentPet 为 CurPet
2026-04-04 04:34:43 +08:00

195 lines
5.1 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/logic/service/fight/action"
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
"github.com/alpacahq/alpacadecimal"
)
func effectOwnerPetByCatchTime(our *input.Input, catchTime uint32) *info.BattlePetEntity {
if our == nil {
return nil
}
if catchTime == 0 {
return our.CurPet[0]
}
for _, pet := range our.AllPet {
if pet != nil && pet.Info.CatchTime == catchTime {
return pet
}
}
return our.CurPet[0]
}
func effectOwnerAliveByCatchTime(our *input.Input, catchTime uint32) bool {
pet := effectOwnerPetByCatchTime(our, catchTime)
return pet != nil && pet.Alive()
}
// Effect 1433: 损失“辛”所有体力同时使对手受到损失体力值1/2的固定伤害
type Effect1433 struct{ node.EffectNode }
func (e *Effect1433) Skill_Use() bool {
ownerPet := effectOwnerPetByCatchTime(e.Ctx().Our, e.ID().GetCatchTime())
if ownerPet == nil {
return true
}
lost := alpacadecimal.NewFromInt(int64(ownerPet.Info.Hp))
if lost.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
if ownerPet == e.Ctx().Our.CurPet[0] {
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: lost,
})
} else {
ownerPet.Info.Hp = 0
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: lost.Div(alpacadecimal.NewFromInt(2)),
})
return true
}
// Effect 1434: “辛”死亡后令自身下1次受到的攻击伤害减少50%
type Effect1434 struct{ node.EffectNode }
func (e *Effect1434) SwitchOut(in *input.Input) bool {
if in != e.Ctx().Our {
return true
}
ownerPet := effectOwnerPetByCatchTime(e.Ctx().Our, e.ID().GetCatchTime())
if ownerPet == nil || ownerPet.Alive() {
return true
}
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1434)
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
e.Alive(false)
return true
}
type Effect1434Sub struct {
FixedDurationNeg1Base
used bool
}
func (e *Effect1434Sub) DamageDivEx(zone *info.DamageZone) bool {
if e.used || zone == nil || zone.Type != info.DamageType.Red {
return true
}
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(50)).Div(hundred)
e.used = true
e.Alive(false)
return true
}
// Effect 1435: “辛”存活时反转自身能力下降状态反转成功则2回合内令对手使用的属性技能无效
type Effect1435 struct{ node.EffectNode }
func (e *Effect1435) OnSkill() bool {
if !effectOwnerAliveByCatchTime(e.Ctx().Our, e.ID().GetCatchTime()) {
return true
}
reversed := false
for i, v := range e.Ctx().Our.Prop[:] {
if v >= 0 {
continue
}
if e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), -2*v) {
reversed = true
}
}
if !reversed {
return true
}
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1435)
if sub != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1435Sub struct{ FixedDuration2Base }
func (e *Effect1435Sub) SkillHit_ex() bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() != info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.SetNoSide()
return true
}
// Effect 1436: 当回合击败对手则{0}%恢复自身全部体力,未触发则全属性+{1}
type Effect1436 struct{ node.EffectNode }
func (e *Effect1436) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
if e.Ctx().Opp.CurPet[0].Info.Hp == 0 {
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100); ok {
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.CurPet[0].GetMaxHP())
return true
}
}
boost := int8(e.Args()[1].IntPart())
for i := range e.Ctx().Our.Prop[:] {
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), boost)
}
return true
}
// Effect 1437: “辛”存活时造成攻击伤害的50%恢复自身体力“辛”死亡后造成的攻击伤害额外提升50%
type Effect1437 struct{ node.EffectNode }
func (e *Effect1437) Damage_Mul(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
if effectOwnerAliveByCatchTime(e.Ctx().Our, e.ID().GetCatchTime()) {
return true
}
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(150)).Div(hundred)
return true
}
func (e *Effect1437) Skill_Use() bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
if !effectOwnerAliveByCatchTime(e.Ctx().Our, e.ID().GetCatchTime()) {
return true
}
if e.Ctx().Our.SumDamage.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
heal := e.Ctx().Our.SumDamage.Div(alpacadecimal.NewFromInt(2))
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, heal)
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 1433, &Effect1433{})
input.InitEffect(input.EffectType.Skill, 1434, &Effect1434{})
input.InitEffect(input.EffectType.Sub, 1434, &Effect1434Sub{})
input.InitEffect(input.EffectType.Skill, 1435, &Effect1435{})
input.InitEffect(input.EffectType.Sub, 1435, &Effect1435Sub{})
input.InitEffect(input.EffectType.Skill, 1436, &Effect1436{})
input.InitEffect(input.EffectType.Skill, 1437, &Effect1437{})
}