feat: 添加段位保护,添加失败排名保护。

main
NorthLan 3 years ago
parent bc66e55bf0
commit 557686a782

@ -99,8 +99,10 @@ Coin:
Grade:
BravePointCost: [0,300,320,350,400,450,500,600,800,1000]
MaxBravePoint: 3000
WinScoreThreshold: 32
MinUserCount: 8
WinScoreThreshold: 18
MinUserCount: 4
ProtectedGradeThreshold: 2
ProtectedGradeLost: 1
Elite:
LiveDict: { "1": "0", "2": "1001", "3": "1002", "4": "1003" }
DefaultId: 0

@ -116,7 +116,8 @@ func (m *Manager) reportItem(ctx context.Context, tx *gorm.DB, item ReportReq, w
model.DefaultUserGradeLevel,
model.DefaultUserGradeStar,
0,
item.Score)
item.Score,
item.Position)
dbModel.Grade = int64(grade.Grade)
dbModel.Level = int64(grade.Level)
dbModel.Star = int64(grade.Star)
@ -142,7 +143,8 @@ func (m *Manager) reportItem(ctx context.Context, tx *gorm.DB, item ReportReq, w
dbModel.Level,
dbModel.Star,
dbModel.BravePoint,
item.Score)
item.Score,
item.Position)
dbModel.Grade = int64(grade.Grade)
dbModel.Level = int64(grade.Level)
dbModel.Star = int64(grade.Star)
@ -164,7 +166,7 @@ func (m *Manager) reportItem(ctx context.Context, tx *gorm.DB, item ReportReq, w
return resp, nil
}
func (m *Manager) calcRank(win bool, userCountSatisfied bool, grade, level, star, bravePoint int64, score float32) (g pb.Grade, result pb.StatPvPReportResp_GradeResult, reason pb.StatPvPReportResp_GradeReason) {
func (m *Manager) calcRank(win bool, userCountSatisfied bool, grade, level, star, bravePoint int64, score float32, position int32) (g pb.Grade, result pb.StatPvPReportResp_GradeResult, reason pb.StatPvPReportResp_GradeReason) {
g.Grade = int32(grade)
g.Level = int32(level)
g.Star = int32(star)
@ -208,6 +210,26 @@ func (m *Manager) calcRank(win bool, userCountSatisfied bool, grade, level, star
}
}
} else {
// 大段位保护
if grade <= m.config.Grade.ProtectedGradeThreshold {
g.Grade = int32(grade)
g.Level = int32(level)
g.Star = int32(star)
g.BravePoint = bravePoint
reason = pb.StatPvPReportResp_Lost
result = pb.StatPvPReportResp_Keep
return
}
// 名次保护
if position <= m.config.Grade.ProtectedGradeLost {
g.Grade = int32(grade)
g.Level = int32(level)
g.Star = int32(star)
g.BravePoint = bravePoint
reason = pb.StatPvPReportResp_Lost
result = pb.StatPvPReportResp_Keep
return
}
// 段位的骁勇分减扣规则
bravePointCost := m.config.Grade.BravePointCost[grade]
if bravePoint >= bravePointCost {

@ -101,10 +101,12 @@ type (
}
// 段位
Grade struct {
BravePointCost []int64 // 骁勇分抵扣规则对于grade等级
MaxBravePoint int64 // 最大骁勇分
WinScoreThreshold float32 // 获胜升段分数阈值
MinUserCount int // 最小段位计算用户量
BravePointCost []int64 // 骁勇分抵扣规则对于grade等级
MaxBravePoint int64 // 最大骁勇分
WinScoreThreshold float32 // 获胜升段分数阈值
MinUserCount int // 最小段位计算用户量
ProtectedGradeThreshold int64 // 保护段位阈值(大段位)
ProtectedGradeLost int32 // 保护段位(失败方)名次
}
// 精英单位
Elite Elite

Loading…
Cancel
Save