```
feat(fight): 实现精灵大乱斗模式并优化对战逻辑 新增大乱斗模式(PET_MELEE)支持,重构原有精灵王之战相关逻辑。 更新战斗初始化流程,添加随机精灵选择机制。 调整玩家匹配与取消邀请接口实现方式。 完善战斗结束处理函数,移除未实现异常抛出。 ```
This commit is contained in:
@@ -2,6 +2,7 @@ package input
|
||||
|
||||
import (
|
||||
"blazing/common/data/xmlres"
|
||||
"sort"
|
||||
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/fight/action"
|
||||
@@ -56,6 +57,29 @@ func NewInput(c common.FightI, p common.PlayerI) *Input {
|
||||
return ret
|
||||
|
||||
}
|
||||
|
||||
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 {
|
||||
v.NotAlive = true
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
func (our *Input) GetPetInfo() *info.BattlePetEntity {
|
||||
|
||||
return our.CurrentPet
|
||||
@@ -66,6 +90,7 @@ func (our *Input) SetOPP(t *Input) {
|
||||
our.Opp = t
|
||||
|
||||
}
|
||||
|
||||
func (our *Input) GenSataus() {
|
||||
our.Status = [20]int8{}
|
||||
for i := 0; i < 20; i++ { //堆叠状态剩余回合
|
||||
|
||||
Reference in New Issue
Block a user