diff --git a/bin/json/game_friends.json b/bin/json/game_friends.json index f4f50d05b..521416256 100644 --- a/bin/json/game_friends.json +++ b/bin/json/game_friends.json @@ -41,7 +41,7 @@ "png": "jiban_img_zu02", "friends_lv": 1, "favorability_lv": 1, - "hid": "35001", + "hid": "14002", "attribute": [ { "a": "atk", @@ -49,7 +49,7 @@ } ], "attribute_txt": { - "key": "favorability_friends_friend_name_350011", + "key": "favorability_friends_friend_name_140021", "text": "攻击力+{0}" } }, @@ -95,7 +95,7 @@ "png": "jiban_img_zu02", "friends_lv": 2, "favorability_lv": 9, - "hid": "35001", + "hid": "14002", "attribute": [ { "a": "atk", @@ -103,7 +103,7 @@ } ], "attribute_txt": { - "key": "favorability_friends_friend_name_350012", + "key": "favorability_friends_friend_name_140022", "text": "攻击力+{0}" } }, @@ -149,7 +149,7 @@ "png": "jiban_img_zu02", "friends_lv": 3, "favorability_lv": 15, - "hid": "35001", + "hid": "14002", "attribute": [ { "a": "atk", @@ -157,7 +157,7 @@ } ], "attribute_txt": { - "key": "favorability_friends_friend_name_350013", + "key": "favorability_friends_friend_name_140023", "text": "攻击力+{0}" } }, diff --git a/modules/library/comp_configure.go b/modules/library/comp_configure.go index ebc006435..29e314f57 100644 --- a/modules/library/comp_configure.go +++ b/modules/library/comp_configure.go @@ -27,8 +27,6 @@ const ( type configureComp struct { modules.MCompConfigure hlock sync.RWMutex - // fetter map[int64]*cfg.GameLibraryFetterData - // favor map[int64]*cfg.GameLibraryFavorData favorability map[string]*cfg.GameFavorabilityData favorLvExp map[string][]int32 // key 英雄id value 每级升级所需要的经验值 @@ -40,25 +38,15 @@ type configureComp struct { //组件初始化接口 func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { err = this.MCompConfigure.Init(service, module, comp, options) - // err = this.LoadMultiConfigure(map[string]interface{}{ - // game_libraryhero: cfg.NewGameLibraryHero, - // game_libraryhistory: cfg.NewGameLibraryHistory, - // game_libraryfavor: cfg.NewGameLibraryFavor, - // game_librarystory: cfg.NewGameLibraryStory, - // game_librarycomplot: cfg.NewGameLibraryComplot, - // }) - - // this.fetter = make(map[int64]*cfg.GameLibraryFetterData, 0) - // configure.RegisterConfigure(game_libraryfetter, cfg.NewGameLibraryFetter, this.SetLibraryFetter) - // this.favor = make(map[int64]*cfg.GameLibraryFavorData, 0) - // configure.RegisterConfigure(game_libraryfetter, cfg.NewGameLibraryFetter, this.SetLibraryFavor) configure.RegisterConfigure(game_favorability, cfg.NewGameFavorability, this.SetFavorability) - configure.RegisterConfigure(game_friends, cfg.NewGameLibraryFetter, this.SetFriendData) + configure.RegisterConfigure(game_friends, cfg.NewGameFriends, this.SetFriendData) return } func (this *configureComp) SetFavorability() { if v, err := this.GetConfigure(game_favorability); err == nil { + this.hlock.Lock() + defer this.hlock.Unlock() this.favorability = make(map[string]*cfg.GameFavorabilityData, 0) this.favorLvExp = make(map[string][]int32) if _configure, ok := v.(*cfg.GameFavorability); ok { @@ -81,6 +69,8 @@ func (this *configureComp) GetFavorability(hid string, lv int32) *cfg.GameFavora func (this *configureComp) SetFriendData() { if v, err := this.GetConfigure(game_friends); err == nil { + this.hlock.Lock() + defer this.hlock.Unlock() this.friend = make(map[int64][]*cfg.GameFriendsData, 0) this.heroFetter = make(map[string][]int32) if _configure, ok := v.(*cfg.GameFriends); ok { @@ -89,11 +79,11 @@ func (this *configureComp) SetFriendData() { this.friend[key] = append(this.friend[key], v1) this.heroFetter[v1.Hid] = append(this.heroFetter[v1.Hid], v1.FriendId) } - return } } else { err = fmt.Errorf("%T no is *cfg.SetFavorability", err) } + return } // id:羁绊id lv 羁绊等级 diff --git a/modules/library/module.go b/modules/library/module.go index 00d2a98ac..af1c08aa6 100644 --- a/modules/library/module.go +++ b/modules/library/module.go @@ -95,11 +95,7 @@ func (this *Library) CheckFetter(uid string, hid string) (dbLibrary []*pb.DBLibr szFid := this.configure.GetHeroFetterID(hid) for _, fid := range szFid { - conf := this.configure.GetFriendData(fid, 1) - if len(conf) == 0 { - this.modelFetter.module.Errorf("can't foun conf fid:%d", fid) - continue - } + if list := this.GetLibraryListByFid(uid, fid); list == nil { // 没有这条羁绊数据 tmp := &pb.DBLibrary{ // 创建一条羁绊数据 Id: primitive.NewObjectID().Hex(), @@ -108,29 +104,28 @@ func (this *Library) CheckFetter(uid string, hid string) (dbLibrary []*pb.DBLibr Herofetter: map[string]string{}, Prize: map[int32]int32{}, } - for _, v := range conf { - if _d := this.CheckHeroFetter(uid, v.Hid); _d != nil { // check DBHeroFetter - tmp.Herofetter[v.Hid] = _d.Id - fetter = append(fetter, _d) - } + + if _d := this.CheckHeroFetter(uid, hid); _d != nil { // check DBHeroFetter + tmp.Herofetter[hid] = _d.Id + fetter = append(fetter, _d) } + if err := this.modelLibrary.createLibrary(uid, tmp); err != nil { this.modelFetter.module.Errorf("createLibrary error: %v,obj:%v", err, tmp) continue } dbLibrary = append(dbLibrary, tmp) } else { // 有这条羁绊数据 - for _, v := range conf { - if _, ok := list.Herofetter[v.Hid]; !ok { - if _d := this.CheckHeroFetter(uid, v.Hid); _d == nil { - list.Herofetter[v.Hid] = _d.Id - fetter = append(fetter, _d) - } - mapData := make(map[string]interface{}, 0) - mapData["herofetter"] = list.Herofetter - this.modelLibrary.modifyLibraryDataByObjId(uid, list.Id, mapData) // 更新新的羁绊信息 - dbLibrary = append(dbLibrary, list) + + if _, ok := list.Herofetter[hid]; !ok { + if _d := this.CheckHeroFetter(uid, hid); _d == nil { + list.Herofetter[hid] = _d.Id + fetter = append(fetter, _d) } + mapData := make(map[string]interface{}, 0) + mapData["herofetter"] = list.Herofetter + this.modelLibrary.modifyLibraryDataByObjId(uid, list.Id, mapData) // 更新新的羁绊信息 + dbLibrary = append(dbLibrary, list) } } } diff --git a/pb/hero_db.pb.go b/pb/hero_db.pb.go index 5c4207c3d..5e3988c4e 100644 --- a/pb/hero_db.pb.go +++ b/pb/hero_db.pb.go @@ -101,7 +101,7 @@ type DBHero struct { HoroscopeProperty map[string]int32 `protobuf:"bytes,28,rep,name=horoscopeProperty,proto3" json:"horoscopeProperty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"horoscopeProperty"` ////星座属性加成 Fulllvenr int32 `protobuf:"varint,29,opt,name=fulllvenr,proto3" json:"fulllvenr" bson:"fulllvenr"` ////满级登记分组 武馆使用 KongfuUid string `protobuf:"bytes,30,opt,name=kongfuUid,proto3" json:"kongfuUid"` //@go_tags(`bson:"kongfuUid"`)// 英雄在谁家练功 - Fetters map[string]int32 `protobuf:"bytes,31,rep,name=fetters,proto3" json:"fetters" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"horoscopeProperty"` ////羁绊属性加成 + Fetters map[string]int32 `protobuf:"bytes,31,rep,name=fetters,proto3" json:"fetters" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"fetters"` ////羁绊属性加成 } func (x *DBHero) Reset() {