diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index 666d19c98..4823f38fb 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -41,9 +41,8 @@ type configureComp struct { hlock sync.RWMutex drawCardCfg map[string]map[int32][]*cfg.GameDrawCardData // 第一个key 卡池id 第二个key 星级 awakenMap map[int64]*cfg.GameHeroAwakenData - - starMap map[int64]*cfg.GameHeroStarupData - module *Hero + starMap map[int64]*cfg.GameHeroStarupData + module *Hero } //组件初始化接口 @@ -78,9 +77,8 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp defer this.hlock.Unlock() if _configure, ok := v.(*cfg.GameHeroAwaken); ok { for _, v := range _configure.GetDataList() { - this.awakenMap[int64(utils.ToInt32(v.Hid)<<8)+int64(v.Phase)] = v + this.awakenMap[utils.ToInt64(v.Hid)+int64(v.Phase<<31)] = v } - return } } else { @@ -96,7 +94,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp this.hlock.Lock() defer this.hlock.Unlock() for _, v := range _configure.GetDataList() { - this.starMap[int64(utils.ToInt32(v.Id)<<8)+int64(v.Star)] = v + this.starMap[utils.ToInt64(v.Id)+int64(v.Star<<31)] = v } return @@ -111,22 +109,23 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp // 获取英雄升星相关配置数据 func (this *configureComp) GetHeroStarupConfig(hid string, star int32) *cfg.GameHeroStarupData { - return this.starMap[int64(utils.ToInt32(hid)<<8)+int64(star)] + return this.starMap[utils.ToInt64(hid)+int64(star<<31)] } // 获取当前英雄最高星级 func (this *configureComp) GetHeroMaxStar(hid string, curStar int32) int32 { var star int32 for star = curStar; star < 100; star++ { - if _, ok := this.starMap[int64(utils.ToInt32(hid)<<8)+int64(star+1)]; !ok { + if _, ok := this.starMap[utils.ToInt64(hid)+int64((star+1)<<31)]; !ok { return star } } return star } +// 获取觉醒配置 func (this *configureComp) GetHeroAwakenConfig(hid string, phase int32) *cfg.GameHeroAwakenData { - return this.awakenMap[int64(utils.ToInt32(hid)<<8)+int64(phase)] + return this.awakenMap[utils.ToInt64(hid)+int64(phase<<31)] } // 抽卡配置表 @@ -238,7 +237,7 @@ func (this *configureComp) GetHeroLvgrow(heroId string) *cfg.GameHeroLevelgrowDa return configure.Get(heroId) } } - + this.module.Errorf("cfg.GetHeroLvgrow :id = %s", heroId) return nil } @@ -251,7 +250,7 @@ func (this *configureComp) GetHeroSkillUpConfig(skillid int32) (data *cfg.GameHe return } } - + this.module.Errorf("cfg.GetHeroSkillUpConfig :id = %d", skillid) return } @@ -267,7 +266,7 @@ func (this *configureComp) GetHeroSkillMaxLvConfig(skillId uint32) int32 { } } } - + this.module.Errorf("cfg.GetHeroSkillMaxLvConfig :id = %d", skillId) return 0 } diff --git a/utils/strings.go b/utils/strings.go index 631a913ff..7cbfbd620 100644 --- a/utils/strings.go +++ b/utils/strings.go @@ -88,3 +88,11 @@ func ToInt32(s string) int32 { return int32(j) } } + +func ToInt64(s string) int64 { + if j, err := strconv.ParseInt(s, 10, 32); err != nil { + return 0 + } else { + return int64(j) + } +}