Bug fix bf-3mx7: Fix match index winner badge - use p.Won instead of comparing BotID with WinnerID
The WinnerID field is a player-slot integer as string (e.g. "2"), not a bot_id. The SQL query already computes the correct winner status in p.Won field. Fixed in 3 functions: - matchToSummary: Changed Won: p.BotID == m.WinnerID to Won: p.Won - buildPlaylistMatch: Changed Won: p.BotID == m.WinnerID to Won: p.Won - ratingUpsetMagnitude: Use p.Won to identify winner instead of comparing with m.WinnerID - maxScoreDiff: Use p.Won to identify winner instead of comparing with m.WinnerID - isEvolutionBreakthrough: Find winner using p.Won before checking if evolved This fixes the issue where 984/1000 prod matches had winner_id set but all participants showed won: false. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
af52f05594
commit
9bcbd566b6
1 changed files with 19 additions and 8 deletions
|
|
@ -352,7 +352,7 @@ func matchToSummary(m MatchData, data *IndexData, cfg *Config) MatchSummary {
|
||||||
BotID: p.BotID,
|
BotID: p.BotID,
|
||||||
Name: name,
|
Name: name,
|
||||||
Score: p.Score,
|
Score: p.Score,
|
||||||
Won: p.BotID == m.WinnerID,
|
Won: p.Won,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -979,7 +979,7 @@ func buildPlaylistMatch(m MatchData, order int, data *IndexData, curationTag str
|
||||||
BotID: p.BotID,
|
BotID: p.BotID,
|
||||||
Name: name,
|
Name: name,
|
||||||
Score: p.Score,
|
Score: p.Score,
|
||||||
Won: p.BotID == m.WinnerID,
|
Won: p.Won,
|
||||||
})
|
})
|
||||||
scoreParts = append(scoreParts, fmt.Sprintf("%d", p.Score))
|
scoreParts = append(scoreParts, fmt.Sprintf("%d", p.Score))
|
||||||
}
|
}
|
||||||
|
|
@ -1010,7 +1010,7 @@ func ratingUpsetMagnitude(m MatchData) int {
|
||||||
var winnerRating, bestLoserRating float64
|
var winnerRating, bestLoserRating float64
|
||||||
found := false
|
found := false
|
||||||
for _, p := range m.Participants {
|
for _, p := range m.Participants {
|
||||||
if p.BotID == m.WinnerID {
|
if p.Won {
|
||||||
winnerRating = p.PreMatchRating
|
winnerRating = p.PreMatchRating
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
|
|
@ -1019,7 +1019,7 @@ func ratingUpsetMagnitude(m MatchData) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
for _, p := range m.Participants {
|
for _, p := range m.Participants {
|
||||||
if p.BotID != m.WinnerID && p.PreMatchRating > bestLoserRating {
|
if !p.Won && p.PreMatchRating > bestLoserRating {
|
||||||
bestLoserRating = p.PreMatchRating
|
bestLoserRating = p.PreMatchRating
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1161,14 +1161,14 @@ func maxScoreDiff(m MatchData) int {
|
||||||
}
|
}
|
||||||
var winnerScore int
|
var winnerScore int
|
||||||
for _, p := range m.Participants {
|
for _, p := range m.Participants {
|
||||||
if p.BotID == m.WinnerID {
|
if p.Won {
|
||||||
winnerScore = p.Score
|
winnerScore = p.Score
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maxDiff := 0
|
maxDiff := 0
|
||||||
for _, p := range m.Participants {
|
for _, p := range m.Participants {
|
||||||
if p.BotID != m.WinnerID {
|
if !p.Won {
|
||||||
diff := winnerScore - p.Score
|
diff := winnerScore - p.Score
|
||||||
if diff > maxDiff {
|
if diff > maxDiff {
|
||||||
maxDiff = diff
|
maxDiff = diff
|
||||||
|
|
@ -1249,10 +1249,21 @@ func isEvolutionBreakthrough(m MatchData, data *IndexData) bool {
|
||||||
if m.WinnerID == "" || len(m.Participants) < 2 {
|
if m.WinnerID == "" || len(m.Participants) < 2 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
var winnerBotID string
|
||||||
|
for _, p := range m.Participants {
|
||||||
|
if p.Won {
|
||||||
|
winnerBotID = p.BotID
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if winnerBotID == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
winnerEvolved := false
|
winnerEvolved := false
|
||||||
for _, bot := range data.Bots {
|
for _, bot := range data.Bots {
|
||||||
if bot.ID == m.WinnerID && bot.Evolved {
|
if bot.ID == winnerBotID && bot.Evolved {
|
||||||
winnerEvolved = true
|
winnerEvolved = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !winnerEvolved {
|
if !winnerEvolved {
|
||||||
|
|
@ -1260,7 +1271,7 @@ func isEvolutionBreakthrough(m MatchData, data *IndexData) bool {
|
||||||
}
|
}
|
||||||
// Winner must have beaten someone rated >= 1600
|
// Winner must have beaten someone rated >= 1600
|
||||||
for _, p := range m.Participants {
|
for _, p := range m.Participants {
|
||||||
if p.BotID != m.WinnerID && p.PreMatchRating >= 1600 && !p.Won {
|
if !p.Won && p.PreMatchRating >= 1600 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue