This commit is contained in:
meixiongfeng 2023-01-17 12:39:50 +08:00
commit 1d2e7edd32
10 changed files with 233 additions and 128 deletions

View File

@ -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
}

View File

@ -42,6 +42,7 @@ const (
SociatySubTypeBuy = "buy"
SociatySubTypeBuynum = "buynum"
SociatySubTypeBreceive = "breceive"
SociatySubTypeRecommend = "recommend"
)
type apiComp struct {

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
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

View File

@ -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,

View File

@ -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
}

View File

@ -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()
}
}

View File

@ -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
}

View File

@ -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
}
// 跨服玩家会话

View File

@ -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:

View File

@ -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)
}
}