更新配置

This commit is contained in:
wh_zcy 2023-01-16 19:03:59 +08:00
parent afc3f2ccf0
commit b441c4b272
5 changed files with 58 additions and 46 deletions

View File

@ -1578,7 +1578,7 @@
"main": [ "main": [
{ {
"key": "worldtaskid", "key": "worldtaskid",
"param": 20010 "param": 20050
} }
], ],
"optional": "", "optional": "",
@ -1586,8 +1586,8 @@
"kqbx": 0, "kqbx": 0,
"img": "", "img": "",
"prompt": { "prompt": {
"key": "", "key": "opencond_prompt_slidescreen_up",
"text": "" "text": "请先完成主线剧情"
}, },
"uiid": 0 "uiid": 0
}, },
@ -1600,7 +1600,7 @@
"main": [ "main": [
{ {
"key": "worldtaskid", "key": "worldtaskid",
"param": 20010 "param": 20050
} }
], ],
"optional": "", "optional": "",
@ -1608,8 +1608,8 @@
"kqbx": 0, "kqbx": 0,
"img": "", "img": "",
"prompt": { "prompt": {
"key": "", "key": "opencond_prompt_slidescreen_left",
"text": "" "text": "请先完成主线剧情"
}, },
"uiid": 0 "uiid": 0
}, },
@ -1622,7 +1622,7 @@
"main": [ "main": [
{ {
"key": "worldtaskid", "key": "worldtaskid",
"param": 20010 "param": 20050
} }
], ],
"optional": "", "optional": "",
@ -1630,8 +1630,8 @@
"kqbx": 0, "kqbx": 0,
"img": "", "img": "",
"prompt": { "prompt": {
"key": "", "key": "opencond_prompt_slidescreen_right",
"text": "" "text": "请先完成主线剧情"
}, },
"uiid": 0 "uiid": 0
} }

View File

