feat: 添加战斗效果800-814及优化道具逻辑
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed

This commit is contained in:
xinian
2026-03-31 06:51:40 +08:00
committed by cnb
parent 8552eb61a8
commit b4a8048b85
7 changed files with 841 additions and 99 deletions

View File

@@ -0,0 +1,291 @@
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 800: {0}回合内若对手使用属性技能,则下{1}回合自身受到的伤害不超过{2}
type Effect800 struct {
node.EffectNode
}
func (e *Effect800) Skill_Use() bool {
if len(e.Args()) < 3 {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 800, 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 Effect800Sub struct {
node.EffectNode
watchRounds int
capRounds int
capDamage alpacadecimal.Decimal
}
func (e *Effect800Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.Duration(-1)
if len(a) > 0 {
e.watchRounds = a[0]
}
if len(a) > 1 {
e.capRounds = 0
}
if len(a) > 2 {
e.capDamage = alpacadecimal.NewFromInt(int64(a[2]))
}
}
func (e *Effect800Sub) Skill_Use_ex() bool {
if e.watchRounds <= 0 || len(e.Args()) < 3 || e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.Category() != info.Category.STATUS {
return true
}
e.capRounds = int(e.Args()[1].IntPart())
return true
}
func (e *Effect800Sub) DamageLockEx(zone *info.DamageZone) bool {
if e.capRounds <= 0 || zone == nil || zone.Type != info.DamageType.Red {
return true
}
if zone.Damage.Cmp(e.capDamage) <= 0 {
return true
}
zone.Damage = e.capDamage
return true
}
func (e *Effect800Sub) TurnEnd() {
if e.watchRounds > 0 {
e.watchRounds--
}
if e.capRounds > 0 {
e.capRounds--
}
if e.watchRounds <= 0 && e.capRounds <= 0 {
e.Alive(false)
}
}
// Effect 801: 消除对手能力提升,消除成功则下{0}回合必定先出手、下{1}回合造成的伤害恢复自身体力
type Effect801 struct {
node.EffectNode
}
func (e *Effect801) Skill_Use() bool {
if len(e.Args()) < 2 || !clearPositiveProps(e.Ctx().Opp, e.Ctx().Our) {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 801, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect801Sub struct {
node.EffectNode
priorityRounds int
drainRounds int
}
func (e *Effect801Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.Duration(-1)
if len(a) > 0 {
e.priorityRounds = a[0]
}
if len(a) > 1 {
e.drainRounds = a[1]
}
}
func (e *Effect801Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
if e.priorityRounds <= 0 {
return true
}
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
if current == nil || current.SkillEntity == nil {
return true
}
current.SkillEntity.XML.Priority = 999999
return true
}
func (e *Effect801Sub) Action_end() bool {
if e.drainRounds <= 0 || e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().Our.SumDamage.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.SumDamage)
return true
}
func (e *Effect801Sub) TurnEnd() {
if e.priorityRounds > 0 {
e.priorityRounds--
}
if e.drainRounds > 0 {
e.drainRounds--
}
if e.priorityRounds <= 0 && e.drainRounds <= 0 {
e.Alive(false)
}
}
// Effect 802: {0}回合内免疫控制类异常状态
type Effect802 struct {
RoundEffectArg0Base
}
func (e *Effect802) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
if in != e.Ctx().Opp || !input.IS_Stat(effEffect) {
return true
}
if !isControlStatus800(statusIDFromEffect800(effEffect)) {
return true
}
return false
}
func statusIDFromEffect800(eff input.Effect) int {
if eff == nil {
return 0
}
return int(eff.ID().Suffix())
}
func isControlStatus800(statusID int) bool {
switch info.EnumPetStatus(statusID) {
case info.PetStatus.Paralysis,
info.PetStatus.Tired,
info.PetStatus.Fear,
info.PetStatus.Petrified,
info.PetStatus.Sleep:
return true
default:
return false
}
}
// Effect 803: 命中后{0}%令对手{1}未触发则恢复自身最大体力的1/{2}体力且{3}回合内自身受到的伤害不超过{4}
type Effect803 struct {
node.EffectNode
}
func (e *Effect803) OnSkill() bool {
if len(e.Args()) < 5 {
return true
}
success, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100)
if success {
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart()))
return true
}
if e.Args()[2].Cmp(alpacadecimal.Zero) > 0 {
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.CurrentPet.GetMaxHP().Div(e.Args()[2]))
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 803, int(e.Args()[3].IntPart()), int(e.Args()[4].IntPart()))
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect803Sub struct {
RoundEffectArg0Base
}
func (e *Effect803Sub) DamageLockEx(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 2 {
return true
}
if zone.Damage.Cmp(e.Args()[1]) <= 0 {
return true
}
zone.Damage = e.Args()[1]
return true
}
// Effect 804: {0}回合内自身能力提升状态被消除或吸取时,令对手全属性-{1}
type Effect804 struct {
node.EffectNode
}
func (e *Effect804) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 804, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect804Sub struct {
RoundEffectArg0Base
triggered bool
}
func (e *Effect804Sub) 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 {
return true
}
e.triggered = true
applyAllPropDown(e.Ctx().Our, e.Ctx().Opp, int8(e.Args()[1].IntPart()))
return true
}
func (e *Effect804Sub) Action_end() bool {
e.triggered = false
return true
}
func (e *Effect804Sub) Action_end_ex() bool {
e.triggered = false
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 800, &Effect800{})
input.InitEffect(input.EffectType.Sub, 800, &Effect800Sub{})
input.InitEffect(input.EffectType.Skill, 801, &Effect801{})
input.InitEffect(input.EffectType.Sub, 801, &Effect801Sub{})
input.InitEffect(input.EffectType.Skill, 802, &Effect802{})
input.InitEffect(input.EffectType.Skill, 803, &Effect803{})
input.InitEffect(input.EffectType.Sub, 803, &Effect803Sub{})
input.InitEffect(input.EffectType.Skill, 804, &Effect804{})
input.InitEffect(input.EffectType.Sub, 804, &Effect804Sub{})
}

