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

main
NorthLan 2 years ago
parent 0e0339e385
commit 2af5c212d3

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

Loading…
Cancel
Save