@ -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 userEx.SociatyTicket = ggd.GuildBossInitialNum
update := map[string]interface{}{ update := map[string]interface{}{
"sociatyTicket": userEx.SociatyTicket, "sociatyTicket": userEx.SociatyTicket,
@ -47,6 +47,7 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
rsp.Ticket = userEx.SociatyTicket
} }
sociaty := this.module.modelSociaty.getUserSociaty(uid) 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) fmt.Sprintf("%s:%s", this.module.modelSociatyBoss.TableName, BOSS_PERSONAL_RANK), uid)
// 公会排名 // 公会排名
rsp.SociatyRanking = this.module.modelSociatyBoss.getRankingByUid( rsp.SociatyRanking = this.module.modelSociatyBoss.getRankingByMember(
fmt.Sprintf("%s:%s", this.module.modelSociatyBoss.TableName, BOSS_SOCIATY_RANK), uid) fmt.Sprintf("%s:%s", this.module.modelSociatyBoss.TableName, BOSS_SOCIATY_RANK), sociaty.Id)
if sm := this.module.modelSociaty.getMemberInfo(sociaty, uid); sm != nil { if sm := this.module.modelSociaty.getMemberInfo(sociaty, uid); sm != nil {
rsp.Teams = sm.Teams rsp.Teams = sm.Teams

View File

@ -73,7 +73,7 @@ func (s *ModelSociatyBoss) initSports() error {
if now.Unix() >= sports.EndTime { if now.Unix() >= sports.EndTime {
sports.EndTime, sports.SettlementTime = s.sportsTime() sports.EndTime, sports.SettlementTime = s.sportsTime()
//归档前赛季数据 //归档前赛季数据
s.reset() s.resetSportsData()
// 更新下一赛季周期结束时间 // 更新下一赛季周期结束时间
update := map[string]interface{}{ update := map[string]interface{}{
"endTime": sports.EndTime, "endTime": sports.EndTime,
@ -110,7 +110,7 @@ func (s *ModelSociatyBoss) updateSociatyBossSports(data map[string]interface{})
} }
} }
// 赛季时间 // 赛季结算和结束时间
func (s *ModelSociatyBoss) sportsTime() (t1, t2 int64) { func (s *ModelSociatyBoss) sportsTime() (t1, t2 int64) {
now := configure.Now() now := configure.Now()
end1 := now.Add(time.Duration(SPORTS_HOUR) * time.Hour) //测试时单位分钟 else Hour 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() return end1.Unix(), end2.Unix()
} }
// 公会BOSS是否开始 // 公会BOSS赛季是否开始
func (s *ModelSociatyBoss) sportsIsStarted() bool { func (s *ModelSociatyBoss) sportsIsStarted() bool {
sports := s.getSociatyBossSports() sports := s.getSociatyBossSports()
if sports == nil { if sports == nil {
@ -137,7 +137,7 @@ func (s *ModelSociatyBoss) sportsIsStarted() bool {
return false return false
} }
// 公会BOSS是否结束 // 公会BOSS赛季是否结束
func (s *ModelSociatyBoss) sportsIsFinished() bool { func (s *ModelSociatyBoss) sportsIsFinished() bool {
sports := s.getSociatyBossSports() sports := s.getSociatyBossSports()
if sports == nil { 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) result, err := s.DBModel.Redis.ZRevRank(key, member)
if err != nil { if err != nil {
return 0 return 0
@ -381,8 +381,8 @@ func (s *ModelSociatyBoss) bossRank(sociaty *pb.DBSociaty, rankType int32) (res
key string key string
) )
// 所有排行记录(个人、公会)
rank := func() []*pb.SociatyRankInfo { rank := func() []*pb.SociatyRankInfo {
// 所有排行记录
rankUids, err := s.queryRankUid(rankCount) rankUids, err := s.queryRankUid(rankCount)
if err != nil { if err != nil {
return nil return nil
@ -399,7 +399,7 @@ func (s *ModelSociatyBoss) bossRank(sociaty *pb.DBSociaty, rankType int32) (res
Name: user.Name, Name: user.Name,
Head: user.Avatar, Head: user.Avatar,
Lv: user.Lv, Lv: user.Lv,
Ranking: s.getRankingByUid(key, user.Uid), Ranking: s.getRankingByMember(key, user.Uid),
Integral: s.getScoreByUid(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 { switch rankType {
case 1: //个人 case 1: //个人
rankCount = 1000 rankCount = 1000 //数据数量
key = fmt.Sprintf("%s:%s", s.TableName, BOSS_PERSONAL_RANK) key = fmt.Sprintf("%s:%s", s.TableName, BOSS_PERSONAL_RANK)
rank() rank()
case 2: //公会 case 2: //公会
rankCount = 50 rankCount = 50 //数据数量
key = fmt.Sprintf("%s:%s", s.TableName, BOSS_SOCIATY_RANK) key = fmt.Sprintf("%s:%s", s.TableName, BOSS_SOCIATY_RANK)
rank() rank()
case 3: //公会成员 case 3: //公会成员排行
for _, m := range sociaty.Members { for _, m := range sociaty.Members {
imodule, err := s.service.GetModule(comm.ModuleUser) imodule, err := s.service.GetModule(comm.ModuleUser)
if err != nil { if err != nil {
@ -429,7 +429,7 @@ func (s *ModelSociatyBoss) bossRank(sociaty *pb.DBSociaty, rankType int32) (res
Name: user.Name, Name: user.Name,
Head: user.Avatar, Head: user.Avatar,
Lv: user.Lv, Lv: user.Lv,
Ranking: s.getRankingByUid(key, user.Uid), Ranking: s.getRankingByMember(key, user.Uid),
Integral: s.getScoreByUid(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 return nil
} }
// 公会BOSS重置数据 // 公会BOSS重置数据(每个周期)
func (s *ModelSociatyBoss) reset() error { func (s *ModelSociatyBoss) resetSportsData() error {
sports := s.getSociatyBossSports() sports := s.getSociatyBossSports()
if sports == nil { if sports == nil {
return errors.New("sociatyboss sports is nil") return errors.New("sociatyboss sports is nil")
@ -455,24 +455,24 @@ func (s *ModelSociatyBoss) reset() error {
var record []*pb.DBSociatyBossRecord var record []*pb.DBSociatyBossRecord
_ = s.GetList(uid, &record) _ = s.GetList(uid, &record)
for _, v := range record { for _, v := range record {
update := map[string]interface{}{ // update := map[string]interface{}{
"status": 1, //归档 // "status": 1, //归档
"tasks": []*pb.ChallengeTask{}, // "tasks": []*pb.ChallengeTask{},
} // }
if err := s.Change(BOSS_SPORTS, update); err != nil { if err := s.DelByUId(uid); err != nil {
s.moduleSociaty.Error("归档玩家赛事记录", log.Field{Key: "uid", Value: v.Uid}, log.Field{Key: "err", Value: err.Error()}) 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 { // if err := s.Del(BOSS_PERSONAL_RANK); err != nil {
s.moduleSociaty.Error("清理排行榜", log.Field{Key: "err", Value: err.Error()}) // s.moduleSociaty.Error("清理排行榜", log.Field{Key: "err", Value: err.Error()})
} // }
return nil return nil
} }
// 是否参赛 // 是否参赛
func (s *ModelSociatyBoss) IsSports(uid string) bool { func (s *ModelSociatyBoss) IsInSports(uid string) bool {
sports := s.getSociatyBossSports() sports := s.getSociatyBossSports()
if sports == nil { if sports == nil {
return false return false
@ -542,6 +542,7 @@ func (s *ModelSociatyBoss) settlement() error {
// 任务状态有变化时更新 // 任务状态有变化时更新
if taskFlag { if taskFlag {
update["tasks"] = tasks update["tasks"] = tasks
cr.Tasks = tasks
} }
if err := s.Change(uid, update); err != nil { if err := s.Change(uid, update); err != nil {
s.moduleSociaty.Error("更新玩家赛事信息", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()}) 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.addSociatyRank(uid, total)
s.moduleSociaty.Debug("结算:", log.Field{Key: "uid", Value: uid}) 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 return nil

View File

@ -169,6 +169,11 @@ func (this *User) UserOnlineList() ([]*pb.CacheUser, error) {
if err := this.modelSession.GetList(comm.RDS_EMPTY, &cache); err != nil { if err := this.modelSession.GetList(comm.RDS_EMPTY, &cache); err != nil {
return nil, err return nil, err
} }
} else {
var err error
if cache, err = this.CrossUserOnlineList(); err != nil {
return nil, err
}
} }
return cache, nil return cache, nil
} }

View File

@ -12,8 +12,6 @@ import (
"sync" "sync"
"testing" "testing"
"github.com/go-redis/redis/v8"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
@ -138,21 +136,24 @@ func TestRa(t *testing.T) {
fmt.Printf("err:%v", err) fmt.Printf("err:%v", err)
return return
} else { } else {
s, err2 := sys.ZRevRange("sociatyrank", 0, 10).Result() s, err2 := sys.ZRevRange("sociatyboss:personalrank", 0, 10).Result()
if err2 != nil { if err2 != nil {
t.Fatal(err2) t.Fatal(err2)
} }
m := &redis.Z{Score: float64(1), Member: "dd"} // m := &redis.Z{Score: float64(1), Member: "dd"}
sys.ZAdd("sociatyrank", m) // sys.ZAdd("sociatyrank", m)
sys.ZIncrBy("sociatyrank", 10, "a100aa") // sys.ZIncrBy("sociatyrank", 10, "a100aa")
sys.ZIncrBy("sociatyrank", 10, "a100ab") // sys.ZIncrBy("sociatyrank", 10, "a100ab")
for _, v := range s { for _, v := range s {
fmt.Println(v) // fmt.Println(v)
score, _ := sys.ZScore("sociatyrank", v) score, _ := sys.ZScore("sociatyboss:personalrank", v)
ranking, _ := sys.ZRevRank("sociatyrank", v) ranking, _ := sys.ZRevRank("sociatyboss:personalrank", v)
fmt.Printf("%d %v - %d \n", (ranking + 1), v, int64(score)) fmt.Printf("%d %v - %d \n", (ranking + 1), v, int64(score))
result, _ := sys.ZRevRank("sociatyboss:personalrank", v)
fmt.Println(result)
} }
} }