```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

feat(effect): 移除effect435并重构为selfkill模块

移除独立的effect435实现文件,并将该效果重新实现在selfkill.go中。
effect435功能为牺牲自己使下回合出场精灵首次攻击必定命中和先手。

fix(effect): 修复effect457技能复制逻辑并添加回合结束处理

修复effect457在组队对战中的技能复制逻辑问题,添加deepcopy依赖,
并在回合结束时恢复原始技能状态。

refactor(fight): 调整战斗
This commit is contained in:
昔念
2026-03-10 09:17:26 +08:00
parent c357773647
commit 939ef29800
11 changed files with 199 additions and 180 deletions

View File

@@ -0,0 +1,31 @@
package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 197 - n回合内若被对方击败则对手所有能力加强状态消失
type Effect197 struct {
node.EffectNode
}
func (e *Effect197) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(a[0]) // 持续n回合
}
func (e *Effect197) SwitchOut(in *input.Input) bool {
if e.Ctx().Our.CurrentPet.NotAlive { // 被击败
for i, v := range e.Ctx().Opp.Prop[:] {
if v > 0 {
e.Ctx().Opp.SetProp(e.Ctx().Opp, int8(i), 0)
}
}
}
return true
}
func init() {
input.InitEffect(input.EffectType.NewSel, 197, &Effect197{})
}

View File

@@ -0,0 +1,29 @@
package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 199 - 下次被击败后下一个出场的精灵xx等级+k
type Effect199 struct {
node.EffectNode
}
func (e *Effect199) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(-1) // 持续n回合
}
func (e *Effect199) SwitchOut(in *input.Input) bool {
if e.Ctx().Our.CurrentPet.NotAlive { // 被击败
// 设置下一个出场精灵的增益效果
effectType := int8(e.Args()[0].IntPart()) // xx类型
effectValue := int8(e.Args()[1].IntPart()) // 等级+k
e.Ctx().Our.SetProp(e.Ctx().Our, effectType, effectValue)
}
return true
}
func init() {
input.InitEffect(input.EffectType.NewSel, 199, &Effect199{})
}

View File

@@ -1,82 +0,0 @@
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"
)
// 435 - 牺牲自己,使下回合出场的精灵首次攻击必定命中,必定先手
type Effect435 struct {
node.EffectNode
can bool
can2 bool
}
func (e *Effect435) SetArgs(t *input.Input, a ...int) {
//e.CanStack(-1)//后续的不会顶掉这个效果
e.EffectNode.SetArgs(t, a...)
e.Duration(-1) //次数类,无限回合
}
// 命中之后
func (e *Effect435) OnSkill() bool {
e.can = 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.Ctx().Our.CurrentPet.NotAlive = true
return true
}
func (e *Effect435) SwitchOut(in *input.Input) bool {
return true
}
func (e *Effect435) SwitchIn(in *input.Input) bool {
// 1. 检查效果是否生效(当次攻击有效)
if !e.can {
return true
}
//
if in != e.Ctx().Our {
return true
}
e.can2 = true
return true
}
func (e *Effect435) ComparePre(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
if !e.can2 {
return true
}
if fattack == nil {
return true
}
//先手是自己
if fattack.PlayerID == e.Ctx().Our.UserID {
return true
}
if sattack == nil {
return true
}
if sattack == nil {
return true
}
if sattack.SkillEntity == nil {
return true
}
//对调
sattack.SkillEntity.XML.Priority += 7
e.Alive(false)
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 435, &Effect435{})
}

View File

@@ -2,13 +2,18 @@ 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/barkimedes/go-deepcopy"
)
// 457 - 复制对手释放的技能(组队对战时无效)
type Effect457 struct {
node.EffectNode
org *info.SkillEntity
reid int
}
func (e *Effect457) ComparePre(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
@@ -19,18 +24,41 @@ func (e *Effect457) ComparePre(fattack *action.SelectSkillAction, sattack *actio
//先手是自己
if fattack.PlayerID == e.Ctx().Our.UserID {
if sattack != nil {
fattack.Accuracy = sattack.SkillEntity.Accuracy
originalSkill, _ := deepcopy.Anything(sattack.SkillEntity) //备份技能
originalSkill.(*info.SkillEntity).Accuracy = sattack.SkillEntity.Accuracy
e.reid = sattack.SkillEntity.XML.ID
fattack.SkillEntity = originalSkill.(*info.SkillEntity)
} else {
fattack = nil
}
} else {
if fattack != nil {
e.org = sattack.SkillEntity
originalSkill, _ := deepcopy.Anything(fattack.SkillEntity) //备份技能
originalSkill.(*info.SkillEntity).Accuracy = fattack.SkillEntity.Accuracy
e.reid = fattack.SkillEntity.XML.ID
sattack.SkillEntity = originalSkill.(*info.SkillEntity)
} else {
sattack = nil
}
}
return true
}
func (e *Effect457) TurnEnd() {
for _, v := range e.Ctx().Our.CurrentPet.Skills {
if v.XML.ID == e.reid {
v = e.org
}
}
}
func init() {
input.InitEffect(input.EffectType.Skill, 457, &Effect457{})

View File

@@ -0,0 +1,29 @@
package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 523 - 若当回合未击败对手则自身1 1 1 1 1 1能力+1
type Effect523 struct {
node.EffectNode
}
func (e *Effect523) Action_end() bool {
// 检查对手是否还活着
if e.Ctx().Opp.CurrentPet.Info.Hp > 0 {
// 提升自身的全部能力等级
for i := 0; i < 6; i++ {
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), int8(e.SideEffectArgs[i]))
}
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 523, &Effect523{})
}

View File

@@ -1,77 +0,0 @@
package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 523 - 若当回合未击败对手则自身1 1 1 1 1 1能力+1
type Effect523 struct {
node.EffectNode
}
func (e *Effect523) Action_end_ex() bool {
// 检查对手是否还活着
if e.Ctx().Opp.CurrentPet.Info.Hp > 0 {
// 提升自身的全部能力等级
stats := []int{
int(info.PetStatus.AtkUp),
int(info.PetStatus.DefUp),
int(info.PetStatus.SpAtkUp),
int(info.PetStatus.SpDefUp),
int(info.PetStatus.SpeedUp),
int(info.PetStatus.AccuracyUp),
}
for _, stat := range stats {
statEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, stat)
if statEffect != nil {
statEffect.SetArgs(e.Ctx().Our, 1) // 提升1级
e.Ctx().Our.AddEffect(e.Ctx().Our, statEffect)
}
}
}
return true
}
// 197 - n回合内若被对方击败则对手所有能力加强状态消失
type Effect197 struct {
node.EffectNode
}
func (e *Effect197) Skill_Use() bool {
if e.Ctx().Our.CurrentPet.Info.Hp <= 0 { // 被击败
// 清除对手的所有能力加强状态
e.Ctx().Opp.RemoveAllPositiveBuffs()
}
return true
}
func (e *Effect197) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(a[0]) // 持续n回合
}
// 199 - 下次被击败后下一个出场的精灵xx等级+k
type Effect199 struct {
node.EffectNode
}
func (e *Effect199) Skill_Use() bool {
if e.Ctx().Our.CurrentPet.Info.Hp <= 0 { // 被击败
// 设置下一个出场精灵的增益效果
effectType := int(e.Args()[0].IntPart()) // xx类型
effectValue := int(e.Args()[1].IntPart()) // 等级+k
buffEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, effectType)
if buffEffect != nil {
buffEffect.SetArgs(e.Ctx().Our, effectValue)
e.Ctx().Our.SetNextPetBuff(buffEffect)
}
}
return true
}

View File

@@ -16,7 +16,7 @@ type Effect46 struct {
conut int64
}
func (e *Effect46) DamageDivEx(t *info.DamageZone) bool {
func (e *Effect46) Damage_Shield(t *info.DamageZone) bool {
if e.Ctx().SkillEntity == nil {
return true

View File

@@ -134,6 +134,56 @@ func (e *Effect144) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
return true
}
// 435 - 牺牲自己,使下回合出场的精灵首次攻击必定命中,必定先手
type Effect435 struct {
SelfKill
}
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 == 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
}
//fmt.Println(e.Ctx().SkillEntity)
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
}
func init() {
input.InitEffect(input.EffectType.Skill, 435, &Effect435{})
}
/**
* 牺牲全部体力造成对手250~300点伤害造成致命伤害时对手剩下1点体力
*/

View File

@@ -271,19 +271,19 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
return true
})
}
//技能使用后
attacker.Exec(func(effect input.Effect) bool { //技能使用后的我方效果
effect.Ctx().SkillEntity = currentSkill
effect.Action_end()
return true
})
//技能使用后
defender.Exec(func(effect input.Effect) bool { //技能使用后的我方效果
effect.Ctx().SkillEntity = currentSkill
effect.Action_end_ex()
return true
})
//技能使用后
attacker.Exec(func(effect input.Effect) bool { //技能使用后的我方效果
effect.Ctx().SkillEntity = currentSkill
effect.Action_end()
return true
})
if defender.CurrentPet.Info.Hp <= 0 && attacker.CurrentPet.Info.Hp <= 0 { //先手方死亡,触发反同归于尽
attacker.CurrentPet.Info.Hp = 1
}

View File

@@ -134,16 +134,6 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) {
return true
})
}
// sub.BeforeLock = sub.Damage
if ok && in != our {
ok = our.Opp.Exec(func(t Effect) bool {
t.DamageLock(sub)
return true
})
}
//sub.BeforeLocked = sub.Damage
if ok {
our.Exec(func(t Effect) bool {
@@ -153,10 +143,31 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) {
return true
})
}
// sub.BeforeLock = sub.Damage
if ok && in != our {
ok = our.Opp.Exec(func(t Effect) bool {
t.DamageLock(sub)
return true
})
}
if sub.Type == info.DamageType.Red { //红才会产生造成伤害
our.Opp.SumDamage = sub.Damage.Add(our.Opp.SumDamage) // 叠加总伤害 这里相当于记录红伤
}
if ok {
our.Exec(func(t Effect) bool {
t.Damage_Shield(sub)
return true
})
}
if sub.Type == info.DamageType.Red { //红才会产生造成伤害
our.AttackValue.LostHp += uint32(sub.Damage.IntPart()) //红伤落实
}
if uint32(sub.Damage.IntPart()) > our.CurrentPet.Info.Hp {

View File

@@ -165,7 +165,7 @@ func (our *Input) GenInfo() {
our.RemainHp = int32(our.CurrentPet.Info.Hp)
our.SkillList = our.CurrentPet.Info.SkillList
our.AttackValue.LostHp = uint32(our.SumDamage.IntPart()) //红伤落实
// f.Second.SkillList = f.Second.CurrentPet.Info.SkillList
// f.Second.RemainHp = int32(f.Second.CurrentPet.Info.Hp)
// ret.FAttack = *f.First.AttackValue