diff --git a/bin/json/game_opencond.json b/bin/json/game_opencond.json index 0cc3152e8..cce4953ff 100644 --- a/bin/json/game_opencond.json +++ b/bin/json/game_opencond.json @@ -1578,7 +1578,7 @@ "main": [ { "key": "worldtaskid", - "param": 20010 + "param": 20050 } ], "optional": "", @@ -1586,8 +1586,8 @@ "kqbx": 0, "img": "", "prompt": { - "key": "", - "text": "" + "key": "opencond_prompt_slidescreen_up", + "text": "请先完成主线剧情" }, "uiid": 0 }, @@ -1600,7 +1600,7 @@ "main": [ { "key": "worldtaskid", - "param": 20010 + "param": 20050 } ], "optional": "", @@ -1608,8 +1608,8 @@ "kqbx": 0, "img": "", "prompt": { - "key": "", - "text": "" + "key": "opencond_prompt_slidescreen_left", + "text": "请先完成主线剧情" }, "uiid": 0 }, @@ -1622,7 +1622,7 @@ "main": [ { "key": "worldtaskid", - "param": 20010 + "param": 20050 } ], "optional": "", @@ -1630,8 +1630,8 @@ "kqbx": 0, "img": "", "prompt": { - "key": "", - "text": "" + "key": "opencond_prompt_slidescreen_right", + "text": "请先完成主线剧情" }, "uiid": 0 } diff --git a/comm/imodule.go b/comm/imodule.go index 8a6b89724..4471cea98 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -48,8 +48,6 @@ type ( //查询用户卡片数量 QueryHeroAmount(uId string, heroCfgId string) (amount uint32) - //创建指定数量 - CreateRepeatHero(session IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, code pb.ErrorCode) // 批量创建英雄 CreateRepeatHeros(session IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, code pb.ErrorCode) // 获取英雄 @@ -156,7 +154,7 @@ type ( IReddot } IMline interface { - ModifyMlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode) + ModifyMlineDataByNanduID(session IUserSession, id int32) (code pb.ErrorCode) /// 查询章节ID GetUsermLineData(uid string, chapterType int32) (chapterId int32) ///红点 diff --git a/modules/gm/api_cmd.go b/modules/gm/api_cmd.go index d8fc75b12..32ac4c95b 100644 --- a/modules/gm/api_cmd.go +++ b/modules/gm/api_cmd.go @@ -24,7 +24,7 @@ import ( 9、bingo:season,10 赛季塔层数 10、bingo:viking // 解锁维京所有难度 11、bingo:hunting // 解锁狩猎所有难度 -12、bingo:mainline,1,101 // 难度 id +12、bingo:mainline,11001 // 难度 id 13、bingo:moon,1 // 触发月之秘境 14、bingo:arena,100 // 设置竞技场用户积分 15、bingo:sociatyexp,100 // 设置工会经验 diff --git a/modules/gm/module.go b/modules/gm/module.go index 52ce54393..a5708bbeb 100644 --- a/modules/gm/module.go +++ b/modules/gm/module.go @@ -194,8 +194,8 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC this.Debug("使用bingo命令:uid = %s ", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "0", Value: datas[0]}) - } else if len(datas) == 3 && (datas[0] == "mainline") { - module1, err := this.service.GetModule(comm.ModuleMainline) + } else if len(datas) == 2 && (datas[0] == "mainline") { + module1, err := this.service.GetModule(comm.ModuleMline) if err != nil { return } @@ -204,12 +204,8 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC code = pb.ErrorCode_ReqParameterError return } - num2, err := strconv.Atoi(datas[2]) - if err != nil { - code = pb.ErrorCode_ReqParameterError - return - } - code = module1.(comm.IMainline).ModifyMainlineDataByNanduID(session.GetUserId(), int32(num1), int32(num2)) + + code = module1.(comm.IMline).ModifyMlineDataByNanduID(session, int32(num1)) this.Debug("使用bingo命令", log.Field{Key: "uid", Value: session.GetUserId()}, diff --git a/modules/hero/api_drawCard.go b/modules/hero/api_drawCard.go index dd287e780..51a6bd3d1 100644 --- a/modules/hero/api_drawCard.go +++ b/modules/hero/api_drawCard.go @@ -276,12 +276,33 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq update["totalcount"] = heroRecord.Totalcount update["daycount"] = heroRecord.Daycount this.module.modelRecord.ChangeHeroRecord(session.GetUserId(), update) + szNewCards := make([]*cfg.Gameatn, 0) for _, heroId := range szCards { - + bFind := false _mapAddHero[heroId]++ + for _, v := range szNewCards { + if v.T == heroId { + v.N++ + bFind = true + break + } + } + if !bFind { + res := &cfg.Gameatn{ + A: "hero", + T: heroId, + N: 1, + } + szNewCards = append(szNewCards, res) + } } - _, code = this.module.CreateRepeatHeros(session, _mapAddHero, true) + // 获得新卡 + if code = this.module.DispenseRes(session, szNewCards, true); code != pb.ErrorCode_Success { + + this.module.Errorf("err:%v,create heros:%v,uid,%s", code, szNewCards, session.GetUserId()) + code = pb.ErrorCode_HeroCreate // 创建新英雄失败 + } ///英雄招募 【玩家名称】在招募中获得了【英雄名称】! this.module.SendChatMsg(session, _mapAddHero, szCards) diff --git a/modules/hero/api_fusion.go b/modules/hero/api_fusion.go index 0e87064e0..665c8bce2 100644 --- a/modules/hero/api_fusion.go +++ b/modules/hero/api_fusion.go @@ -3,6 +3,7 @@ package hero import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/utils" "google.golang.org/protobuf/proto" @@ -74,12 +75,14 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (c } // 获得新卡 - var new map[string]int32 - new = make(map[string]int32) - new[conf.Hero] = 1 - if _, err := this.module.CreateRepeatHeros(session, new, false); err != pb.ErrorCode_Success { + res := &cfg.Gameatn{ + A: "hero", + T: conf.Hero, + N: 1, + } + if code = this.module.DispenseRes(session, []*cfg.Gameatn{res}, false); code != pb.ErrorCode_Success { - this.module.Errorf("err:%v,create hero:%s,uid,%ss", err, conf.Hero, session.GetUserId()) + this.module.Errorf("err:%v,create hero:%s,uid,%ss", code, conf.Hero, session.GetUserId()) code = pb.ErrorCode_HeroCreate // 创建新英雄失败 } session.SendMsg(string(this.module.GetType()), HeroFusionResp, &pb.HeroFusionResp{Heroid: conf.Hero}) diff --git a/modules/hero/module.go b/modules/hero/module.go index a3513fb30..faf671c6b 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -76,7 +76,7 @@ func (this *Hero) Start() (err error) { } //创建单个叠加英雄 -func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, code pb.ErrorCode) { +func (this *Hero) createRepeatHero(session comm.IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, code pb.ErrorCode) { var err error hero, err = this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num) if err == nil { @@ -272,7 +272,7 @@ func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string] if num == 0 { // 数量为0 不做处理 continue } - if hero, code = this.CreateRepeatHero(session, heroCfgId, num); code != pb.ErrorCode_Success { + if hero, code = this.createRepeatHero(session, heroCfgId, num); code != pb.ErrorCode_Success { this.Errorf("create hero %s failed", heroCfgId) return } diff --git a/modules/mline/api_challenge.go b/modules/mline/api_challenge.go index 89293270a..9ce83e36c 100644 --- a/modules/mline/api_challenge.go +++ b/modules/mline/api_challenge.go @@ -42,16 +42,16 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MlineChallenge } } if curChapter == nil { // 校验是不是新的数据 - preStage := this.module.configure.GetPreMainChapter(req.StageId) // 新章节数据校验 - preStageConf := this.module.configure.GetMainStageConf(preStage) - if stageConf == nil { // 配置文件校验 + //preStage := this.module.configure.GetMainStageConf(stageConf.Previoustage) // 新章节数据校验 + preStageConf := this.module.configure.GetMainStageConf(stageConf.Previoustage) + if preStageConf == nil { // 配置文件校验 code = pb.ErrorCode_MainlineNotFindChapter return } for _, v := range list { - if preStageConf.CaptainId == v.ChapterId { // 有上一章节数据 - if _, ok := v.Star[v.StageId]; ok { + if preStageConf.Chapterid == v.ChapterId { // 有上一章节数据 + if _, ok := v.Star[preStageConf.Id]; ok { newData := &pb.DBMline{ Id: primitive.NewObjectID().Hex(), Uid: session.GetUserId(), @@ -62,22 +62,22 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MlineChallenge Award: map[int32]bool{}, Ps: map[int32]int32{}, } + curChapter = newData this.module.modelMline.addNewChapter(session.GetUserId(), newData) break } } } + } + if curChapter == nil { code = pb.ErrorCode_MainlineNotFindChapter return } + if v1, ok := curChapter.Ps[req.StageId]; ok && v1 == 0 { - if v, ok := curChapter.Ps[req.StageId]; ok && v > 0 { - if v != 0 { // 扣1点 - if code = this.module.ConsumeRes(session, stageConf.PsMg, true); code != pb.ErrorCode_Success { // 扣1点 - return - } + if code = this.module.ConsumeRes(session, stageConf.PsMg, true); code != pb.ErrorCode_Success { // 扣1点 + return } - } else { for _, v := range stageConf.PsConsume { if v.A == "attr" && v.T == "ps" { diff --git a/modules/mline/comp_configure.go b/modules/mline/comp_configure.go index b71511bbc..6d71dc235 100644 --- a/modules/mline/comp_configure.go +++ b/modules/mline/comp_configure.go @@ -140,24 +140,3 @@ func (this *configureComp) GetAllStageByChapterID(chapterID int32) (stage []int3 } return } - -// gm 专用 -func (this *configureComp) GetGMChapter(chapterID, itype int32) (d map[int32][]int32) { - // var d map[int32][]int32 - d = make(map[int32][]int32, 0) - if v, err := this.GetConfigure(game_mainstage); err == nil { - if configure, ok := v.(*cfg.GameMainStage); ok { - for _, v1 := range configure.GetDataList() { - if v1.Episodetype == itype && v1.Id <= chapterID { - //chapter = append(chapter, v1.Id) - stage := this.GetAllStageByChapterID(v1.Id) - if len(stage) > 0 { - d[v1.Id] = stage - } - } - } - } - } - - return -} diff --git a/modules/mline/module.go b/modules/mline/module.go index 124d59dad..256b27d1f 100644 --- a/modules/mline/module.go +++ b/modules/mline/module.go @@ -90,37 +90,44 @@ func (this *Mline) CheckPoint(uid string) bool { } // 参数 难度 + 章节id -func (this *Mline) ModifyMlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode) { +func (this *Mline) ModifyMlineDataByNanduID(session comm.IUserSession, id int32) (code pb.ErrorCode) { var del []string - list, err := this.modelMline.getMainlineList(uid) + list, err := this.modelMline.getMainlineList(session.GetUserId()) if err != nil { code = pb.ErrorCode_DBError return } for _, v := range list { - if v.CType == nandu { - del = append(del, v.Id) - } + del = append(del, v.Id) } // 清除 - this.modelMline.cleanChapterDataById(uid, del...) - d := this.configure.GetGMChapter(id, nandu) - for k, v := range d { - newData := &pb.DBMline{ - Id: primitive.NewObjectID().Hex(), - Uid: uid, - CType: nandu, - ChapterId: k, - StageId: 0, - Star: map[int32]int32{}, - Award: map[int32]bool{}, - Ps: map[int32]int32{}, - } - for _, v1 := range v { - newData.Star[v1] = 3 // gm 全给3星 - } - this.modelMline.addNewChapter(uid, newData) + this.modelMline.cleanChapterDataById(session.GetUserId(), del...) + + connf := this.configure.GetMainStageConf(id) + if connf == nil { + return } + _data := this.configure.GetAllChapterID() + for _, v := range _data { + if v <= connf.Chapterid { + newData := &pb.DBMline{ + Id: primitive.NewObjectID().Hex(), + Uid: session.GetUserId(), + CType: connf.Episodetype, + ChapterId: v, + StageId: id, + Star: map[int32]int32{}, + Award: map[int32]bool{}, + Ps: map[int32]int32{}, + } + stageConf := this.configure.GetAllStageByChapterID(v) + for _, v := range stageConf { + newData.Star[v] = 3 + } + this.modelMline.addNewChapter(session.GetUserId(), newData) + } + } + return } func (this *Mline) GetUsermLineData(uid string, chapterType int32) (chapterId int32) { diff --git a/modules/sociaty/api.go b/modules/sociaty/api.go index 63ec80db0..e32713789 100644 --- a/modules/sociaty/api.go +++ b/modules/sociaty/api.go @@ -42,6 +42,7 @@ const ( SociatySubTypeBuy = "buy" SociatySubTypeBuynum = "buynum" SociatySubTypeBreceive = "breceive" + SociatySubTypeRecommend = "recommend" ) type apiComp struct { diff --git a/modules/sociaty/api_cross_bossmain.go b/modules/sociaty/api_cross_bossmain.go index 0c37a76c6..f3c1905de 100644 --- a/modules/sociaty/api_cross_bossmain.go +++ b/modules/sociaty/api_cross_bossmain.go @@ -38,7 +38,7 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq } // 未参赛(恢复挑战券) - if !this.module.modelSociatyBoss.IsSports(uid) { + if !this.module.modelSociatyBoss.IsInSports(uid) { userEx.SociatyTicket = ggd.GuildBossInitialNum update := map[string]interface{}{ "sociatyTicket": userEx.SociatyTicket, @@ -47,6 +47,7 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq code = pb.ErrorCode_DBError return } + rsp.Ticket = userEx.SociatyTicket } sociaty := this.module.modelSociaty.getUserSociaty(uid) @@ -73,12 +74,12 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq } //个人排名 - rsp.PersonalRanking = this.module.modelSociatyBoss.getRankingByUid( + rsp.PersonalRanking = this.module.modelSociatyBoss.getRankingByMember( fmt.Sprintf("%s:%s", this.module.modelSociatyBoss.TableName, BOSS_PERSONAL_RANK), uid) // 公会排名 - rsp.SociatyRanking = this.module.modelSociatyBoss.getRankingByUid( - fmt.Sprintf("%s:%s", this.module.modelSociatyBoss.TableName, BOSS_SOCIATY_RANK), uid) + rsp.SociatyRanking = this.module.modelSociatyBoss.getRankingByMember( + fmt.Sprintf("%s:%s", this.module.modelSociatyBoss.TableName, BOSS_SOCIATY_RANK), sociaty.Id) if sm := this.module.modelSociaty.getMemberInfo(sociaty, uid); sm != nil { rsp.Teams = sm.Teams diff --git a/modules/sociaty/api_cross_breceive.go b/modules/sociaty/api_cross_breceive.go index c1986a064..4a59f3d43 100644 --- a/modules/sociaty/api_cross_breceive.go +++ b/modules/sociaty/api_cross_breceive.go @@ -46,13 +46,29 @@ func (this *apiComp) Breceive(session comm.IUserSession, req *pb.SociatyBReceive } else if taskId == 0 { //未完成 code = pb.ErrorCode_SociatyTaskNoFinished return + } else if taskId == 1 { //可领取 + task.Status = 2 } break } } - //更新任务状态 - + //更新任务状态 + update := map[string]interface{}{ + "tasks": dbr.Tasks, + } + if err := this.module.modelSociatyBoss.Change(uid, update); err != nil { + code = pb.ErrorCode_DBError + return + } + + // 奖励 + if code := this.module.DispenseRes(session, taskConf.Reward, true); code != pb.ErrorCode_Success { + this.module.Error("积分任务奖励领取", + log.Field{Key: "uid", Value: uid}, + log.Field{Key: "taskId", Value: taskId}, + log.Field{Key: "reward", Value: taskConf.Reward}) + } rsp := &pb.SociatyBReceiveResp{ SociatyId: sociaty.Id, diff --git a/modules/sociaty/api_cross_recommend.go b/modules/sociaty/api_cross_recommend.go new file mode 100644 index 000000000..2dc382594 --- /dev/null +++ b/modules/sociaty/api_cross_recommend.go @@ -0,0 +1,29 @@ +package sociaty + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + + "google.golang.org/protobuf/proto" +) + +// 公会BOSS 推荐 +func (this *apiComp) RecommendCheck(session comm.IUserSession, req *pb.SociatyRecommendReq) (code pb.ErrorCode) { + if req.Cate != 1 || req.Cate != 2 { + code = pb.ErrorCode_ReqParameterError + } + return +} + +func (this *apiComp) Recommend(session comm.IUserSession, req *pb.SociatyRecommendReq) (code pb.ErrorCode, data proto.Message) { + if code = this.RecommendCheck(session, req); code != pb.ErrorCode_Success { + return + } + + rsp := &pb.SociatyRecommendResp{} + + if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeRecommend, rsp); err != nil { + code = pb.ErrorCode_SystemError + } + return +} diff --git a/modules/sociaty/config.go b/modules/sociaty/config.go index f8556e665..85add7e4f 100644 --- a/modules/sociaty/config.go +++ b/modules/sociaty/config.go @@ -134,3 +134,17 @@ func (this *configureComp) getBossTask(taskId int32) *cfg.GameGuildBossTaskData } return nil } + +// 积分任务列表 +func (this *configureComp) getBossTaskList() []*cfg.GameGuildBossTaskData { + if v, err := this.GetConfigure(gameSociatyBossTask); err != nil { + return nil + } else { + data, ok := v.(*cfg.GameGuildBossTask) + if !ok { + err = fmt.Errorf("%T no is *cfg.GameGuildActivity", v) + return nil + } + return data.GetDataList() + } +} diff --git a/modules/sociaty/model_sociatyboss.go b/modules/sociaty/model_sociatyboss.go index 953d92de1..32dc213d0 100644 --- a/modules/sociaty/model_sociatyboss.go +++ b/modules/sociaty/model_sociatyboss.go @@ -73,7 +73,7 @@ func (s *ModelSociatyBoss) initSports() error { if now.Unix() >= sports.EndTime { sports.EndTime, sports.SettlementTime = s.sportsTime() //归档前赛季数据 - s.reset() + s.resetSportsData() // 更新下一赛季周期结束时间 update := map[string]interface{}{ "endTime": sports.EndTime, @@ -110,7 +110,7 @@ func (s *ModelSociatyBoss) updateSociatyBossSports(data map[string]interface{}) } } -// 赛季时间 +// 赛季结算和结束时间 func (s *ModelSociatyBoss) sportsTime() (t1, t2 int64) { now := configure.Now() end1 := now.Add(time.Duration(SPORTS_HOUR) * time.Hour) //测试时单位分钟 else Hour @@ -119,7 +119,7 @@ func (s *ModelSociatyBoss) sportsTime() (t1, t2 int64) { return end1.Unix(), end2.Unix() } -// 公会BOSS是否开始 +// 公会BOSS赛季是否开始 func (s *ModelSociatyBoss) sportsIsStarted() bool { sports := s.getSociatyBossSports() if sports == nil { @@ -137,7 +137,7 @@ func (s *ModelSociatyBoss) sportsIsStarted() bool { return false } -// 公会BOSS是否结束 +// 公会BOSS赛季是否结束 func (s *ModelSociatyBoss) sportsIsFinished() bool { sports := s.getSociatyBossSports() if sports == nil { @@ -366,7 +366,7 @@ func (s *ModelSociatyBoss) getScoreByUid(key, member string) int64 { } // 取排名 -func (s *ModelSociatyBoss) getRankingByUid(key, member string) int64 { +func (s *ModelSociatyBoss) getRankingByMember(key, member string) int64 { result, err := s.DBModel.Redis.ZRevRank(key, member) if err != nil { return 0 @@ -381,8 +381,8 @@ func (s *ModelSociatyBoss) bossRank(sociaty *pb.DBSociaty, rankType int32) (res key string ) + // 所有排行记录(个人、公会) rank := func() []*pb.SociatyRankInfo { - // 所有排行记录 rankUids, err := s.queryRankUid(rankCount) if err != nil { return nil @@ -399,7 +399,7 @@ func (s *ModelSociatyBoss) bossRank(sociaty *pb.DBSociaty, rankType int32) (res Name: user.Name, Head: user.Avatar, Lv: user.Lv, - Ranking: s.getRankingByUid(key, user.Uid), + Ranking: s.getRankingByMember(key, user.Uid), Integral: s.getScoreByUid(key, user.Uid), }) } @@ -409,14 +409,14 @@ func (s *ModelSociatyBoss) bossRank(sociaty *pb.DBSociaty, rankType int32) (res } switch rankType { case 1: //个人 - rankCount = 1000 + rankCount = 1000 //数据数量 key = fmt.Sprintf("%s:%s", s.TableName, BOSS_PERSONAL_RANK) rank() case 2: //公会 - rankCount = 50 + rankCount = 50 //数据数量 key = fmt.Sprintf("%s:%s", s.TableName, BOSS_SOCIATY_RANK) rank() - case 3: //公会成员 + case 3: //公会成员排行 for _, m := range sociaty.Members { imodule, err := s.service.GetModule(comm.ModuleUser) if err != nil { @@ -429,7 +429,7 @@ func (s *ModelSociatyBoss) bossRank(sociaty *pb.DBSociaty, rankType int32) (res Name: user.Name, Head: user.Avatar, Lv: user.Lv, - Ranking: s.getRankingByUid(key, user.Uid), + Ranking: s.getRankingByMember(key, user.Uid), Integral: s.getScoreByUid(key, user.Uid), }) } @@ -443,8 +443,8 @@ func (s *ModelSociatyBoss) bossRank(sociaty *pb.DBSociaty, rankType int32) (res return nil } -// 公会BOSS重置数据 -func (s *ModelSociatyBoss) reset() error { +// 公会BOSS重置数据(每个周期) +func (s *ModelSociatyBoss) resetSportsData() error { sports := s.getSociatyBossSports() if sports == nil { return errors.New("sociatyboss sports is nil") @@ -455,23 +455,20 @@ func (s *ModelSociatyBoss) reset() error { var record []*pb.DBSociatyBossRecord _ = s.GetList(uid, &record) for _, v := range record { - update := map[string]interface{}{ - "status": 1, //归档 - } - if err := s.Change(BOSS_SPORTS, update); err != nil { - s.moduleSociaty.Error("归档玩家赛事记录", log.Field{Key: "uid", Value: v.Uid}, log.Field{Key: "err", Value: err.Error()}) + if err := s.DelByUId(uid); err != nil { + s.moduleSociaty.Error("清理玩家赛季记录", log.Field{Key: "uid", Value: v.Uid}, log.Field{Key: "err", Value: err.Error()}) } } } // 清理排行榜 - if err := s.Del(BOSS_PERSONAL_RANK); err != nil { - s.moduleSociaty.Error("清理排行榜", log.Field{Key: "err", Value: err.Error()}) - } + // if err := s.Del(BOSS_PERSONAL_RANK); err != nil { + // s.moduleSociaty.Error("清理排行榜", log.Field{Key: "err", Value: err.Error()}) + // } return nil } // 是否参赛 -func (s *ModelSociatyBoss) IsSports(uid string) bool { +func (s *ModelSociatyBoss) IsInSports(uid string) bool { sports := s.getSociatyBossSports() if sports == nil { return false @@ -508,13 +505,41 @@ func (s *ModelSociatyBoss) settlement() error { } } - // 更新玩家赛季信息 + // 更新玩家赛季历史记录 + isExist := func(tasks []*pb.ChallengeTask, taskId int32) bool { + for _, task := range tasks { + if task.TaskId == taskId { + return true + } + } + return false + } + // 判断积分任务是否达标 + var tasks []*pb.ChallengeTask + var taskFlag bool //任务更新状态 + taskList := s.moduleSociaty.configure.getBossTaskList() + for _, task := range taskList { + if total >= int64(task.Score) && !isExist(cr.Tasks, task.Id) { + tasks = append(tasks, &pb.ChallengeTask{ + TaskId: task.Id, + Status: 1, //可领取 + }) + taskFlag = true + } + } + cr.Total = total cr.Integrals = highScore update := map[string]interface{}{ "total": total, "integrals": highScore, } + + // 任务状态有变化时更新 + if taskFlag { + update["tasks"] = tasks + cr.Tasks = tasks + } if err := s.Change(uid, update); err != nil { s.moduleSociaty.Error("更新玩家赛事信息", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()}) continue @@ -526,7 +551,10 @@ func (s *ModelSociatyBoss) settlement() error { s.addSociatyRank(uid, total) s.moduleSociaty.Debug("结算:", log.Field{Key: "uid", Value: uid}) + } + //归档前10的玩家记录 + return nil } diff --git a/modules/user/module.go b/modules/user/module.go index 1522ebc1d..b51b4d983 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -169,19 +169,35 @@ func (this *User) UserOnlineList() ([]*pb.CacheUser, error) { if err := this.modelSession.GetList(comm.RDS_EMPTY, &cache); err != nil { return nil, err } + } else { + var err error + if cache, err = this.CrossUserOnlineList(); err != nil { + return nil, err + } } return cache, nil } // 跨服玩家列表 func (this *User) CrossUserOnlineList() ([]*pb.CacheUser, error) { - reply := &pb.UserOnlineResp{} - err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), - comm.Service_Worker, Rpc_GetAllOnlineUser, nil, reply) + conn, err := db.Local() if err != nil { return nil, err } - return reply.Users, err + model := db.NewDBModel(comm.TableSession, 0, conn) + var cache []*pb.CacheUser + if err := model.GetList(comm.RDS_EMPTY, &cache); err != nil { + return nil, err + } + return cache, nil + + // reply := &pb.UserOnlineResp{} + // err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), + // comm.Service_Worker, Rpc_GetAllOnlineUser, nil, reply) + // if err != nil { + // return nil, err + // } + // return reply.Users, err } // 跨服玩家会话 diff --git a/pb/sociaty_msg.pb.go b/pb/sociaty_msg.pb.go index 418c8804e..9b9627083 100644 --- a/pb/sociaty_msg.pb.go +++ b/pb/sociaty_msg.pb.go @@ -3193,7 +3193,7 @@ func (x *SociatyBChallengeFinishResp) GetIntegral() int64 { } // 公会BOSS 阵容推荐 -type SociatyBFormationRecoReq struct { +type SociatyRecommendReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -3201,8 +3201,8 @@ type SociatyBFormationRecoReq struct { Cate int32 `protobuf:"varint,1,opt,name=cate,proto3" json:"cate"` // 1全服排行 2好友排行 } -func (x *SociatyBFormationRecoReq) Reset() { - *x = SociatyBFormationRecoReq{} +func (x *SociatyRecommendReq) Reset() { + *x = SociatyRecommendReq{} if protoimpl.UnsafeEnabled { mi := &file_sociaty_sociaty_msg_proto_msgTypes[61] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -3210,13 +3210,13 @@ func (x *SociatyBFormationRecoReq) Reset() { } } -func (x *SociatyBFormationRecoReq) String() string { +func (x *SociatyRecommendReq) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SociatyBFormationRecoReq) ProtoMessage() {} +func (*SociatyRecommendReq) ProtoMessage() {} -func (x *SociatyBFormationRecoReq) ProtoReflect() protoreflect.Message { +func (x *SociatyRecommendReq) ProtoReflect() protoreflect.Message { mi := &file_sociaty_sociaty_msg_proto_msgTypes[61] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -3228,19 +3228,19 @@ func (x *SociatyBFormationRecoReq) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SociatyBFormationRecoReq.ProtoReflect.Descriptor instead. -func (*SociatyBFormationRecoReq) Descriptor() ([]byte, []int) { +// Deprecated: Use SociatyRecommendReq.ProtoReflect.Descriptor instead. +func (*SociatyRecommendReq) Descriptor() ([]byte, []int) { return file_sociaty_sociaty_msg_proto_rawDescGZIP(), []int{61} } -func (x *SociatyBFormationRecoReq) GetCate() int32 { +func (x *SociatyRecommendReq) GetCate() int32 { if x != nil { return x.Cate } return 0 } -type SociatyBFormationRecoResp struct { +type SociatyRecommendResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -3248,8 +3248,8 @@ type SociatyBFormationRecoResp struct { Teams map[int32]*ChallengeTeam `protobuf:"bytes,1,rep,name=teams,proto3" json:"teams" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } -func (x *SociatyBFormationRecoResp) Reset() { - *x = SociatyBFormationRecoResp{} +func (x *SociatyRecommendResp) Reset() { + *x = SociatyRecommendResp{} if protoimpl.UnsafeEnabled { mi := &file_sociaty_sociaty_msg_proto_msgTypes[62] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -3257,13 +3257,13 @@ func (x *SociatyBFormationRecoResp) Reset() { } } -func (x *SociatyBFormationRecoResp) String() string { +func (x *SociatyRecommendResp) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SociatyBFormationRecoResp) ProtoMessage() {} +func (*SociatyRecommendResp) ProtoMessage() {} -func (x *SociatyBFormationRecoResp) ProtoReflect() protoreflect.Message { +func (x *SociatyRecommendResp) ProtoReflect() protoreflect.Message { mi := &file_sociaty_sociaty_msg_proto_msgTypes[62] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -3275,12 +3275,12 @@ func (x *SociatyBFormationRecoResp) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SociatyBFormationRecoResp.ProtoReflect.Descriptor instead. -func (*SociatyBFormationRecoResp) Descriptor() ([]byte, []int) { +// Deprecated: Use SociatyRecommendResp.ProtoReflect.Descriptor instead. +func (*SociatyRecommendResp) Descriptor() ([]byte, []int) { return file_sociaty_sociaty_msg_proto_rawDescGZIP(), []int{62} } -func (x *SociatyBFormationRecoResp) GetTeams() map[int32]*ChallengeTeam { +func (x *SociatyRecommendResp) GetTeams() map[int32]*ChallengeTeam { if x != nil { return x.Teams } @@ -3937,57 +3937,56 @@ var file_sociaty_sociaty_msg_proto_rawDesc = []byte{ 0x74, 0x22, 0x39, 0x0a, 0x1b, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x22, 0x2e, 0x0a, 0x18, - 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x61, 0x74, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x61, 0x74, 0x65, 0x22, 0xa2, 0x01, 0x0a, - 0x19, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3b, 0x0a, 0x05, 0x74, 0x65, - 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x53, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x79, 0x42, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x63, - 0x6f, 0x52, 0x65, 0x73, 0x70, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x1a, 0x48, 0x0a, 0x0a, 0x54, 0x65, 0x61, 0x6d, 0x73, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, - 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, - 0x01, 0x22, 0x2c, 0x0a, 0x12, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x65, 0x63, - 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, - 0x4b, 0x0a, 0x13, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x65, 0x63, 0x65, 0x69, - 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x79, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x2d, 0x0a, 0x0f, - 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x12, - 0x1a, 0x0a, 0x08, 0x72, 0x61, 0x6e, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x08, 0x72, 0x61, 0x6e, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x22, 0xa1, 0x01, 0x0a, 0x0f, - 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x61, 0x6e, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x65, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x68, 0x65, 0x61, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x61, 0x6e, - 0x6b, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x72, 0x61, 0x6e, 0x6b, - 0x69, 0x6e, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x22, - 0x38, 0x0a, 0x10, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x61, 0x6e, 0x6b, 0x52, - 0x65, 0x73, 0x70, 0x12, 0x24, 0x0a, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x10, 0x2e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x61, 0x6e, 0x6b, 0x49, - 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x22, 0x46, 0x0a, 0x0d, 0x53, 0x6f, 0x63, - 0x69, 0x61, 0x74, 0x79, 0x42, 0x75, 0x79, 0x52, 0x65, 0x71, 0x12, 0x1d, 0x0a, 0x03, 0x61, 0x74, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x73, - 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x61, 0x74, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, 0x79, - 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x75, 0x79, 0x4e, 0x75, - 0x6d, 0x22, 0x22, 0x0a, 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x75, 0x79, 0x52, - 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x75, 0x69, 0x64, 0x2a, 0x42, 0x0a, 0x11, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, - 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, - 0x4c, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x10, 0x01, 0x12, 0x0b, - 0x0a, 0x07, 0x4e, 0x4f, 0x41, 0x50, 0x50, 0x4c, 0x59, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x41, - 0x50, 0x50, 0x4c, 0x59, 0x49, 0x4e, 0x47, 0x10, 0x03, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, - 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x22, 0x29, 0x0a, 0x13, + 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, + 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x04, 0x63, 0x61, 0x74, 0x65, 0x22, 0x98, 0x01, 0x0a, 0x14, 0x53, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, + 0x12, 0x36, 0x0a, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x20, 0x2e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, + 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x1a, 0x48, 0x0a, 0x0a, 0x54, 0x65, 0x61, 0x6d, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, + 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x22, 0x2c, 0x0a, 0x12, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x65, + 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, + 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, + 0x22, 0x4b, 0x0a, 0x13, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x65, 0x63, 0x65, + 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, + 0x74, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x79, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x2d, 0x0a, + 0x0f, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x65, 0x71, + 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x61, 0x6e, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x08, 0x72, 0x61, 0x6e, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x22, 0xa1, 0x01, 0x0a, + 0x0f, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x61, 0x6e, 0x6b, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x65, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x68, 0x65, 0x61, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, + 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x61, + 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x72, 0x61, 0x6e, + 0x6b, 0x69, 0x6e, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, + 0x22, 0x38, 0x0a, 0x10, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x61, 0x6e, 0x6b, + 0x52, 0x65, 0x73, 0x70, 0x12, 0x24, 0x0a, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x61, 0x6e, 0x6b, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x22, 0x46, 0x0a, 0x0d, 0x53, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x75, 0x79, 0x52, 0x65, 0x71, 0x12, 0x1d, 0x0a, 0x03, 0x61, + 0x74, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, + 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x61, 0x74, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, + 0x79, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x75, 0x79, 0x4e, + 0x75, 0x6d, 0x22, 0x22, 0x0a, 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x75, 0x79, + 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x2a, 0x42, 0x0a, 0x11, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, + 0x79, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x07, 0x0a, 0x03, 0x41, + 0x4c, 0x4c, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x10, 0x01, 0x12, + 0x0b, 0x0a, 0x07, 0x4e, 0x4f, 0x41, 0x50, 0x50, 0x4c, 0x59, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, + 0x41, 0x50, 0x50, 0x4c, 0x59, 0x49, 0x4e, 0x47, 0x10, 0x03, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, + 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -4067,8 +4066,8 @@ var file_sociaty_sociaty_msg_proto_goTypes = []interface{}{ (*SociatyBChallengeStartResp)(nil), // 59: SociatyBChallengeStartResp (*SociatyBChallengeFinishReq)(nil), // 60: SociatyBChallengeFinishReq (*SociatyBChallengeFinishResp)(nil), // 61: SociatyBChallengeFinishResp - (*SociatyBFormationRecoReq)(nil), // 62: SociatyBFormationRecoReq - (*SociatyBFormationRecoResp)(nil), // 63: SociatyBFormationRecoResp + (*SociatyRecommendReq)(nil), // 62: SociatyRecommendReq + (*SociatyRecommendResp)(nil), // 63: SociatyRecommendResp (*SociatyBReceiveReq)(nil), // 64: SociatyBReceiveReq (*SociatyBReceiveResp)(nil), // 65: SociatyBReceiveResp (*SociatyBRankReq)(nil), // 66: SociatyBRankReq @@ -4078,7 +4077,7 @@ var file_sociaty_sociaty_msg_proto_goTypes = []interface{}{ (*SociatyBuyResp)(nil), // 70: SociatyBuyResp nil, // 71: SociatyBMainResp.TeamsEntry nil, // 72: SociatyBFormationReq.TeamsEntry - nil, // 73: SociatyBFormationRecoResp.TeamsEntry + nil, // 73: SociatyRecommendResp.TeamsEntry (*DBSociaty)(nil), // 74: DBSociaty (SociatyJob)(0), // 75: SociatyJob (*DBSociatyLog)(nil), // 76: DBSociatyLog @@ -4109,12 +4108,12 @@ var file_sociaty_sociaty_msg_proto_depIdxs = []int32{ 72, // 15: SociatyBFormationReq.teams:type_name -> SociatyBFormationReq.TeamsEntry 80, // 16: SociatyBChallengeFinishReq.ptype:type_name -> PlayType 81, // 17: SociatyBChallengeFinishReq.report:type_name -> BattleReport - 73, // 18: SociatyBFormationRecoResp.teams:type_name -> SociatyBFormationRecoResp.TeamsEntry + 73, // 18: SociatyRecommendResp.teams:type_name -> SociatyRecommendResp.TeamsEntry 67, // 19: SociatyBRankResp.rank:type_name -> SociatyRankInfo 82, // 20: SociatyBuyReq.atn:type_name -> UserAssets 83, // 21: SociatyBMainResp.TeamsEntry.value:type_name -> ChallengeTeam 83, // 22: SociatyBFormationReq.TeamsEntry.value:type_name -> ChallengeTeam - 83, // 23: SociatyBFormationRecoResp.TeamsEntry.value:type_name -> ChallengeTeam + 83, // 23: SociatyRecommendResp.TeamsEntry.value:type_name -> ChallengeTeam 24, // [24:24] is the sub-list for method output_type 24, // [24:24] is the sub-list for method input_type 24, // [24:24] is the sub-list for extension type_name @@ -4865,7 +4864,7 @@ func file_sociaty_sociaty_msg_proto_init() { } } file_sociaty_sociaty_msg_proto_msgTypes[61].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SociatyBFormationRecoReq); i { + switch v := v.(*SociatyRecommendReq); i { case 0: return &v.state case 1: @@ -4877,7 +4876,7 @@ func file_sociaty_sociaty_msg_proto_init() { } } file_sociaty_sociaty_msg_proto_msgTypes[62].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SociatyBFormationRecoResp); i { + switch v := v.(*SociatyRecommendResp); i { case 0: return &v.state case 1: diff --git a/sys/db/init_test.go b/sys/db/init_test.go index 154a946e9..a5947e76f 100644 --- a/sys/db/init_test.go +++ b/sys/db/init_test.go @@ -12,8 +12,6 @@ import ( "sync" "testing" - "github.com/go-redis/redis/v8" - "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" @@ -138,21 +136,24 @@ func TestRa(t *testing.T) { fmt.Printf("err:%v", err) return } else { - s, err2 := sys.ZRevRange("sociatyrank", 0, 10).Result() + s, err2 := sys.ZRevRange("sociatyboss:personalrank", 0, 10).Result() if err2 != nil { t.Fatal(err2) } - m := &redis.Z{Score: float64(1), Member: "dd"} - sys.ZAdd("sociatyrank", m) + // m := &redis.Z{Score: float64(1), Member: "dd"} + // sys.ZAdd("sociatyrank", m) - sys.ZIncrBy("sociatyrank", 10, "a100aa") - sys.ZIncrBy("sociatyrank", 10, "a100ab") + // sys.ZIncrBy("sociatyrank", 10, "a100aa") + // sys.ZIncrBy("sociatyrank", 10, "a100ab") for _, v := range s { - fmt.Println(v) - score, _ := sys.ZScore("sociatyrank", v) - ranking, _ := sys.ZRevRank("sociatyrank", v) + // fmt.Println(v) + score, _ := sys.ZScore("sociatyboss:personalrank", v) + ranking, _ := sys.ZRevRank("sociatyboss:personalrank", v) fmt.Printf("%d %v - %d \n", (ranking + 1), v, int64(score)) + + result, _ := sys.ZRevRank("sociatyboss:personalrank", v) + fmt.Println(result) } }