refactor: 重构宠物初始化逻辑
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

提取宠物配置初始化到ConfigBoss方法,简化initplayer代码
This commit is contained in:
xinian
2026-03-07 11:30:17 +08:00
committed by cnb
parent 2dab20653f
commit bbaa71f4b2
4 changed files with 59 additions and 69 deletions

View File

@@ -1,12 +1,10 @@
package fight
import (
"blazing/common/data"
"blazing/common/socket/errorcode"
"blazing/common/utils"
config "blazing/modules/config/model"
"blazing/modules/player/model"
"encoding/json"
"blazing/logic/service/common"
"blazing/logic/service/fight/action"
@@ -177,49 +175,14 @@ func (f *FightC) initplayer(c common.PlayerI) (*input.Input, errorcode.ErrorCode
}
pet := model.GenPetInfo(int(v.MonID), 24, int(v.Nature), int(v.Effect[0]), int(v.Lv), nil, 0)
var color data.GlowFilter
err := json.Unmarshal([]byte(v.Color), &color)
if err == nil && color.Alpha != 0 {
pet.ShinyInfo = append(pet.ShinyInfo, color)
}
if len(v.Prop) == 5 {
pet.Prop = [5]uint32(v.Prop)
}
if v.Hp != 0 {
pet.MaxHp = uint32(v.Hp)
}
if len(v.SKill) != 0 {
for i := 0; i < 4; i++ {
if v.SKill[i] != 0 {
pet.SkillList[i].ID = v.SKill[i]
}
}
}
pet.ConfigBoss(v)
pet.CatchTime = c.GetInfo().UserID + uint32(i)*1000000
pet.Cure()
in.AllPet = append(in.AllPet, info.CreateBattlePetEntity(*pet, f.rand))
}
// for i, v := range meetpet {
// v1 := v
// if len(in.AllPet) > 2 {
// break
// }
// v1.CatchTime = c.GetInfo().UserID + uint32(i)*1000000
// v1.Cure()
// in.AllPet = append(in.AllPet, info.CreateBattlePetEntity(v1, f.rand))
// }
//in.AllPet = in.AllPet[:3]
default:
}