fix: 分数计算重置,把kd因素去除,修改为k比例与d比例占比(均10%)

main
NorthLan 2 years ago
parent 0e0339e385
commit 2af5c212d3

@ -32,6 +32,8 @@ type (
damage int64
deDamage int64
killPlayer int64
killUnit int64
deKillUnit int64
}
statPvPReportItem struct {
@ -99,6 +101,8 @@ func (l *StatPvpReportLogic) calcSum(items []*pb.StatPvPReportReq_Item) (sumType
sum.damage += item.Damage
sum.deDamage += item.DeDamage
sum.killPlayer += item.KillPlayer
sum.killUnit += item.KillUnit
sum.deKillUnit += item.DeKillUnit
resp = append(resp, &statPvPReportItem{
uid: item.Uid,
uname: item.Uname,
@ -123,48 +127,45 @@ func (l *StatPvpReportLogic) calcScoreResponse(sum sumType, items []*statPvPRepo
Uname: item.uname,
Score: 0,
}
var damageScore float64
if sum.damage == 0 {
damageScore = 0
} else {
damageScore, _ = decimal.NewFromInt(item.damage).
var tmpScore float64
if sum.damage != 0 {
tmp, _ := decimal.NewFromInt(item.damage).
Div(decimal.NewFromInt(sum.damage)).
Mul(decimal.NewFromFloat32(0.3)).
Mul(decimal.NewFromFloat32(0.45)).
Mul(decimal.NewFromInt(100)).Float64()
tmpScore += tmp
}
var deDamageScore float64
if sum.damage == 0 {
deDamageScore = 0
} else {
deDamageScore, _ = decimal.NewFromInt(item.deDamage).
if sum.damage != 0 {
tmp, _ := decimal.NewFromInt(item.deDamage).
Div(decimal.NewFromInt(sum.deDamage)).
Mul(decimal.NewFromFloat32(0.1)).
Mul(decimal.NewFromFloat32(0.15)).
Mul(decimal.NewFromInt(100)).Float64()
tmpScore += tmp
}
var killPlayerScore float64
if sum.killPlayer == 0 {
killPlayerScore = 0
} else {
killPlayerScore, _ = decimal.NewFromInt(item.killPlayer).
if sum.killPlayer != 0 {
tmp, _ := decimal.NewFromInt(item.killPlayer).
Div(decimal.NewFromInt(sum.killPlayer)).
Mul(decimal.NewFromFloat32(0.3)).
Mul(decimal.NewFromFloat32(0.2)).
Mul(decimal.NewFromInt(100)).Float64()
tmpScore += tmp
}
var kdScore float64
if item.killUnit+item.deKillUnit <= 0 {
kdScore = 0
} else {
kdScore, _ = decimal.NewFromInt(item.killUnit).
Div(decimal.NewFromInt(item.killUnit + item.deKillUnit)).
Mul(decimal.NewFromFloat32(0.3)).
if sum.killUnit != 0 {
tmp, _ := decimal.NewFromInt(item.killUnit).
Div(decimal.NewFromInt(sum.killUnit)).
Mul(decimal.NewFromFloat32(0.1)).
Mul(decimal.NewFromInt(100)).Float64()
tmpScore += tmp
}
if sum.deKillUnit != 0 {
tmp, _ := decimal.NewFromInt(item.deKillUnit).
Div(decimal.NewFromInt(sum.deKillUnit)).
Mul(decimal.NewFromFloat32(0.1)).
Mul(decimal.NewFromInt(100)).Float64()
tmpScore += tmp
}
// z(0-100)=(xi-min(x))/(max(x)-min(x))*100
itemResp.Score += float32(damageScore)
itemResp.Score += float32(deDamageScore)
itemResp.Score += float32(killPlayerScore)
itemResp.Score += float32(kdScore)
itemResp.Score += float32(tmpScore)
if item.firstBlood {
itemResp.Score += 5
}
@ -181,8 +182,8 @@ func (l *StatPvpReportLogic) calcScoreResponse(sum sumType, items []*statPvPRepo
itemResp.Score = 0
}
// 最终进行四舍五入
tmpScore, _ := decimal.NewFromFloat32(itemResp.Score).Round(1).Float64()
itemResp.Score = float32(tmpScore)
tmp, _ := decimal.NewFromFloat32(itemResp.Score).Round(1).Float64()
itemResp.Score = float32(tmp)
item.respItem = itemResp
}

Loading…
Cancel
Save