配置解析优化

This commit is contained in:
meixiongfeng 2022-10-25 10:30:48 +08:00
parent b3d7379f75
commit 62d7a63f53
3 changed files with 21 additions and 42 deletions

View File

@ -106,9 +106,7 @@ func (this *MCompConfigure) GetGlobalInitConf() (configure *cfg.GameInitial, err
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_initial); err != nil {
return
} else {
if v, err = this.GetConfigure(game_initial); err == nil {
if configure, ok = v.(*cfg.GameInitial); !ok {
err = fmt.Errorf("%T no is *cfg.Game_comInitial", v)
return
@ -122,15 +120,13 @@ func (this *MCompConfigure) GetGlobalAtnConf(key string) *cfg.GameComAtnData {
configure *cfg.GameComAtn
ok bool
)
if v, err := this.GetConfigure(game_comatn); err != nil {
return nil
} else {
if configure, ok = v.(*cfg.GameComAtn); !ok {
err = fmt.Errorf("%T no is *cfg.Game_comatn", v)
return nil
if v, err := this.GetConfigure(game_comatn); err == nil {
if configure, ok = v.(*cfg.GameComAtn); ok {
return configure.Get(key)
}
}
return configure.Get(key)
fmt.Errorf("%T no is *cfg.GameComAtnData", key)
return nil
}
// 主角等级经验配置列表
@ -241,7 +237,7 @@ func (this *MCompConfigure) GetColor(id int32) (item *cfg.GameGameColorData, err
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_gamecolor); err != nil {
if v, err = this.GetConfigure(game_gamecolor); err == nil {
return
} else {
if item, ok = v.(*cfg.GameGameColor).GetDataMap()[id]; !ok {

View File

@ -149,7 +149,6 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
_hero.HeroID = hid
_heroMap["heroID"] = _hero.HeroID
}
}
// 保存数据
err := this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)

View File

@ -109,8 +109,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
err = fmt.Errorf("%T no is *cfg.Game_drawCard", v)
}
})
hid := this.GetHeroSpriteStar("43901")
fmt.Printf("%s", hid)
return
}
@ -360,7 +359,6 @@ func (this *configureComp) GetHeroSkillMaxLvConfig(skillId uint32) int32 {
if v, err := this.GetConfigure(game_skillatk); err == nil {
if configure, ok := v.(*cfg.GameSkillAtk); ok {
//return configure.Get(int32(skillId)).MaxLV
for _, v1 := range configure.GetDataList() {
if v1.Id == int32(skillId) {
return v1.MaxLV
@ -377,16 +375,12 @@ func (this *configureComp) GetHeroResonanceRestConfig() (data *cfg.GameComAtnDat
v interface{}
)
if v, err = this.GetConfigure(hero_comatn); err == nil {
if configure, ok := v.(*cfg.GameComAtn); !ok {
err = fmt.Errorf("%T no is *cfg.GamecomAtn", v)
return
} else {
if configure, ok := v.(*cfg.GameComAtn); ok {
data = configure.Get("hero_reset")
return
}
} else {
err = fmt.Errorf("%T no is *cfg.game_comatn", v)
}
this.module.Errorf("cfg.GameComAtnData GetHeroResonanceRestConfig:id = hero_reset")
return
}
@ -394,43 +388,33 @@ func (this *configureComp) GetHeroResonanceRestConfig() (data *cfg.GameComAtnDat
func (this *configureComp) GetHeroFucionConfig(cid string) (data *cfg.GameHerofusionData) {
if v, err := this.GetConfigure(hero_fusion); err == nil {
if configure, ok := v.(*cfg.GameHerofusion); !ok {
err = fmt.Errorf("%T no is *cfg.GameHerofusionData", v)
return
} else {
if configure, ok := v.(*cfg.GameHerofusion); ok {
data = configure.Get(cid)
return
}
} else {
err = fmt.Errorf("%T no is *cfg.GameHerofusionData", v)
}
this.module.Errorf("cfg.GameHerofusionData GetHeroFucionConfig:id = %s", cid)
return
}
func (this *configureComp) GetHeroSpriteStar(cid string) (hid string) {
if v, err := this.GetConfigure(hero_starupsp); err == nil {
if configure, ok := v.(*cfg.GameHeroStarupSp); !ok {
err = fmt.Errorf("%T no is *cfg.GameHerofusionData", v)
return
} else {
hid = configure.Get(cid).Starid
return
}
} else {
err = fmt.Errorf("%T no is *cfg.GameHerofusionData", v)
}
return
this.module.Errorf("cfg.GameHeroStarupSpData GetHeroSpriteStar:id = %s", cid)
return ""
}
func (this *configureComp) GetHeroTalent(id int32) (data *cfg.GameHeroTalentData) {
if v, err := this.GetConfigure(hero_talent); err == nil {
if configure, ok := v.(*cfg.GameHeroTalent); !ok {
err = fmt.Errorf("%T no is *cfg.GameHerofusionData", v)
return
} else {
if configure, ok := v.(*cfg.GameHeroTalent); ok {
data = configure.Get(id)
return
}
} else {
err = fmt.Errorf("%T no is *cfg.GameHerofusionData", v)
}
return
this.module.Errorf("cfg.GameHeroTalentData GetHeroTalent:id = %d", id)
return nil
}