查询玩家心魔塔最高层数数据
This commit is contained in:
parent
17465a2f63
commit
531718d3a2
@ -8,6 +8,7 @@ import (
|
||||
|
||||
const (
|
||||
PagodaGetListResp = "getlist"
|
||||
PagodaQueryRecordResp = "queryrecord"
|
||||
PagodaChallengeResp = "challenge"
|
||||
PagodaChallengeOverResp = "challengeover"
|
||||
PagodaGetRewardResp = "getreward"
|
||||
|
@ -92,7 +92,19 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal
|
||||
} else {
|
||||
this.module.Errorf("no found userdata uid:%s", session.GetUserId())
|
||||
}
|
||||
|
||||
if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 {
|
||||
sz := make([]*pb.LineUp, 5)
|
||||
for i, v := range req.Report.Info.Redflist[0].Team {
|
||||
if v != nil {
|
||||
sz[i] = &pb.LineUp{
|
||||
Cid: v.HeroID,
|
||||
Star: v.Star,
|
||||
Lv: v.Lv,
|
||||
}
|
||||
}
|
||||
}
|
||||
this.module.modulerank.addPagodaList(session, pagoda, req.Report.Info.Redflist[0].Leadpos, sz, req.Report.Costtime)
|
||||
}
|
||||
// 普通塔通关了
|
||||
Nomalcfg := this.module.configure.GetPagodaConfigData(comm.PagodaType, pagoda.PagodaId+1)
|
||||
if Nomalcfg == nil { // 创建赛季塔数据
|
||||
|
37
modules/pagoda/api_queryrecord.go
Normal file
37
modules/pagoda/api_queryrecord.go
Normal file
@ -0,0 +1,37 @@
|
||||
package pagoda
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) QueryRecordCheck(session comm.IUserSession, req *pb.PagodaQueryRecordReq) (code pb.ErrorCode) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
///获取主线关卡信息
|
||||
func (this *apiComp) QueryRecord(session comm.IUserSession, req *pb.PagodaQueryRecordReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
record *pb.DBPagodaRecord
|
||||
)
|
||||
|
||||
list, _ := this.module.modelPagoda.getPagodaList(session.GetUserId())
|
||||
if list == nil { // redis没有数据
|
||||
list = &pb.DBPagoda{}
|
||||
list.Id = primitive.NewObjectID().Hex()
|
||||
|
||||
list.Uid = session.GetUserId()
|
||||
list.PagodaId = 0 // 初始数据0层
|
||||
list.Type = comm.PagodaType
|
||||
this.module.modelPagoda.addNewPagoda(session.GetUserId(), list)
|
||||
} else {
|
||||
record = this.module.modelPagoda.getPagodaRankList(session.GetUserId(), list.PagodaId)
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), PagodaQueryRecordResp, &pb.PagodaQueryRecordResp{Data: record})
|
||||
return
|
||||
}
|
@ -22,11 +22,18 @@ func (this *apiComp) RankList(session comm.IUserSession, req *pb.PagodaRankListR
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
if req.FloorId == 0 && req.Friend == false {
|
||||
if !req.Friend {
|
||||
if req.FloorId == 0 {
|
||||
szRank, err = this.module.modulerank.GetRankData()
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
}
|
||||
} else {
|
||||
szRank, err = this.module.modulerank.GetFloorRankList(req.FloorId)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), PagodaRankListResp, &pb.PagodaRankListResp{Ranks: szRank})
|
||||
|
@ -53,3 +53,17 @@ func (this *ModelPagoda) addNewPagoda(uId string, data *pb.DBPagoda) (err error)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *ModelPagoda) getPagodaRankList(uid string, floorid int32) *pb.DBPagodaRecord {
|
||||
pagodaRank := make([]*pb.DBPagodaRecord, 0)
|
||||
err := this.GetList(uid, &pagodaRank)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
for _, v := range pagodaRank {
|
||||
if v.PagodaId == floorid {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -67,6 +67,29 @@ func (this *ModelRank) getPagodaRankList(uid string) []*pb.DBPagodaRecord {
|
||||
}
|
||||
return pagodaRank
|
||||
}
|
||||
func (this *ModelRank) addPagodaList(session comm.IUserSession, data *pb.DBPagoda, Leadpos int32, line []*pb.LineUp, costTime int32) {
|
||||
userinfo := this.modulePagoda.ModuleUser.GetUser(session.GetUserId())
|
||||
new := &pb.DBPagodaRecord{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Uid: session.GetUserId(),
|
||||
PagodaId: data.PagodaId,
|
||||
Type: data.Type,
|
||||
Nickname: userinfo.Name,
|
||||
Icon: "", // icon 暂无
|
||||
Lv: userinfo.Lv,
|
||||
CostTime: costTime,
|
||||
Line: line,
|
||||
}
|
||||
this.AddList(session.GetUserId(), new.Id, new) //写爬塔记录
|
||||
// 查询本层是否上榜
|
||||
rankData, ilen, err1 := this.GetFloorLastRankData(data.PagodaId)
|
||||
if err1 == nil {
|
||||
if ilen < comm.MaxRankNum || rankData.CostTime < costTime {
|
||||
this.ChangeFloorRankList(session, data.PagodaId, new)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 插入新的排行数据
|
||||
func (this *ModelRank) addPagodaRankList(session comm.IUserSession, data *pb.DBSeasonPagoda, Leadpos int32, line []*pb.LineUp, costTime int32) {
|
||||
@ -104,7 +127,7 @@ func (this *ModelRank) GetFloorRankList(floor int32) (result []*pb.DBPagodaRecor
|
||||
result = make([]*pb.DBPagodaRecord, len(temp))
|
||||
for n, v := range temp {
|
||||
result[n] = v
|
||||
n++
|
||||
//n++
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -136,15 +159,19 @@ func (this *ModelRank) ChangeFloorRankList(session comm.IUserSession, floor int3
|
||||
this.modulePagoda.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
// 排序
|
||||
sort.SliceStable(temp, func(i, j int) bool {
|
||||
return temp[i].CostTime < temp[j].CostTime
|
||||
})
|
||||
|
||||
iLne := len(temp)
|
||||
if this.Redis.RPush(key, temp); err != nil {
|
||||
this.modulePagoda.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
err = this.Redis.Ltrim(key, -1*comm.MaxRankNum, -1) //对一个列表进行修剪
|
||||
if iLne > comm.MaxRankNum {
|
||||
iLne = comm.MaxRankNum
|
||||
}
|
||||
err = this.Redis.Ltrim(key, -1*iLne, -1) //对一个列表进行修剪
|
||||
if err != nil {
|
||||
log.Errorf("delete failed")
|
||||
}
|
||||
|
@ -550,6 +550,92 @@ func (x *PagodaRankListResp) GetRanks() []*DBPagodaRecord {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 查询玩家最佳通关记录数据
|
||||
type PagodaQueryRecordReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *PagodaQueryRecordReq) Reset() {
|
||||
*x = PagodaQueryRecordReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_pagoda_pagoda_msg_proto_msgTypes[10]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *PagodaQueryRecordReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PagodaQueryRecordReq) ProtoMessage() {}
|
||||
|
||||
func (x *PagodaQueryRecordReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pagoda_pagoda_msg_proto_msgTypes[10]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use PagodaQueryRecordReq.ProtoReflect.Descriptor instead.
|
||||
func (*PagodaQueryRecordReq) Descriptor() ([]byte, []int) {
|
||||
return file_pagoda_pagoda_msg_proto_rawDescGZIP(), []int{10}
|
||||
}
|
||||
|
||||
type PagodaQueryRecordResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Data *DBPagodaRecord `protobuf:"bytes,1,opt,name=data,proto3" json:"data"`
|
||||
}
|
||||
|
||||
func (x *PagodaQueryRecordResp) Reset() {
|
||||
*x = PagodaQueryRecordResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_pagoda_pagoda_msg_proto_msgTypes[11]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *PagodaQueryRecordResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PagodaQueryRecordResp) ProtoMessage() {}
|
||||
|
||||
func (x *PagodaQueryRecordResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pagoda_pagoda_msg_proto_msgTypes[11]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use PagodaQueryRecordResp.ProtoReflect.Descriptor instead.
|
||||
func (*PagodaQueryRecordResp) Descriptor() ([]byte, []int) {
|
||||
return file_pagoda_pagoda_msg_proto_rawDescGZIP(), []int{11}
|
||||
}
|
||||
|
||||
func (x *PagodaQueryRecordResp) GetData() *DBPagodaRecord {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_pagoda_pagoda_msg_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_pagoda_pagoda_msg_proto_rawDesc = []byte{
|
||||
@ -602,8 +688,14 @@ var file_pagoda_pagoda_msg_proto_rawDesc = []byte{
|
||||
0x64, 0x22, 0x3b, 0x0a, 0x12, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x61, 0x6e, 0x6b, 0x4c,
|
||||
0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x25, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73,
|
||||
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x67, 0x6f, 0x64,
|
||||
0x61, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x42, 0x06,
|
||||
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x61, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x22, 0x16,
|
||||
0x0a, 0x14, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x63,
|
||||
0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x22, 0x3c, 0x0a, 0x15, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61,
|
||||
0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12,
|
||||
0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e,
|
||||
0x44, 0x42, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x04,
|
||||
0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -618,7 +710,7 @@ func file_pagoda_pagoda_msg_proto_rawDescGZIP() []byte {
|
||||
return file_pagoda_pagoda_msg_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_pagoda_pagoda_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
|
||||
var file_pagoda_pagoda_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
|
||||
var file_pagoda_pagoda_msg_proto_goTypes = []interface{}{
|
||||
(*PagodaGetListReq)(nil), // 0: PagodaGetListReq
|
||||
(*PagodaGetListResp)(nil), // 1: PagodaGetListResp
|
||||
@ -630,23 +722,26 @@ var file_pagoda_pagoda_msg_proto_goTypes = []interface{}{
|
||||
(*PagodaChallengeOverResp)(nil), // 7: PagodaChallengeOverResp
|
||||
(*PagodaRankListReq)(nil), // 8: PagodaRankListReq
|
||||
(*PagodaRankListResp)(nil), // 9: PagodaRankListResp
|
||||
(*DBPagoda)(nil), // 10: DBPagoda
|
||||
(*BattleInfo)(nil), // 11: BattleInfo
|
||||
(*BattleReport)(nil), // 12: BattleReport
|
||||
(*DBPagodaRecord)(nil), // 13: DBPagodaRecord
|
||||
(*PagodaQueryRecordReq)(nil), // 10: PagodaQueryRecordReq
|
||||
(*PagodaQueryRecordResp)(nil), // 11: PagodaQueryRecordResp
|
||||
(*DBPagoda)(nil), // 12: DBPagoda
|
||||
(*BattleInfo)(nil), // 13: BattleInfo
|
||||
(*BattleReport)(nil), // 14: BattleReport
|
||||
(*DBPagodaRecord)(nil), // 15: DBPagodaRecord
|
||||
}
|
||||
var file_pagoda_pagoda_msg_proto_depIdxs = []int32{
|
||||
10, // 0: PagodaGetListResp.data:type_name -> DBPagoda
|
||||
10, // 1: PagodaGetRewardResp.data:type_name -> DBPagoda
|
||||
11, // 2: PagodaChallengeResp.info:type_name -> BattleInfo
|
||||
12, // 3: PagodaChallengeOverReq.report:type_name -> BattleReport
|
||||
10, // 4: PagodaChallengeOverResp.data:type_name -> DBPagoda
|
||||
13, // 5: PagodaRankListResp.ranks:type_name -> DBPagodaRecord
|
||||
6, // [6:6] is the sub-list for method output_type
|
||||
6, // [6:6] is the sub-list for method input_type
|
||||
6, // [6:6] is the sub-list for extension type_name
|
||||
6, // [6:6] is the sub-list for extension extendee
|
||||
0, // [0:6] is the sub-list for field type_name
|
||||
12, // 0: PagodaGetListResp.data:type_name -> DBPagoda
|
||||
12, // 1: PagodaGetRewardResp.data:type_name -> DBPagoda
|
||||
13, // 2: PagodaChallengeResp.info:type_name -> BattleInfo
|
||||
14, // 3: PagodaChallengeOverReq.report:type_name -> BattleReport
|
||||
12, // 4: PagodaChallengeOverResp.data:type_name -> DBPagoda
|
||||
15, // 5: PagodaRankListResp.ranks:type_name -> DBPagodaRecord
|
||||
15, // 6: PagodaQueryRecordResp.data:type_name -> DBPagodaRecord
|
||||
7, // [7:7] is the sub-list for method output_type
|
||||
7, // [7:7] is the sub-list for method input_type
|
||||
7, // [7:7] is the sub-list for extension type_name
|
||||
7, // [7:7] is the sub-list for extension extendee
|
||||
0, // [0:7] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_pagoda_pagoda_msg_proto_init() }
|
||||
@ -777,6 +872,30 @@ func file_pagoda_pagoda_msg_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_pagoda_pagoda_msg_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*PagodaQueryRecordReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_pagoda_pagoda_msg_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*PagodaQueryRecordResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -784,7 +903,7 @@ func file_pagoda_pagoda_msg_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_pagoda_pagoda_msg_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 10,
|
||||
NumMessages: 12,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user