View File

@@ -0,0 +1,145 @@
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 805: 消除对手能力提升状态,消除成功则令对手随机{0}项技能PP值归零
type Effect805 struct {
node.EffectNode
}
func (e *Effect805) Skill_Use() bool {
if len(e.Args()) == 0 || !clearPositiveProps(e.Ctx().Opp, e.Ctx().Our) {
return true
}
zeroRandomSkillPP(e.Ctx().Opp, int(e.Args()[0].IntPart()))
return true
}
// Effect 806: {0}回合内若对手使用攻击技能则使用后令自身全属性+{1}
type Effect806 struct {
node.EffectNode
}
func (e *Effect806) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 806, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect806Sub struct {
RoundEffectArg0Base
}
func (e *Effect806Sub) Skill_Use_ex() bool {
if len(e.Args()) < 2 || e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
applyAllPropUp(e.Ctx().Our, int8(e.Args()[1].IntPart()))
return true
}
// Effect 807: 附加对手上次造成伤害数值的固定伤害
type Effect807 struct {
node.EffectNode
}
func (e *Effect807) OnSkill() bool {
if e.Ctx().Opp.SumDamage.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: e.Ctx().Opp.SumDamage,
})
return true
}
// Effect 808: 自身每处于一种能力提升状态则附加{0}点固定伤害
type Effect808 struct {
node.EffectNode
}
func (e *Effect808) OnSkill() bool {
if len(e.Args()) == 0 {
return true
}
count := 0
for _, v := range e.Ctx().Our.Prop[:] {
if v > 0 {
count++
}
}
if count <= 0 {
return true
}
damage := e.Args()[0].Mul(alpacadecimal.NewFromInt(int64(count)))
if damage.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: damage,
})
return true
}
// Effect 809: 使对手下次使用的攻击技能失效
type Effect809 struct {
node.EffectNode
}
func (e *Effect809) Skill_Use() bool {
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 809)
if effect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect809Sub struct {
node.EffectNode
}
func (e *Effect809Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.Duration(-1)
}
func (e *Effect809Sub) ActionStart(a, b *action.SelectSkillAction) bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.SetMiss()
e.Alive(false)
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 805, &Effect805{})
input.InitEffect(input.EffectType.Skill, 806, &Effect806{})
input.InitEffect(input.EffectType.Sub, 806, &Effect806Sub{})
input.InitEffect(input.EffectType.Skill, 807, &Effect807{})
input.InitEffect(input.EffectType.Skill, 808, &Effect808{})
input.InitEffect(input.EffectType.Skill, 809, &Effect809{})
input.InitEffect(input.EffectType.Sub, 809, &Effect809Sub{})
}

