This commit is contained in:
liwei1dao 2023-12-28 16:35:06 +08:00
commit 4034a37282
2 changed files with 37 additions and 30 deletions

View File

@ -91,7 +91,9 @@ func (this *ModelRank) CheckRank(uid string, boosID int32, difficulty int32, lin
model := db.NewDBModelByExpired(comm.TableVikingRank, conn_) model := db.NewDBModelByExpired(comm.TableVikingRank, conn_)
// 写入排行榜 // 写入排行榜
record := &pb.DBVikingRecord{} record := &pb.DBVikingRecord{
Data: map[int32]*pb.ScoreData{},
}
if err = model.Get(uid, record); err == mgo.MongodbNil { if err = model.Get(uid, record); err == mgo.MongodbNil {
record.Id = primitive.NewObjectID().Hex() record.Id = primitive.NewObjectID().Hex()
record.Data = make(map[int32]*pb.ScoreData, 0) record.Data = make(map[int32]*pb.ScoreData, 0)
@ -111,7 +113,7 @@ func (this *ModelRank) CheckRank(uid string, boosID int32, difficulty int32, lin
tmp := make(map[int32]int32, 0) tmp := make(map[int32]int32, 0)
tmp[difficulty] = costTime tmp[difficulty] = costTime
if record.Data[boosID] == nil { if _, ok := record.Data[boosID]; !ok {
record.Data[boosID] = &pb.ScoreData{ record.Data[boosID] = &pb.ScoreData{
Costime: tmp, Costime: tmp,
Maxnandu: difficulty, Maxnandu: difficulty,
@ -137,27 +139,27 @@ func (this *ModelRank) CheckRank(uid string, boosID int32, difficulty int32, lin
} }
update := make(map[string]interface{}, 0) update := make(map[string]interface{}, 0)
update["uinfo"] = record.Uinfo update["uinfo"] = record.Uinfo
if record.Data == nil {
record.Data = make(map[int32]*pb.ScoreData)
}
if _, ok := record.Data[boosID]; !ok { if _, ok := record.Data[boosID]; !ok {
tmp := make(map[int32]int32, 0)
tmp[difficulty] = costTime
mpLine := make(map[int32]*pb.LineData, 0)
mpLine[difficulty] = line
record.Data[boosID] = &pb.ScoreData{ record.Data[boosID] = &pb.ScoreData{
Costime: map[int32]int32{}, Costime: tmp,
Maxnandu: 0, Maxnandu: difficulty,
Line: map[int32]*pb.LineData{}, Line: mpLine,
} }
}
if record.Data[boosID] == nil {
record.Data[boosID].Costime = make(map[int32]int32, 0)
record.Data[boosID].Line = make(map[int32]*pb.LineData, 0)
}
if record.Data[boosID].Maxnandu < difficulty {
record.Data[boosID].Maxnandu = difficulty
} else { } else {
if record.Data[boosID].Costime[difficulty] > costTime { // 不是新记录不写 if record.Data[boosID].Maxnandu < difficulty {
return record.Data[boosID].Maxnandu = difficulty
} else {
if record.Data[boosID].Costime[difficulty] > costTime { // 不是新记录不写
return
}
} }
} }
record.Data[boosID].Costime[difficulty] = costTime record.Data[boosID].Costime[difficulty] = costTime
record.Data[boosID].Line[difficulty] = line record.Data[boosID].Line[difficulty] = line
update["data"] = record.Data update["data"] = record.Data

View File

@ -122,8 +122,7 @@ func (this *ModelSRank) CheckSeasonRank(uid string, boosID int32, difficulty int
record = &pb.DBVSeasonRecord{ record = &pb.DBVSeasonRecord{
Id: "", Id: "",
Uinfo: &pb.BaseUserInfo{}, Uinfo: &pb.BaseUserInfo{},
Data: map[int32]*pb.HuiheData{}, Data: make(map[int32]*pb.HuiheData, 0),
//Line: &pb.LineData{},
} }
if err = model.Get(uid, record); err == mgo.MongodbNil { if err = model.Get(uid, record); err == mgo.MongodbNil {
record.Id = primitive.NewObjectID().Hex() record.Id = primitive.NewObjectID().Hex()
@ -144,7 +143,7 @@ func (this *ModelSRank) CheckSeasonRank(uid string, boosID int32, difficulty int
tmp := make(map[int32]int32, 0) tmp := make(map[int32]int32, 0)
tmp[difficulty] = huihe tmp[difficulty] = huihe
if record.Data[boosID] == nil { if _, ok := record.Data[boosID]; !ok {
record.Data[boosID] = &pb.HuiheData{ record.Data[boosID] = &pb.HuiheData{
Huihe: tmp, Huihe: tmp,
Maxnandu: difficulty, Maxnandu: difficulty,
@ -158,7 +157,6 @@ func (this *ModelSRank) CheckSeasonRank(uid string, boosID int32, difficulty int
model.Add(uid, record) model.Add(uid, record)
} else if err == nil { } else if err == nil {
record.Uinfo = &pb.BaseUserInfo{ record.Uinfo = &pb.BaseUserInfo{
Uid: uid, Uid: uid,
Sid: user.Sid, Sid: user.Sid,
@ -170,16 +168,23 @@ func (this *ModelSRank) CheckSeasonRank(uid string, boosID int32, difficulty int
Lv: user.Lv, Lv: user.Lv,
} }
update["uinfo"] = record.Uinfo update["uinfo"] = record.Uinfo
if record.Data[boosID] == nil { if _, ok := record.Data[boosID]; !ok {
record.Data[boosID].Huihe = make(map[int32]int32, 0) mpLine := make(map[int32]*pb.LineData, 0)
record.Data[boosID].Line = make(map[int32]*pb.LineData, 0) mpLine[difficulty] = line
} tmp := make(map[int32]int32, 0)
tmp[difficulty] = huihe
if record.Data[boosID].Maxnandu < difficulty { record.Data[boosID] = &pb.HuiheData{
record.Data[boosID].Maxnandu = difficulty Huihe: tmp,
Maxnandu: difficulty,
Line: mpLine,
}
} else { } else {
if record.Data[boosID].Huihe[difficulty] > huihe { // 不是新记录不写 if record.Data[boosID].Maxnandu < difficulty {
return record.Data[boosID].Maxnandu = difficulty
} else {
if record.Data[boosID].Huihe[difficulty] > huihe { // 不是新记录不写
return
}
} }
} }
record.Data[boosID].Huihe[difficulty] = huihe record.Data[boosID].Huihe[difficulty] = huihe