维京数据校验 时间写入

This commit is contained in:
meixiongfeng 2022-11-15 17:44:41 +08:00
parent 4310615605
commit 96c91542d6
4 changed files with 60 additions and 27 deletions

View File

@ -216,6 +216,9 @@ func (this *MCompConfigure) GetDropReward(dropId int32) (result []*cfg.Gameatn)
result = make([]*cfg.Gameatn, 0)
data := this.GetDropData(dropId)
if len(data) == 0 {
return
}
szW := make([]int32, 0)
for _, value := range data {
szW = append(szW, value.P)

View File

@ -7,6 +7,7 @@ import (
cfg "go_dreamfactory/sys/configure/structs"
"strconv"
"go.mongodb.org/mongo-driver/bson/primitive"
"google.golang.org/protobuf/proto"
)
@ -71,21 +72,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
mapData["boss"] = viking.Boss
}
if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 {
costTime = req.Report.Costtime
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.updateVikingRankList(session, req.Difficulty, req.BossId, req.Report.Info.Redflist[0].Leadpos, sz, req.Report.Costtime)
}
// 耗时校验 当前战斗胜利时间消耗小于之前刷新数据
code, _ = this.module.battle.CheckBattleReport(session, req.Report)
if code != pb.ErrorCode_Success {
@ -103,19 +89,63 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
viking.ChallengeCount++
mapData["challengeCount"] = viking.ChallengeCount
// 写入排行榜
if newChallenge {
this.module.modulerank.SetRankListData("vikingRank"+strconv.Itoa(int(req.BossId)), req.Difficulty<<16+costTime, session.GetUserId())
}
// 时间写入
key := strconv.Itoa(int(req.BossId)) + "_" + strconv.Itoa(int(req.Difficulty))
if t, ok := viking.BossTime[key]; ok {
if t < req.Report.Costtime {
viking.BossTime[key] = t
//if t, ok := viking.BossTime[key]; ok {
if viking.BossTime[key] > costTime || viking.BossTime[key] == 0 { // 刷新记录
viking.BossTime[key] = costTime
szLine := make([]*pb.LineUp, 5)
Leadpos := 0
if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 {
costTime = req.Report.Costtime
Leadpos = int(req.Report.Info.Redflist[0].Leadpos)
for i, v := range req.Report.Info.Redflist[0].Team {
if v != nil {
szLine[i] = &pb.LineUp{
Cid: v.HeroID,
Star: v.Star,
Lv: v.Lv,
}
}
}
}
} else {
viking.BossTime[key] = req.Report.Costtime
// 写入排行榜
objID := ""
if newChallenge { // 插入
userinfo := this.module.ModuleUser.GetUser(session.GetUserId())
new := &pb.DBVikingRank{
Id: primitive.NewObjectID().Hex(),
Uid: session.GetUserId(),
Difficulty: req.Difficulty,
Bosstype: req.BossId,
Nickname: userinfo.Name,
Icon: "",
Lv: userinfo.Lv,
Leadpos: int32(Leadpos),
Line: szLine,
CostTime: costTime,
}
objID = new.Id
this.module.modulerank.AddList(session.GetUserId(), new.Id, new)
} else { // 更新数据
ranks := this.module.modulerank.getVikingRankList(session.GetUserId())
for _, v := range ranks {
if v.Bosstype == req.BossId && v.Difficulty == req.Difficulty {
mapRankData := make(map[string]interface{}, 0)
mapRankData["difficulty"] = req.Difficulty
mapRankData["bosstype"] = req.BossId
mapRankData["Leadpos"] = Leadpos
mapRankData["line"] = szLine
mapRankData["costTime"] = costTime
this.module.modulerank.ChangeUserRank(session.GetUserId(), v.Id, mapRankData)
objID = v.Id
break
}
}
}
this.module.modulerank.SetRankListData("vikingRank"+strconv.Itoa(int(req.BossId)), req.Difficulty<<16+costTime, objID)
}
//}
mapData["bossTime"] = viking.BossTime // 更新时间
if newChallenge { // 新关卡挑战通过 发放首通奖励
if code = this.module.DispenseRes(session, cfg.Firstprize, true); code != pb.ErrorCode_Success {

View File

@ -42,8 +42,8 @@ func (this *apiComp) RankList(session comm.IUserSession, req *pb.VikingRankListR
this.module.Errorln(err)
return
}
_data3 := rd.Val()
for _, v := range _data3 {
_dataList := rd.Val()
for _, v := range _dataList {
result := &pb.DBVikingRank{}
if err = this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil {
szRank = append(szRank, result)

View File

@ -77,7 +77,7 @@ func (this *ModelRank) updateVikingRankList(session comm.IUserSession, difficult
ranks := this.getVikingRankList(session.GetUserId())
bfind := false
for _, v := range ranks {
if v.Bosstype == boosType {
if v.Bosstype == boosType && v.Difficulty == difficulty {
mapRankData := make(map[string]interface{}, 0)
mapRankData["difficulty"] = difficulty
mapRankData["bosstype"] = boosType