feat: 新增效果实现并重构相关逻辑
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed

This commit is contained in:
xinian
2026-03-31 04:36:25 +08:00
committed by cnb
parent 79c014f9cd
commit b4463c35e0
12 changed files with 603 additions and 232 deletions

View File

@@ -46,6 +46,83 @@ func (e *BossJsonEid41) TurnStart(fattack, sattack *action.SelectSkillAction) {
}
}
// 42: 迅捷,所有技能先制+n
type BossJsonEid42 struct{ BossJsonEid0 }
func (e *BossJsonEid42) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
if !e.ownerActive() {
return true
}
priority := bossJsonIntArg(e.Args(), 0, 0)
if priority == 0 {
return true
}
userID := e.Ctx().Our.Player.GetInfo().UserID
if fattack != nil && fattack.PlayerID == userID && fattack.SkillEntity != nil {
fattack.SkillEntity.XML.Priority += priority
}
if sattack != nil && sattack.PlayerID == userID && sattack.SkillEntity != nil {
sattack.SkillEntity.XML.Priority += priority
}
return true
}
// 7: 致盲闪避率提升n%
type BossJsonEid7 struct{ BossJsonEid0 }
func (e *BossJsonEid7) SkillHit_ex() bool {
if !e.ownerActive() || e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.AttackTime == 2 {
return true
}
hit, _, _ := e.Input.Player.Roll(bossJsonFirstPositiveArg(e.Args(), 0), 100)
if hit {
e.Ctx().SkillEntity.SetMiss()
}
return true
}
// 8: 锁定n%打出致命一击
type BossJsonEid8 struct{ BossJsonEid0 }
func (e *BossJsonEid8) ActionStart(a, b *action.SelectSkillAction) bool {
if !e.ownerActive() || !bossJsonIsAttackSkill(e.Ctx().SkillEntity) {
return true
}
e.Ctx().SkillEntity.XML.CritRate += bossJsonIntArg(e.Args(), 0, 0)
return true
}
// 45: 锁定n%打出致命一击
type BossJsonEid45 struct{ BossJsonEid0 }
func (e *BossJsonEid45) ActionStart(a, b *action.SelectSkillAction) bool {
if !e.ownerActive() || !bossJsonIsAttackSkill(e.Ctx().SkillEntity) {
return true
}
e.Ctx().SkillEntity.XML.CritRate = bossJsonIntArg(e.Args(), 0, 0)
return true
}
// 77: 锋锐每回合附加n点固定伤害
type BossJsonEid77 struct{ BossJsonEid0 }
func (e *BossJsonEid77) TurnStart(fattack, sattack *action.SelectSkillAction) {
if !e.ownerActive() {
return
}
damage := bossJsonIntArg(e.Args(), 0, 0)
if damage <= 0 {
return
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: alpacadecimal.NewFromInt(int64(damage)),
})
}
// 113: 对手使用技能后全属性-1
type BossJsonEid113 struct{ BossJsonEid0 }
@@ -314,6 +391,11 @@ func (e *BossJsonEid1254) TurnEnd() {
func init() {
input.InitEffect(input.EffectType.NewSel, 41, &BossJsonEid41{})
input.InitEffect(input.EffectType.NewSel, 42, &BossJsonEid42{})
input.InitEffect(input.EffectType.NewSel, 7, &BossJsonEid7{})
input.InitEffect(input.EffectType.NewSel, 8, &BossJsonEid8{})
input.InitEffect(input.EffectType.NewSel, 45, &BossJsonEid45{})
input.InitEffect(input.EffectType.NewSel, 77, &BossJsonEid77{})
input.InitEffect(input.EffectType.NewSel, 113, &BossJsonEid113{})
input.InitEffect(input.EffectType.NewSel, 144, &BossJsonEid144{})
input.InitEffect(input.EffectType.NewSel, 224, &BossJsonEid224{})

View File

@@ -33,22 +33,34 @@ func (e *Effect2220) SkillHit() bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
if e.Ctx().Our.Prop[1] > e.Ctx().Our.Prop[0] {
e.Ctx().SkillEntity.XML.Power = int(e.Ctx().Our.Prop[1])
return true
atk := e.Ctx().Our.GetProp(0)
spAtk := e.Ctx().Our.GetProp(2)
if spAtk.Cmp(atk) > 0 {
e.Ctx().SkillEntity.XML.Category = int(info.Category.SPECIAL)
} else if atk.Cmp(spAtk) > 0 {
e.Ctx().SkillEntity.XML.Category = int(info.Category.PHYSICAL)
}
e.Ctx().SkillEntity.XML.Power = int(e.Ctx().Our.Prop[0])
return true
}
// Effect 2221: {0}回合内每回合{1}%闪避对手攻击,对手攻击技能命中时令对手随机{2}个技能PP值归0
type Effect2221 struct{ node.EffectNode }
type Effect2221 struct{ RoundEffectArg0Base }
func (e *Effect2221) SkillHit_ex() bool {
if len(e.Args()) < 3 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100); ok {
e.Ctx().SkillEntity.SetMiss()
}
return true
}
func (e *Effect2221) Skill_Use_ex() bool {
if len(e.Args()) < 3 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100); ok && e.Ctx().SkillEntity.AttackTime != 0 {
if e.Ctx().SkillEntity.AttackTime != 0 {
e.Ctx().Opp.DelPP(int(e.Args()[2].IntPart()))
}
return true
@@ -61,6 +73,9 @@ func (e *Effect2222) Damage_Mul(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) == 0 {
return true
}
if e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil {
return true
}
if e.Ctx().Opp.CurrentPet.GetHP().Cmp(e.Ctx().Opp.CurrentPet.GetMaxHP()) >= 0 {
zone.Damage = zone.Damage.Mul(hundred.Add(e.Args()[0])).Div(hundred)
}
@@ -68,26 +83,55 @@ func (e *Effect2222) Damage_Mul(zone *info.DamageZone) bool {
}
// Effect 2223: 若对手当回合切换精灵则造成伤害提升
type Effect2223 struct{ node.EffectNode }
type Effect2223 struct {
node.EffectNode
opponentSwitched bool
}
func (e *Effect2223) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
e.opponentSwitched = false
ourAction := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if ourAction == nil || ourAction.SkillEntity == nil {
return true
}
if oppAction := actionByPlayer(fattack, sattack, e.Ctx().Opp.UserID); oppAction != nil {
return true
}
e.opponentSwitched = e.Ctx().Opp != nil && e.Ctx().Opp.CanChange == 1
return true
}
func (e *Effect2223) Damage_Mul(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) == 0 {
return true
}
if e.Ctx().Opp.CurrentPet != nil && e.Ctx().Opp.CurrentPet.Info.Hp <= 0 {
if e.opponentSwitched {
zone.Damage = zone.Damage.Mul(hundred.Add(e.Args()[0])).Div(hundred)
}
return true
}
// Effect 2224: 若对手当回合选择属性技能则造成伤害提升
type Effect2224 struct{ node.EffectNode }
type Effect2224 struct {
node.EffectNode
oppSelectedStatus bool
}
func (e *Effect2224) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
e.oppSelectedStatus = false
oppAction := actionByPlayer(fattack, sattack, e.Ctx().Opp.UserID)
if oppAction == nil || oppAction.SkillEntity == nil {
return true
}
e.oppSelectedStatus = oppAction.SkillEntity.Category() == info.Category.STATUS
return true
}
func (e *Effect2224) Damage_Mul(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) == 0 {
return true
}
if e.Ctx().Opp.AttackTime == 0 {
if e.oppSelectedStatus {
zone.Damage = zone.Damage.Mul(hundred.Add(e.Args()[0])).Div(hundred)
}
return true

View File

@@ -0,0 +1,199 @@
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 780: {0}回合内受到攻击则{1}%令对手随机{2}个技能PP值归零
type Effect780 struct {
node.EffectNode
}
func (e *Effect780) Skill_Use() bool {
if len(e.Args()) < 3 {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 780, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect780Sub struct {
RoundEffectArg0Base
}
func (e *Effect780Sub) Skill_Use_ex() bool {
if len(e.Args()) < 3 || e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
success, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100)
if !success {
return true
}
zeroRandomSkillPP(e.Ctx().Opp, int(e.Args()[2].IntPart()))
return true
}
// Effect 781: 消除对手回合类效果,消除成功则{0}回合内令对手使用的属性技能无效
type Effect781 struct {
node.EffectNode
}
func (e *Effect781) Skill_Use() bool {
if len(e.Args()) == 0 {
return true
}
before := activeTurnEffectCount(e.Ctx().Opp)
e.Ctx().Opp.CancelTurn(e.Ctx().Our)
if before <= 0 {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 781, int(e.Args()[0].IntPart()))
if effect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect781Sub struct {
RoundEffectArg0Base
}
func (e *Effect781Sub) ActionStart(a, b *action.SelectSkillAction) bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() != info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.SetMiss()
return true
}
// Effect 782: {0}%令对手{1},每次使用概率增加{2}%,最高概率{3}%
type Effect782 struct {
node.EffectNode
useCount int
}
func (e *Effect782) OnSkill() bool {
if len(e.Args()) < 4 {
return true
}
chance := int(e.Args()[0].IntPart()) + e.useCount*int(e.Args()[2].IntPart())
maxChance := int(e.Args()[3].IntPart())
if chance > maxChance {
chance = maxChance
}
success, _, _ := e.Input.Player.Roll(chance, 100)
e.useCount++
if !success {
return true
}
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart()))
return true
}
// Effect 783: {0}回合内自身能力提升状态被消除或吸取时附加对手最大体力1/{1}的百分比伤害
type Effect783 struct {
node.EffectNode
}
func (e *Effect783) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 783, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect783Sub struct {
RoundEffectArg0Base
triggered bool
}
func (e *Effect783Sub) PropBefer(in *input.Input, prop int8, level int8) bool {
if len(e.Args()) < 2 || in != e.Ctx().Our || e.triggered {
return true
}
if int(prop) < 0 || int(prop) >= len(e.Ctx().Our.Prop) {
return true
}
if level > 0 || e.Ctx().Our.Prop[prop] <= 0 || e.Args()[1].Cmp(alpacadecimal.Zero) <= 0 {
return true
}
damage := e.Ctx().Opp.CurrentPet.GetMaxHP().Div(e.Args()[1])
if damage.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.triggered = true
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Percent,
Damage: damage,
})
return true
}
func (e *Effect783Sub) Action_end() bool {
e.triggered = false
return true
}
func (e *Effect783Sub) Action_end_ex() bool {
e.triggered = false
return true
}
// Effect 784: 若本回合击败对手则将对手的能力提升效果转移到自己身上
type Effect784 struct {
node.EffectNode
}
func (e *Effect784) Skill_Use() bool {
if e.Ctx().Opp.CurrentPet.Info.Hp > 0 {
return true
}
for i, v := range e.Ctx().Opp.Prop[:] {
if v <= 0 {
continue
}
if e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), 0) {
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v)
}
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 780, &Effect780{})
input.InitEffect(input.EffectType.Sub, 780, &Effect780Sub{})
input.InitEffect(input.EffectType.Skill, 781, &Effect781{})
input.InitEffect(input.EffectType.Sub, 781, &Effect781Sub{})
input.InitEffect(input.EffectType.Skill, 782, &Effect782{})
input.InitEffect(input.EffectType.Skill, 783, &Effect783{})
input.InitEffect(input.EffectType.Sub, 783, &Effect783Sub{})
input.InitEffect(input.EffectType.Skill, 784, &Effect784{})
}

View File

@@ -0,0 +1,212 @@
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 790: {0}回合内自身所有攻击无视伤害限制效果
type Effect790 struct {
node.EffectNode
}
func (e *Effect790) Skill_Use() bool {
if len(e.Args()) == 0 {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 790, int(e.Args()[0].IntPart()))
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect790Sub struct {
RoundEffectArg0Base
disabled []input.Effect
}
func (e *Effect790Sub) SkillHit() bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
e.disabled = e.disabled[:0]
for _, effect := range e.Ctx().Opp.Effects {
if effect == nil || !effect.Alive() {
continue
}
if _, ok := effect697IgnoredLimitIDs[int(effect.ID().Suffix())]; !ok {
continue
}
effect.Alive(false)
e.disabled = append(e.disabled, effect)
}
return true
}
func (e *Effect790Sub) Skill_Use() bool {
restoreTemporarilyDisabledEffects(e.disabled)
e.disabled = e.disabled[:0]
return true
}
func (e *Effect790Sub) Action_end() bool {
restoreTemporarilyDisabledEffects(e.disabled)
e.disabled = e.disabled[:0]
return true
}
// Effect 791: {0}回合内每回合使用技能恢复自身最大体力的1/{1},恢复体力时若自身当前体力低于对手则恢复效果翻倍
type Effect791 struct {
node.EffectNode
}
func (e *Effect791) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 791, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect791Sub struct {
RoundEffectArg0Base
}
func (e *Effect791Sub) Skill_Use() bool {
if len(e.Args()) < 2 || e.Ctx().SkillEntity == nil || e.Args()[1].Cmp(alpacadecimal.Zero) <= 0 {
return true
}
heal := e.Ctx().Our.CurrentPet.GetMaxHP().Div(e.Args()[1])
if e.Ctx().Our.CurrentPet.GetHP().Cmp(e.Ctx().Opp.CurrentPet.GetHP()) < 0 {
heal = heal.Mul(alpacadecimal.NewFromInt(2))
}
if heal.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, heal)
return true
}
// Effect 792: 先出手时对手当回合攻击技能无效
type Effect792 struct {
node.EffectNode
}
func (e *Effect792) Skill_Use() bool {
if !e.IsFirst() {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 792, 1)
if effect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect792Sub struct {
FixedDuration1Base
}
func (e *Effect792Sub) ActionStart(a, b *action.SelectSkillAction) bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.SetMiss()
return true
}
// Effect 793: 若造成的伤害低于{0},则下{1}回合每回合造成{2}点固定伤害
type Effect793 struct {
node.EffectNode
}
func (e *Effect793) Skill_Use() bool {
if len(e.Args()) < 3 || e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().Our.SumDamage.Cmp(e.Args()[0]) >= 0 {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 793, int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect793Sub struct {
RoundEffectArg0Base
}
func (e *Effect793Sub) TurnEnd() {
if len(e.Args()) >= 2 && e.Ctx().Opp.CurrentPet != nil && e.Ctx().Opp.CurrentPet.Info.Hp > 0 {
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: e.Args()[1],
})
}
e.EffectNode.TurnEnd()
}
// Effect 794: 消除对手能力提升,消除成功可以抵挡{0}回合内对手的攻击伤害
type Effect794 struct {
node.EffectNode
}
func (e *Effect794) Skill_Use() bool {
if len(e.Args()) == 0 || !clearPositiveProps(e.Ctx().Opp, e.Ctx().Our) {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 794, int(e.Args()[0].IntPart()))
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect794Sub struct {
RoundEffectArg0Base
}
func (e *Effect794Sub) DamageLockEx(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red {
return true
}
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
zone.Damage = alpacadecimal.Zero
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 790, &Effect790{})
input.InitEffect(input.EffectType.Sub, 790, &Effect790Sub{})
input.InitEffect(input.EffectType.Skill, 791, &Effect791{})
input.InitEffect(input.EffectType.Sub, 791, &Effect791Sub{})
input.InitEffect(input.EffectType.Skill, 792, &Effect792{})
input.InitEffect(input.EffectType.Sub, 792, &Effect792Sub{})
input.InitEffect(input.EffectType.Skill, 793, &Effect793{})
input.InitEffect(input.EffectType.Sub, 793, &Effect793Sub{})
input.InitEffect(input.EffectType.Skill, 794, &Effect794{})
input.InitEffect(input.EffectType.Sub, 794, &Effect794Sub{})
}

