fix(fight): 修正空变更导致的潜在逻辑问题
This commit is contained in:
@@ -3,7 +3,6 @@ package input
|
||||
import (
|
||||
"blazing/common/data/xmlres"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/fight/action"
|
||||
@@ -58,33 +57,21 @@ func NewInput(c common.FightI, p common.PlayerI) *Input {
|
||||
|
||||
}
|
||||
|
||||
// 非原地交换:收集非0血量精灵 + 0血量精灵,拼接后返回
|
||||
func (our *Input) SortPet() {
|
||||
sort.Slice(our.AllPet, func(i, j int) bool {
|
||||
x, y := our.AllPet[i], our.AllPet[j]
|
||||
// 若x血量>0且y血量=0,则x排在前
|
||||
if x.Info.Hp > 0 && y.Info.Hp <= 0 {
|
||||
return true
|
||||
}
|
||||
// 若x血量=0且y血量>0,则x排在后
|
||||
if x.Info.Hp <= 0 && y.Info.Hp > 0 {
|
||||
return false
|
||||
}
|
||||
// 同类型(都>0或都=0)保持原有顺序
|
||||
return i < j
|
||||
})
|
||||
for _, v := range our.AllPet {
|
||||
if v.Info.Hp == 0 {
|
||||
var nonZeroHP []*info.BattlePetEntity // 收集血量>0的精灵(保持原顺序)
|
||||
var zeroHP []*info.BattlePetEntity // 收集血量=0的精灵(保持原顺序)
|
||||
|
||||
v.NotAlive = true
|
||||
|
||||
} else {
|
||||
for _, e1 := range v.Info.EffectInfo {
|
||||
// 线性遍历一次,分类收集
|
||||
for _, s := range our.AllPet {
|
||||
if s.HP > 0 {
|
||||
for _, e1 := range s.Info.EffectInfo {
|
||||
t := Geteffect(EffectType.NewSel, e1.EID)
|
||||
if t != nil {
|
||||
ef := t.ID()
|
||||
fmt.Println("初始化特性", ef.Suffix())
|
||||
|
||||
ef.SetCatchTime(v.Info.CatchTime)
|
||||
ef.SetCatchTime(s.Info.CatchTime)
|
||||
|
||||
t.ID(ef)
|
||||
|
||||
@@ -94,10 +81,17 @@ func (our *Input) SortPet() {
|
||||
}
|
||||
|
||||
}
|
||||
nonZeroHP = append(nonZeroHP, s)
|
||||
} else {
|
||||
s.NotAlive = true
|
||||
zeroHP = append(zeroHP, s)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 拼接:非0血量精灵在前,0血量精灵在后
|
||||
our.AllPet = append(nonZeroHP, zeroHP...)
|
||||
}
|
||||
|
||||
func (our *Input) GetPetInfo() *info.BattlePetEntity {
|
||||
|
||||
return our.CurrentPet
|
||||
|
||||
Reference in New Issue
Block a user