Files
bl/logic/service/fight/effect/selfkill.go
xinian 5204615c28
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
feat: 新增战斗效果并优化现有逻辑
2026-04-03 00:22:05 +08:00

548 lines
12 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"
"github.com/gogf/gf/v2/util/grand"
)
type SelfKill struct {
node.EffectNode
can bool
}
func (e *SelfKill) SetArgs(t *input.Input, a ...int) {
// e.CanStack(-1)//后续的不会顶掉这个效果
e.EffectNode.SetArgs(t, a...)
e.Duration(-1) // 次数类,无限回合
}
func (e *SelfKill) OnSkill() bool {
if e.can {
return true
}
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
})
e.can = true
return true
}
// 自杀,所以效果不消除
func (e *SelfKill) SwitchOut(in *input.Input) bool {
return true
}
// Effect 59: 消耗自身全部体力(体力降到0),使下一只出战精灵的{0}和{1}能力提升1个等级
type Effect59 struct {
SelfKill
}
func init() {
input.InitEffect(input.EffectType.Skill, 59, &Effect59{})
}
func (e *Effect59) TurnStart(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) {
if !e.can {
return
}
e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.Args()[0].IntPart()), 1)
e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.Args()[1].IntPart()), 1)
e.Alive(false)
}
// Effect 71: 消耗自身全部体力己方下2次攻击技能必定打出致命一击
type Effect71 struct {
SelfKill
count int
}
func init() {
input.InitEffect(input.EffectType.Skill, 71, &Effect71{count: 2})
}
func (e *Effect71) ActionStart(a, b *action.SelectSkillAction) bool {
if !e.can {
return true
}
if e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.XML.CritRate = 16
e.count--
if e.count <= 0 {
e.Alive(false)
}
return true
}
// Effect 72: 若没有命中对手则自己失去全部体力
type Effect72 struct {
node.EffectNode
}
func init() {
input.InitEffect(input.EffectType.Skill, 72, &Effect72{})
}
// SkillHit 命中之后
func (e *Effect72) SkillHit() bool {
if e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().AttackTime != 0 {
return true
}
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.True,
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.Hp)),
})
return true
}
// Effect 79: 损失1/2的体力提升自身的能力
type Effect79 struct {
node.EffectNode
}
func init() {
input.InitEffect(input.EffectType.Skill, 79, &Effect79{})
}
// 命中之后
// 特攻+2速度+1命中+1
func (e *Effect79) OnSkill() bool {
e.Ctx().Our.SetProp(e.Ctx().Our, 2, 2)
e.Ctx().Our.SetProp(e.Ctx().Our, 4, 1)
e.Ctx().Our.SetProp(e.Ctx().Our, 5, 1)
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: e.Ctx().Our.CurrentPet.GetHP().Div(alpacadecimal.NewFromInt(2)),
})
return true
}
// Effect 80: 损失1/2的体力给予对手同等的伤害
type Effect80 struct {
node.EffectNode
}
func init() {
input.InitEffect(input.EffectType.Skill, 80, &Effect80{})
}
func (e *Effect80) Skill_Use() bool {
att := e.Ctx().Our.CurrentPet.GetMaxHP().Div(alpacadecimal.NewFromInt(2))
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: att,
})
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: att,
})
return true
}
// Effect 112: 牺牲全部体力给对手造成250~300点伤害造成致命伤害时对手剩下1点体力
type Effect112 struct {
node.EffectNode
}
func init() {
input.InitEffect(input.EffectType.Skill, 112, &Effect112{})
}
// 命中之后
func (e *Effect112) Skill_Use() bool {
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
})
minDamage := int64(250)
maxDamage := int64(300)
n := int64(grand.N(int(minDamage), int(maxDamage)))
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: alpacadecimal.Min(alpacadecimal.NewFromInt(n), e.Ctx().Opp.CurrentPet.GetHP().Sub(alpacadecimal.NewFromInt(1))),
})
return true
}
// Effect 137: 损失一半当前体力值自身攻击和速度提升2个等级
type Effect137 struct {
node.EffectNode
}
func init() {
input.InitEffect(input.EffectType.Skill, 137, &Effect137{})
}
func (e *Effect137) OnSkill() bool {
currentHp := e.Ctx().Our.CurrentPet.GetHP()
halfHp := currentHp.Div(alpacadecimal.NewFromInt(2))
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: halfHp,
})
e.Ctx().Our.SetProp(e.Ctx().Our, 4, 2)
e.Ctx().Our.SetProp(e.Ctx().Our, 0, 2)
return true
}
// Effect 142: 损失1/{0}的体力值,下回合能较快出手
type Effect142 struct {
node.EffectNode
}
func init() {
input.InitEffect(input.EffectType.Skill, 142, &Effect142{})
}
func (e *Effect142) ComparePre(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
if fattack == nil {
return true
}
if fattack.PlayerID == e.Ctx().Our.UserID {
return true
}
if sattack == nil {
return true
}
if sattack.SkillEntity == nil {
return true
}
sattack.SkillEntity.XML.Priority += 1
return true
}
func (e *Effect142) OnSkill() bool {
maxHp := e.Ctx().Our.CurrentPet.GetMaxHP()
damageAmount := maxHp.Div(e.Args()[0])
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: damageAmount,
})
return true
}
// Effect 144: 消耗自己所有体力,使下一个出战的精灵{0}回合免疫异常状态
type Effect144 struct {
SelfKill
count int
}
func init() {
input.InitEffect(input.EffectType.Skill, 144, &Effect144{})
}
func (e *Effect144) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
// 魂印特性有不在场的情况,绑定时候将精灵和特性绑定
if !e.can {
return true
}
if int(e.Input.FightC.GetOverInfo().Round) >= e.count+e.SideEffectArgs[0] {
e.Alive(false)
}
if e.count == 0 {
e.count = int(e.Input.FightC.GetOverInfo().Round)
}
if in != e.Ctx().Opp {
return true
}
if input.IS_Stat(effEffect) {
return false
}
return true
}
// Effect 435: 牺牲自己,使下回合出场的精灵首次攻击必定命中,必定先手
type Effect435 struct {
SelfKill
}
func init() {
input.InitEffect(input.EffectType.Skill, 435, &Effect435{})
}
func (e *Effect435) ComparePre(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
if !e.can {
return true
}
if fattack == nil {
return true
}
if fattack.PlayerID == e.Ctx().Our.UserID {
return true
}
if sattack == nil {
return true
}
if sattack.SkillEntity == nil {
return true
}
sattack.SkillEntity.XML.Priority += 7
e.Alive(false)
return true
}
func (e *Effect435) ActionStart(a, b *action.SelectSkillAction) bool {
if !e.can {
return true
}
if e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.XML.MustHit = 1
return true
}
// Effect 479: 损失自身{0}点体力,给对手造成{1}点固定伤害,若自身体力不足{2}则剩下{3}点体力
type Effect479 struct {
node.EffectNode
}
func init() {
input.InitEffect(input.EffectType.Skill, 479, &Effect479{})
}
func (e *Effect479) OnSkill() bool {
selfDamage := alpacadecimal.NewFromInt(int64(e.Args()[0].IntPart()))
opponentDamage := alpacadecimal.NewFromInt(int64(e.Args()[1].IntPart()))
currentHp := e.Ctx().Our.CurrentPet.GetHP()
minHp := alpacadecimal.NewFromInt(200)
if currentHp.Cmp(minHp) < 0 {
damageToTake := currentHp.Sub(alpacadecimal.NewFromInt(1))
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: damageToTake,
})
} else {
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: selfDamage,
})
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: opponentDamage,
})
return true
}
// Effect 556: 命中后使自身体力降为1
type Effect556 struct {
node.EffectNode
}
func init() {
input.InitEffect(input.EffectType.Skill, 556, &Effect556{})
}
func (e *Effect556) OnSkill() bool {
currentHP := e.Ctx().Our.CurrentPet.Info.Hp
if currentHP > 1 {
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: alpacadecimal.NewFromInt(int64(currentHP - 1)),
})
}
return true
}
// Effect 574: 消耗自身全部体力,令己方下次使用的技能必定先手、必定命中,下次命中的攻击技能必定打出致命一击
type Effect574 struct {
SelfKill
}
func init() {
input.InitEffect(input.EffectType.Skill, 574, &Effect574{})
}
func (e *Effect574) ComparePre(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
if !e.can {
return true
}
if fattack == nil {
return true
}
if fattack.PlayerID == e.Ctx().Our.UserID {
return true
}
if sattack == nil {
return true
}
if sattack.SkillEntity == nil {
return true
}
sattack.SkillEntity.XML.Priority += 7
e.Alive(false)
return true
}
func (e *Effect574) ActionStart(a, b *action.SelectSkillAction) bool {
if !e.can {
return true
}
if e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.XML.MustHit = 1
e.Ctx().SkillEntity.XML.CritRate = 16
return true
}
// Effect 617: 消耗自身所有体力给对手造成{0}-{1}点伤害,若造成伤害大于对手体力则对手必定留1点血
type Effect617 struct {
node.EffectNode
}
func init() {
input.InitEffect(input.EffectType.Skill, 617, &Effect617{})
}
func (e *Effect617) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: e.Ctx().Our.CurrentPet.GetMaxHP(),
})
minDamage := int(e.Args()[0].IntPart())
maxDamage := int(e.Args()[1].IntPart())
if maxDamage < minDamage {
minDamage, maxDamage = maxDamage, minDamage
}
randomDamage := minDamage
if maxDamage > minDamage {
randomDamage = grand.N(minDamage, maxDamage)
}
remainHP := e.Ctx().Opp.CurrentPet.GetHP().Sub(alpacadecimal.NewFromInt(1))
if remainHP.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
damage := alpacadecimal.Min(alpacadecimal.NewFromInt(int64(randomDamage)), remainHP)
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: damage,
})
return true
}
// Effect 618: 消耗自身所有体力,使下一只出战精灵{0}回合内每回合恢复{1}点体力
type Effect618 struct {
SelfKill
}
func init() {
input.InitEffect(input.EffectType.Skill, 618, &Effect618{})
input.InitEffect(input.EffectType.Sub, 618, &Effect618Sub{})
}
func (e *Effect618) SwitchIn(in *input.Input) bool {
if !e.can || in != e.Ctx().Our {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 618, e.SideEffectArgs...)
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
e.Alive(false)
return true
}
type Effect618Sub struct {
RoundEffectArg0Base
}
func (e *Effect618Sub) TurnEnd() {
if len(e.Args()) > 1 && e.Ctx().Our.CurrentPet.Info.Hp > 0 {
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Args()[1])
}
e.EffectNode.TurnEnd()
}
// Effect 1380: 牺牲自身全部体力,使对手全属性-{0}且{1}回合内先制-{2}
type Effect1380 struct {
node.EffectNode
}
func init() {
input.InitEffect(input.EffectType.Skill, 1380, &Effect1380{})
input.InitEffect(input.EffectType.Sub, 1380, &Effect1380Sub{})
}
func (e *Effect1380) Skill_Use() bool {
if len(e.Args()) < 3 {
return true
}
applyAllPropDown(e.Ctx().Our, e.Ctx().Opp, int8(e.Args()[0].IntPart()))
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1380, int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
if sub != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
}
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: e.Ctx().Our.CurrentPet.GetHP(),
})
return true
}
type Effect1380Sub struct {
RoundEffectArg0Base
}
func (e *Effect1380Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if current == nil || current.SkillEntity == nil || len(e.Args()) < 2 {
return true
}
current.SkillEntity.XML.Priority -= int(e.Args()[1].IntPart())
return true
}