Files
bl/logic/service/fight/effect/1142_1145_1147.go
2026-04-01 00:48:42 +08:00

197 lines
4.7 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"
"github.com/gogf/gf/v2/util/grand"
)
var effect1143StatusPool = []int{
int(info.PetStatus.Burned),
int(info.PetStatus.Frozen),
int(info.PetStatus.IceBound),
22, // 焚烬;当前仓库未见显式枚举常量,按配置 ID 透传
}
func addRandomStatuses1143(owner, target *input.Input, count int) int {
if owner == nil || target == nil || count <= 0 {
return 0
}
indexes := grand.Perm(len(effect1143StatusPool))
applied := 0
for _, idx := range indexes {
statusID := effect1143StatusPool[idx]
eff := owner.InitEffect(input.EffectType.Status, statusID)
if eff == nil {
continue
}
target.AddEffect(owner, eff)
applied++
if applied >= count {
break
}
}
return applied
}
// Effect 1142: 回合结束时将自身当前体力降低为{0},并附加本次降低体力值{1}%的百分比伤害
type Effect1142 struct {
node.EffectNode
}
func (e *Effect1142) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1142, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1142Sub struct {
FixedDuration1Base
}
func (e *Effect1142Sub) TurnEnd() {
if len(e.Args()) < 2 {
e.EffectNode.TurnEnd()
return
}
targetHP := alpacadecimal.NewFromInt(int64(e.Args()[0].IntPart()))
currentHP := e.Ctx().Our.CurrentPet.GetHP()
if currentHP.Cmp(targetHP) <= 0 {
e.EffectNode.TurnEnd()
return
}
reduce := currentHP.Sub(targetHP)
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: reduce,
})
damage := reduce.Mul(e.Args()[1]).Div(hundred)
if damage.Cmp(alpacadecimal.Zero) > 0 {
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Percent,
Damage: damage,
})
}
e.EffectNode.TurnEnd()
}
// Effect 1143: 对手处于异常状态时附加{0}点固定伤害,不处于异常状态则下{1}回合使对手随机进入烧伤、冻伤、冰封、焚烬中的{2}种异常状态
type Effect1143 struct {
node.EffectNode
}
func (e *Effect1143) OnSkill() bool {
if len(e.Args()) < 3 {
return true
}
if e.Ctx().Opp.StatEffect_Exist_all() {
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: e.Args()[0],
})
return true
}
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1143, int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
if sub != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
}
return true
}
type Effect1143Sub struct {
RoundEffectArg0Base
}
func (e *Effect1143Sub) OnSkill() bool {
if len(e.Args()) < 2 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
addRandomStatuses1143(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart()))
return true
}
// Effect 1144: 附加{0}~{1}点固定伤害并恢复等量体力
type Effect1144 struct {
node.EffectNode
}
func (e *Effect1144) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
minDamage := int(e.Args()[0].IntPart())
maxDamage := int(e.Args()[1].IntPart())
if maxDamage < minDamage {
maxDamage = minDamage
}
damage := minDamage
if maxDamage > minDamage {
damage += grand.Intn(maxDamage - minDamage + 1)
}
value := alpacadecimal.NewFromInt(int64(damage))
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: value,
})
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, value)
return true
}
// Effect 1145: 令双方全属性+{0}
type Effect1145 struct {
node.EffectNode
}
func (e *Effect1145) OnSkill() bool {
if len(e.Args()) == 0 {
return true
}
boost := int8(e.Args()[0].IntPart())
for i := range e.Ctx().Our.Prop[:] {
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), boost)
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), boost)
}
return true
}
// Effect 1147: 未击败对手则消除对手能力提升状态
type Effect1147 struct {
node.EffectNode
}
func (e *Effect1147) Skill_Use() bool {
if e.Ctx().Opp.CurrentPet == nil || e.Ctx().Opp.CurrentPet.Info.Hp <= 0 {
return true
}
clearPositiveProps(e.Ctx().Opp, e.Ctx().Our)
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 1142, &Effect1142{})
input.InitEffect(input.EffectType.Sub, 1142, &Effect1142Sub{})
input.InitEffect(input.EffectType.Skill, 1143, &Effect1143{})
input.InitEffect(input.EffectType.Sub, 1143, &Effect1143Sub{})
input.InitEffect(input.EffectType.Skill, 1144, &Effect1144{})
input.InitEffect(input.EffectType.Skill, 1145, &Effect1145{})
input.InitEffect(input.EffectType.Skill, 1147, &Effect1147{})
}