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/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/model_sociatyboss.go b/modules/sociaty/model_sociatyboss.go index 473863c47..c86bbce6c 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,24 +455,24 @@ func (s *ModelSociatyBoss) reset() error { var record []*pb.DBSociatyBossRecord _ = s.GetList(uid, &record) for _, v := range record { - update := map[string]interface{}{ - "status": 1, //归档 - "tasks": []*pb.ChallengeTask{}, - } - 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()}) + // update := map[string]interface{}{ + // "status": 1, //归档 + // "tasks": []*pb.ChallengeTask{}, + // } + 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 @@ -542,6 +542,7 @@ func (s *ModelSociatyBoss) settlement() error { // 任务状态有变化时更新 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()}) @@ -554,6 +555,10 @@ func (s *ModelSociatyBoss) settlement() error { s.addSociatyRank(uid, total) s.moduleSociaty.Debug("结算:", log.Field{Key: "uid", Value: uid}) + //归档赛季记录 + if err := s.AddList(comm.RDS_EMPTY, uid, cr); err != nil { + s.moduleSociaty.Error("归档玩家赛季数据", log.Field{Key: "err", Value: err.Error()}) + } } return nil diff --git a/modules/user/module.go b/modules/user/module.go index 1522ebc1d..509bb2457 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -169,6 +169,11 @@ 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 } 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) } }