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

@@ -60,35 +60,7 @@ func (Controller) PlayerFightBoss(data1 *fight.ChallengeBossInboundInfo, p *play
int(bm.Lv), nil, 0)
monster.CatchTime = uint32(i)
if bm.Hp != 0 {
monster.Hp = uint32(bm.Hp)
monster.MaxHp = uint32(bm.Hp)
}
if len(bm.Prop) == 5 {
monster.Prop = [5]uint32(bm.Prop)
}
if len(bm.SKill) != 0 {
for i := 0; i < 4; i++ {
if bm.SKill[i] != 0 {
monster.SkillList[i].ID = bm.SKill[i]
}
}
}
effects := service.NewEffectService().Args(bm.Effect)
for _, v := range effects {
monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{
Idx: uint16(v.SeIdx),
EID: gconv.Uint16(v.Eid),
Args: gconv.Ints(v.Args),
})
}
monster.ConfigBoss(bm.PetBaseConfig)
monsterInfo.PetList = append(monsterInfo.PetList, *monster)
}

View File

@@ -27,10 +27,19 @@ func (e *Effect439) SetArgs(t *input.Input, a ...int) {
}
func (e *Effect439) Action_end() bool {
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
var isprop bool
for _, v := range e.Ctx().Our.Prop {
if v < 0 {
isprop = true
}
}
if e.Ctx().Our.StatEffect_Exist_all() || isprop {
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: e.Args()[1],
})
}
return true
}

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:
}

View File

@@ -5,7 +5,9 @@ import (
"blazing/common/data/xmlres"
"blazing/common/utils"
"blazing/cool"
"encoding/json"
"blazing/modules/config/model"
"blazing/modules/config/service"
"errors"
"fmt"
@@ -118,6 +120,50 @@ type PetInfo struct {
ExtSkin []uint32 `struc:"skip"` //可用皮肤
}
func (pet *PetInfo) ConfigBoss(bm model.PetBaseConfig) {
var color data.GlowFilter
err := json.Unmarshal([]byte(bm.Color), &color)
if err == nil && color.Alpha != 0 {
pet.ShinyInfo = append(pet.ShinyInfo, color)
}
if bm.Hp != 0 {
pet.Hp = uint32(bm.Hp)
pet.MaxHp = uint32(bm.Hp)
}
if len(bm.Prop) == 5 {
for i := 0; i < 5; i++ {
if bm.Prop[i] != 0 {
pet.Prop[i] = bm.Prop[i]
}
}
//monster.Prop = [5]uint32(bm.Prop)
}
if len(bm.SKill) != 0 {
for i := 0; i < 4; i++ {
if bm.SKill[i] != 0 {
pet.SkillList[i].ID = bm.SKill[i]
}
}
}
effects := service.NewEffectService().Args(bm.Effect)
for _, v := range effects {
pet.EffectInfo = append(pet.EffectInfo, PetEffectInfo{
Idx: uint16(v.SeIdx),
EID: gconv.Uint16(v.Eid),
Args: gconv.Ints(v.Args),
})
}
}
func (pet *PetInfo) Type() int {
return xmlres.PetMAP[int(pet.ID)].Type