diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index 096d5581e..644a076e2 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -13,6 +13,7 @@ import ( "go_dreamfactory/utils" ) +const moduleName = "hero" const ( equip_suit = "game_equipsuit.json" //装备套装表 new_hero = "game_hero.json" //英雄 @@ -139,7 +140,7 @@ func (this *configureComp) GetHeroAwakenConfig(hid string, phase int32) (cfg *cf ) if cfg, ok = this.awakenMap[utils.ToInt64(hid)+int64(phase)<<31]; !ok { par = fmt.Errorf("hid:%s,phase:%d", hid, phase) - err = comm.NewNotFoundConfErr("hero", hero_awaken, par) + err = comm.NewNotFoundConfErr(moduleName, hero_awaken, par) } return } @@ -175,7 +176,7 @@ func (this *configureComp) SetHeroDrawConfig() { func (this *configureComp) GetPollByType(poosType string) (conf map[int32][]*cfg.GameDrawCardData, err error) { var ok bool if conf, ok = this.drawCardCfg[poosType]; !ok { - err = comm.NewNotFoundConfErr("hero", hero_drawcard, poosType) + err = comm.NewNotFoundConfErr(moduleName, hero_drawcard, poosType) } return } @@ -186,14 +187,12 @@ func (this *configureComp) GetHeroExp(hid string) (conf *cfg.GameHeroExpData, er ) if v, err = this.GetConfigure(hero_exp); err == nil { if c, ok := v.(*cfg.GameHeroExp); ok { - if conf = c.Get(hid); conf == nil { - err = comm.NewNotFoundConfErr("hero", hero_exp, hid) + if conf = c.Get(hid); conf != nil { return } } - return } - err = comm.NewNotFoundConfErr("hero", hero_exp, hid) + err = comm.NewNotFoundConfErr(moduleName, hero_exp, hid) return } @@ -204,13 +203,12 @@ func (this *configureComp) GetHeroConfig(heroCfgId string) (conf *cfg.GameHeroDa ) if v, err = this.GetConfigure(new_hero); err == nil { if configure, ok := v.(*cfg.GameHero); ok { - if conf, ok = configure.GetDataMap()[heroCfgId]; !ok { - err = comm.NewNotFoundConfErr("hero", new_hero, heroCfgId) + if conf, ok = configure.GetDataMap()[heroCfgId]; ok { + return } - return } } - err = comm.NewNotFoundConfErr("hero", new_hero, heroCfgId) + err = comm.NewNotFoundConfErr(moduleName, new_hero, heroCfgId) return } @@ -259,13 +257,12 @@ func (this *configureComp) GetHeroSkillUpConfig(skillid int32) (data *cfg.GameHe if v, err = this.GetConfigure(hero_skillup); err == nil { if conf, ok := v.(*cfg.GameHeroSkillLevel); ok { - if data = conf.Get(skillid); data == nil { - err = comm.NewNotFoundConfErr("hero", hero_skillup, skillid) + if data = conf.Get(skillid); data != nil { + return } - return } } - err = comm.NewNotFoundConfErr("hero", hero_skillup, skillid) + err = comm.NewNotFoundConfErr(moduleName, hero_skillup, skillid) return } @@ -292,13 +289,12 @@ func (this *configureComp) GetHeroFucionConfig(cid string) (data *cfg.GameHerofu ) if v, err = this.GetConfigure(hero_fusion); err == nil { if configure, ok := v.(*cfg.GameHerofusion); ok { - if data = configure.Get(cid); data == nil { - err = comm.NewNotFoundConfErr("hero", hero_fusion, cid) + if data = configure.Get(cid); data != nil { + return } - return } } - err = comm.NewNotFoundConfErr("hero", hero_fusion, cid) + err = comm.NewNotFoundConfErr(moduleName, hero_fusion, cid) return } @@ -308,13 +304,12 @@ 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 { - if data = configure.Get(id); data == nil { - err = comm.NewNotFoundConfErr("hero", hero_talent, id) + if data = configure.Get(id); data != nil { + return } - return } } - err = comm.NewNotFoundConfErr("hero", hero_talent, id) + err = comm.NewNotFoundConfErr(moduleName, hero_talent, id) return } @@ -353,11 +348,7 @@ func (this *configureComp) GetShopItemsConfigureByGroups(groupid int32, user *pb v interface{} table *cfg.GameShopitem ) - if v, err = this.GetConfigure(game_shopitem); err != nil { - this.module.Errorf("err:%v", err) - err = comm.NewNotFoundConfErr("hero", game_shopitem, groupid) - return - } else { + if v, err = this.GetConfigure(game_shopitem); err == nil { table = v.(*cfg.GameShopitem) for _, v := range table.GetDataMap() { if v.Id == groupid && @@ -369,6 +360,7 @@ func (this *configureComp) GetShopItemsConfigureByGroups(groupid int32, user *pb } } } + err = comm.NewNotFoundConfErr(moduleName, game_shopitem, groupid) return } @@ -414,7 +406,6 @@ func (this *configureComp) GetHeroMaxLv(star int32) int32 { func (this *configureComp) GetHeroTalentMaxLv(heroid string) (maxlv int32) { if v, err := this.GetConfigure(hero_talentbox); err == nil { if configure, ok := v.(*cfg.GameTalentBox); ok { - return int32(len(configure.GetDataList())) } } diff --git a/modules/library/comp_configure.go b/modules/library/comp_configure.go index 326255f2e..c424d5727 100644 --- a/modules/library/comp_configure.go +++ b/modules/library/comp_configure.go @@ -12,6 +12,8 @@ import ( "sync" ) +var moduleName = "library" + const ( // game_libraryhero = "game_libraryhero.json" // 英雄对应的羁绊id信息 // game_libraryfetter = "game_libraryfetter.json" // 羁绊信息表 @@ -70,7 +72,7 @@ func (this *configureComp) GetFavorability(hid string, lv int32) (conf *cfg.Game ) if conf, ok = this.favorability[hid+"-"+strconv.Itoa(int(lv))]; !ok { par = fmt.Errorf("hid:%s,lv:%d", hid, lv) - err = comm.NewNotFoundConfErr("hero", game_favorability, par) + err = comm.NewNotFoundConfErr(moduleName, game_favorability, par) } return } @@ -105,7 +107,7 @@ func (this *configureComp) GetFriendData(id int32, lv int32) (conf []*cfg.GameFr ) if conf, ok = this.friend[int64(id)<<8+int64(lv)]; !ok { par = fmt.Errorf("hid:%d,lv:%d", id, lv) - err = comm.NewNotFoundConfErr("hero", game_friends, par) + err = comm.NewNotFoundConfErr(moduleName, game_friends, par) } return } @@ -137,7 +139,7 @@ func (this *configureComp) GetFavorabilityExp(hid string) (conf []int32, err err ok bool ) if conf, ok = this.favorLvExp[hid]; !ok { - err = comm.NewNotFoundConfErr("hero", game_favorability, hid) + err = comm.NewNotFoundConfErr(moduleName, game_favorability, hid) } return }