维京数据校验 时间写入
This commit is contained in:
parent
4310615605
commit
96c91542d6
@ -216,6 +216,9 @@ func (this *MCompConfigure) GetDropReward(dropId int32) (result []*cfg.Gameatn)
|
|||||||
result = make([]*cfg.Gameatn, 0)
|
result = make([]*cfg.Gameatn, 0)
|
||||||
|
|
||||||
data := this.GetDropData(dropId)
|
data := this.GetDropData(dropId)
|
||||||
|
if len(data) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
szW := make([]int32, 0)
|
szW := make([]int32, 0)
|
||||||
for _, value := range data {
|
for _, value := range data {
|
||||||
szW = append(szW, value.P)
|
szW = append(szW, value.P)
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -71,21 +72,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
|||||||
mapData["boss"] = viking.Boss
|
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)
|
code, _ = this.module.battle.CheckBattleReport(session, req.Report)
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
@ -103,19 +89,63 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
|||||||
viking.ChallengeCount++
|
viking.ChallengeCount++
|
||||||
mapData["challengeCount"] = 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))
|
key := strconv.Itoa(int(req.BossId)) + "_" + strconv.Itoa(int(req.Difficulty))
|
||||||
if t, ok := viking.BossTime[key]; ok {
|
//if t, ok := viking.BossTime[key]; ok {
|
||||||
if t < req.Report.Costtime {
|
if viking.BossTime[key] > costTime || viking.BossTime[key] == 0 { // 刷新记录
|
||||||
viking.BossTime[key] = t
|
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 // 更新时间
|
mapData["bossTime"] = viking.BossTime // 更新时间
|
||||||
if newChallenge { // 新关卡挑战通过 发放首通奖励
|
if newChallenge { // 新关卡挑战通过 发放首通奖励
|
||||||
if code = this.module.DispenseRes(session, cfg.Firstprize, true); code != pb.ErrorCode_Success {
|
if code = this.module.DispenseRes(session, cfg.Firstprize, true); code != pb.ErrorCode_Success {
|
||||||
|
@ -42,8 +42,8 @@ func (this *apiComp) RankList(session comm.IUserSession, req *pb.VikingRankListR
|
|||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_data3 := rd.Val()
|
_dataList := rd.Val()
|
||||||
for _, v := range _data3 {
|
for _, v := range _dataList {
|
||||||
result := &pb.DBVikingRank{}
|
result := &pb.DBVikingRank{}
|
||||||
if err = this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil {
|
if err = this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil {
|
||||||
szRank = append(szRank, result)
|
szRank = append(szRank, result)
|
||||||
|
@ -77,7 +77,7 @@ func (this *ModelRank) updateVikingRankList(session comm.IUserSession, difficult
|
|||||||
ranks := this.getVikingRankList(session.GetUserId())
|
ranks := this.getVikingRankList(session.GetUserId())
|
||||||
bfind := false
|
bfind := false
|
||||||
for _, v := range ranks {
|
for _, v := range ranks {
|
||||||
if v.Bosstype == boosType {
|
if v.Bosstype == boosType && v.Difficulty == difficulty {
|
||||||
mapRankData := make(map[string]interface{}, 0)
|
mapRankData := make(map[string]interface{}, 0)
|
||||||
mapRankData["difficulty"] = difficulty
|
mapRankData["difficulty"] = difficulty
|
||||||
mapRankData["bosstype"] = boosType
|
mapRankData["bosstype"] = boosType
|
||||||
|
Loading…
Reference in New Issue
Block a user