refactor(fight): 优化战斗逻辑代码结构,清理冗余代码
This commit is contained in:
@@ -69,21 +69,22 @@ func (h *Controller) PetRelease(
|
||||
|
||||
switch data.Flag {
|
||||
case 0:
|
||||
var temp []model.PetInfo
|
||||
|
||||
n, v, ok := utils.FindWithIndex(c.Info.PetList, func(item model.PetInfo) bool {
|
||||
return item.CatchTime == data.CatchTime
|
||||
})
|
||||
if ok {
|
||||
c.Service.PetInfo_One_exec(data.CatchTime, func(t *model.PetEX) {
|
||||
t.Data = *v
|
||||
t.InBag = 0
|
||||
for _, v := range c.Info.PetList {
|
||||
if v.CatchTime == uint32(data.CatchTime) {
|
||||
c.Service.PetInfo_One_exec(data.CatchTime, func(t *model.PetEX) {
|
||||
t.Data = v
|
||||
t.InBag = 0
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
c.Info.PetList = append(c.Info.PetList[:n], c.Info.PetList[n+1:]...)
|
||||
} else {
|
||||
temp = append(temp, v)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
c.Info.PetList = temp
|
||||
// break // 只移除第一个匹配值,若需移除所有,可省略 break 继续循环
|
||||
case 1:
|
||||
//todo 背包
|
||||
|
||||
Reference in New Issue
Block a user