This commit is contained in:
meixiongfeng 2023-04-25 18:48:10 +08:00
parent c9a04e6d81
commit b7700786c8
2 changed files with 9 additions and 6 deletions

View File

@ -31,7 +31,7 @@ type configureComp struct {
favorability map[string]*cfg.GameFavorabilityData
favorLvExp map[string][]int32 // key 英雄id value 每级升级所需要的经验值
friend map[int64][]*cfg.GameFriendsData
heroFetter map[string][]int32 // key 英雄id value 羁绊id
heroFetter map[string]map[int32]int32 // key 英雄id value 羁绊id
}
@ -72,12 +72,15 @@ func (this *configureComp) SetFriendData() {
this.hlock.Lock()
defer this.hlock.Unlock()
this.friend = make(map[int64][]*cfg.GameFriendsData, 0)
this.heroFetter = make(map[string][]int32)
this.heroFetter = make(map[string]map[int32]int32)
if _configure, ok := v.(*cfg.GameFriends); ok {
for _, v1 := range _configure.GetDataList() {
key := int64(v1.FriendId)<<8 + int64(v1.FriendsLv)
this.friend[key] = append(this.friend[key], v1)
this.heroFetter[v1.Hid] = append(this.heroFetter[v1.Hid], v1.FriendId)
if _, ok := this.heroFetter[v1.Hid]; !ok {
this.heroFetter[v1.Hid] = make(map[int32]int32, 0)
}
this.heroFetter[v1.Hid][v1.FriendId] = 1
}
}
} else {
@ -92,7 +95,7 @@ func (this *configureComp) GetFriendData(id int32, lv int32) []*cfg.GameFriendsD
}
// 通过英雄获取当前英雄的所有羁绊ID
func (this *configureComp) GetHeroFetterID(hid string) []int32 {
func (this *configureComp) GetHeroFetterID(hid string) map[int32]int32 {
return this.heroFetter[hid]
}

View File

@ -118,7 +118,7 @@ func (this *Library) CheckFetter(uid string, hid string) (dbLibrary []*pb.DBLibr
} else { // 有这条羁绊数据
if _, ok := list.Herofetter[hid]; !ok {
if _d := this.CheckHeroFetter(uid, hid); _d == nil {
if _d := this.CheckHeroFetter(uid, hid); _d != nil {
list.Herofetter[hid] = _d.Id
fetter = append(fetter, _d)
}
@ -180,7 +180,7 @@ func (this *Library) CheckHeroFetter(uid string, hid string) (obj *pb.DBHeroFett
}
if !bFound { // 创建一条英雄数据
if obj, err = this.createHeroFetter(uid, hid); err != nil {
obj = nil
return
}
}