View File

@@ -507,6 +507,26 @@ var effectInfoByID = map[int]string{
766: "消除对手能力提升状态,消除成功则{0}回合内对手造成的攻击伤害不超过{1}点",
767: "{0}回合内每回合使用技能且出手流程结束后若对手处于能力下降状态则附加给对手{1}点固定伤害",
768: "对手每处于一种异常状态则附加{0}点固定伤害",
774: "若自身当前体力高于对手则附加对手最大体力1/{0}的百分比伤害",
775: "{0}回合内若受到的伤害大于{1},则恢复自身所有体力",
777: "消除对手能力上升状态,消除成功下{0}回合必定先出手",
778: "反转对手的能力提升状态,反转成功则恢复自身所有体力",
779: "若对手处于能力提升状态则先制+2",
780: "{0}回合内受到攻击则{1}%令对手随机{2}个技能PP值归零",
781: "消除对手回合类效果,消除成功则{0}回合内令对手使用的属性技能无效",
782: "{0}%令对手{1},每次使用概率增加{2}%,最高概率{3}%",
783: "{0}回合内自身能力提升状态被消除或吸取时附加对手最大体力1/{1}的百分比伤害",
784: "若本回合击败对手则将对手的能力提升效果转移到自己身上",
785: "若自身攻击对手时克制关系为微弱则先制+2",
786: "令对手随机进入{0}种异常状态",
787: "{0}回合内使用技能后若对手处于能力提升状态则附加对手最大体力1/{1}的百分比伤害",
788: "消除对手能力提升,消除成功{0}回合内免疫异常状态",
789: "消除对手回合类效果,消除成功对手下{0}回合受到的伤害翻倍",
790: "{0}回合内自身所有攻击无视伤害限制效果",
791: "{0}回合内每回合使用技能恢复自身最大体力的1/{1},恢复体力时若自身当前体力低于对手则恢复效果翻倍",
792: "先出手时对手当回合攻击技能无效",
793: "若造成的伤害低于{0},则下{1}回合每回合造成{2}点固定伤害",
794: "消除对手能力提升,消除成功可以抵挡{0}回合内对手的攻击伤害",
841: "使对手和自身同时降低1/{0}最大体力",
842: "若自身处于能力提升状态则造成的攻击伤害额外提升{0}%",