View File

@@ -0,0 +1,161 @@
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 810: 每次命中对手后此技能威力下降{0}点
type Effect810 struct {
node.EffectNode
powerDown int
skillID int
}
func (e *Effect810) SkillHit() bool {
if len(e.Args()) == 0 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
currentSkillID := e.Ctx().SkillEntity.XML.ID
if e.skillID != 0 && e.skillID != currentSkillID {
e.skillID = 0
e.powerDown = 0
}
e.skillID = currentSkillID
power := e.Ctx().SkillEntity.XML.Power - e.powerDown
if power < 1 {
power = 1
}
e.Ctx().SkillEntity.XML.Power = power
return true
}
func (e *Effect810) Skill_Use() bool {
if len(e.Args()) == 0 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
if e.Ctx().SkillEntity.AttackTime == 0 {
return true
}
e.powerDown += int(e.Args()[0].IntPart())
return true
}
// Effect 811: 使自身下次受到的伤害减少n点n等于本回合自身造成的伤害
type Effect811 struct {
node.EffectNode
}
func (e *Effect811) Skill_Use() bool {
if e.Ctx().Our.SumDamage.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 811, int(e.Ctx().Our.SumDamage.IntPart()))
if effect != nil {
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
}
return true
}
type Effect811Sub struct {
node.EffectNode
}
func (e *Effect811Sub) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.Duration(-1)
}
func (e *Effect811Sub) DamageSubEx(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) == 0 {
return true
}
if zone.Damage.Cmp(e.Args()[0]) > 0 {
zone.Damage = zone.Damage.Sub(e.Args()[0])
} else {
zone.Damage = alpacadecimal.Zero
}
e.Alive(false)
return true
}
// Effect 812: 自身速度能力每提升1段则回合结束时减少对手1/{0}最大体力
type Effect812 struct {
node.EffectNode
}
func (e *Effect812) TurnEnd() {
if len(e.Args()) == 0 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
return
}
if e.Ctx().Our.Prop[4] <= 0 {
return
}
base := e.Ctx().Opp.CurrentPet.GetMaxHP().Div(e.Args()[0])
damage := base.Mul(alpacadecimal.NewFromInt(int64(e.Ctx().Our.Prop[4])))
if damage.Cmp(alpacadecimal.Zero) <= 0 {
return
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Percent,
Damage: damage,
})
}
// Effect 813: 将自身的能力下降状态双倍反馈给对手
type Effect813 struct {
node.EffectNode
}
func (e *Effect813) OnSkill() bool {
for i, v := range e.Ctx().Our.Prop[:] {
if v >= 0 {
continue
}
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), v*2)
}
return true
}
// Effect 814: 先出手时附加自身双防值总和{0}%的百分比伤害
type Effect814 struct {
node.EffectNode
}
func (e *Effect814) OnSkill() bool {
if len(e.Args()) == 0 || !e.IsFirst() {
return true
}
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
totalDefense := e.Ctx().Our.GetProp(1).Add(e.Ctx().Our.GetProp(3))
damage := totalDefense.Mul(e.Args()[0]).Div(hundred)
if damage.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: damage,
})
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 810, &Effect810{})
input.InitEffect(input.EffectType.Skill, 811, &Effect811{})
input.InitEffect(input.EffectType.Sub, 811, &Effect811Sub{})
input.InitEffect(input.EffectType.Skill, 812, &Effect812{})
input.InitEffect(input.EffectType.Skill, 813, &Effect813{})
input.InitEffect(input.EffectType.Skill, 814, &Effect814{})
}