上传工会战斗排名

This commit is contained in:
liwei 2023-07-26 15:15:32 +08:00
parent e36daa965e
commit b2cb400165
8 changed files with 114 additions and 18 deletions

View File

@ -300,9 +300,11 @@ const (
TableGuildMember = "guildmember"
///工会轮盘
TableUnionroulette = "unionroulette"
TableGuildroulette = "guildoulette"
///工会排行榜
TableUnionrank = "unionrank"
TableGuildGverank = "guildgverank"
///工会战斗排行排行榜
TableGuildGvebattlerank = "guildgvebattlerank"
//全局表
TableGlobal = "global"

View File

@ -111,6 +111,7 @@ func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.GuildGve
Harm: req.Report.Harm,
}
member.Record[req.Boosid] = record
go this.module.modelbattlerank.updateRank(req.Boosid, req.Report.Harm, record.User.Uid)
for i, v := range req.Report.Info.Redflist[0].Team {
if int32(i) == req.Report.Info.Redflist[0].Leadpos && v != nil {
record.CaptainHeroId = v.HeroID

View File

@ -7,7 +7,7 @@ import (
// 参数校验
func (this *apiComp) FriendsRecordCheck(session comm.IUserSession, req *pb.GuildGveFriendsRecordReq) (errdata *pb.ErrorData) {
if len(req.Friends) == 0 || len(req.Friends) > 50 {
if req.QueryType == 1 && (len(req.Friends) == 0 || len(req.Friends) > 50) {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
@ -21,6 +21,7 @@ func (this *apiComp) FriendsRecordCheck(session comm.IUserSession, req *pb.Guild
func (this *apiComp) FriendsRecord(session comm.IUserSession, req *pb.GuildGveFriendsRecordReq) (errdata *pb.ErrorData) {
var (
member []*pb.DBGuildMember
uids []string
record []*pb.DBGveRecord
err error
)
@ -28,7 +29,20 @@ func (this *apiComp) FriendsRecord(session comm.IUserSession, req *pb.GuildGveFr
return
}
if member, err = this.module.modelGuildMember.inquireGuildMembers(req.Friends); err != nil {
if req.QueryType == 0 {
if uids, err = this.module.modelbattlerank.queryRankUser(req.Boosid); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
} else {
uids = req.Friends
}
if member, err = this.module.modelGuildMember.inquireGuildMembers(uids); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),

View File

@ -21,7 +21,7 @@ type ModelUnionroulette struct {
func (this *ModelUnionroulette) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompModel.Init(service, module, comp, options)
this.TableName = comm.TableUnionroulette
this.TableName = comm.TableGuildroulette
this.module = module.(*GuildGve)
return
}

View File

@ -0,0 +1,67 @@
package guildgve
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"sync"
"github.com/go-redis/redis/v8"
)
type Modelbattlerank struct {
modules.MCompModel
module *GuildGve
conflock sync.RWMutex
bossconf *pb.DBGuildGveBossConf
}
func (this *Modelbattlerank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompModel.Init(service, module, comp, options)
this.TableName = comm.TableGuildGvebattlerank
this.module = module.(*GuildGve)
return
}
func (this *Modelbattlerank) Start() (err error) {
err = this.MCompModel.Start()
return
}
func (this *Modelbattlerank) key(boos int32) string {
return fmt.Sprintf("%s:%d", this.TableName, boos)
}
// 获取排行榜前50的用户名单
func (this *Modelbattlerank) queryRankUser(boos int32) (ranks []string, err error) {
var (
key string
result []string
)
key = this.key(boos)
if result, err = this.DBModel.Redis.ZRevRange(key, 0, 50).Result(); err != nil {
this.module.Errorln(err)
return
}
ranks = make([]string, 0)
for i := 0; i < len(result); i += 1 {
ranks = append(ranks, result[i])
}
return
}
// 更新排名
func (this *Modelbattlerank) updateRank(boos int32, score int32, member string) (err error) {
var (
key string
menbers *redis.Z
)
key = this.key(boos)
menbers = &redis.Z{Score: float64(score), Member: member}
if err = this.Redis.ZAdd(key, menbers); err != nil {
this.module.Errorln(err)
}
return
}

View File

@ -25,7 +25,7 @@ type modelRank struct {
func (this *modelRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompModel.Init(service, module, comp, options)
this.TableName = comm.TableUnionrank
this.TableName = comm.TableGuildGverank
this.module = module.(*GuildGve)
return
}

View File

@ -23,6 +23,7 @@ type GuildGve struct {
modelGuildGve *ModelUniongve
modelUnionroulette *ModelUnionroulette
modelGuildMember *ModelGuildMember
modelbattlerank *Modelbattlerank
modelRank *modelRank
configure *MCompConfigure
}
@ -64,6 +65,7 @@ func (this *GuildGve) OnInstallComp() {
this.configure = this.RegisterComp(new(MCompConfigure)).(*MCompConfigure)
this.modelGuildGve = this.RegisterComp(new(ModelUniongve)).(*ModelUniongve)
this.modelGuildMember = this.RegisterComp(new(ModelGuildMember)).(*ModelGuildMember)
this.modelbattlerank = this.RegisterComp(new(Modelbattlerank)).(*Modelbattlerank)
this.modelUnionroulette = this.RegisterComp(new(ModelUnionroulette)).(*ModelUnionroulette)
this.modelRank = this.RegisterComp(new(modelRank)).(*modelRank)
}

View File

@ -977,7 +977,8 @@ type GuildGveFriendsRecordReq struct {
unknownFields protoimpl.UnknownFields
Boosid int32 `protobuf:"varint,1,opt,name=boosid,proto3" json:"boosid"`
Friends []string `protobuf:"bytes,2,rep,name=friends,proto3" json:"friends"` //奖励
QueryType int32 `protobuf:"varint,2,opt,name=queryType,proto3" json:"queryType"` // 0 全服排行榜 1 好友推荐
Friends []string `protobuf:"bytes,3,rep,name=friends,proto3" json:"friends"` //好友id
}
func (x *GuildGveFriendsRecordReq) Reset() {
@ -1019,6 +1020,13 @@ func (x *GuildGveFriendsRecordReq) GetBoosid() int32 {
return 0
}
func (x *GuildGveFriendsRecordReq) GetQueryType() int32 {
if x != nil {
return x.QueryType
}
return 0
}
func (x *GuildGveFriendsRecordReq) GetFriends() []string {
if x != nil {
return x.Friends
@ -1178,18 +1186,20 @@ var file_guildgve_guildgve_msg_proto_rawDesc = []byte{
0x50, 0x75, 0x73, 0x68, 0x12, 0x2e, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x44, 0x42, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x6f,
0x75, 0x6c, 0x65, 0x74, 0x74, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, 0x65,
0x63, 0x6f, 0x72, 0x64, 0x22, 0x4c, 0x0a, 0x18, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x47, 0x76, 0x65,
0x63, 0x6f, 0x72, 0x64, 0x22, 0x6a, 0x0a, 0x18, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x47, 0x76, 0x65,
0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71,
0x12, 0x16, 0x0a, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
0x52, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x72, 0x69, 0x65,
0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e,
0x64, 0x73, 0x22, 0x59, 0x0a, 0x19, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x47, 0x76, 0x65, 0x46, 0x72,
0x69, 0x65, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12,
0x16, 0x0a, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72,
0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x47, 0x76, 0x65, 0x52,
0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x52, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x71, 0x75, 0x65, 0x72,
0x79, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x71, 0x75, 0x65,
0x72, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64,
0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73,
0x22, 0x59, 0x0a, 0x19, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x47, 0x76, 0x65, 0x46, 0x72, 0x69, 0x65,
0x6e, 0x64, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a,
0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62,
0x6f, 0x6f, 0x73, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18,
0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x47, 0x76, 0x65, 0x52, 0x65, 0x63,
0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e,
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (