Skip to content

Commit

Permalink
Multiply the worst submission when all bad games are discarded right …
Browse files Browse the repository at this point in the history
…away
  • Loading branch information
timoschwarzer committed Jul 6, 2024
1 parent 1cb16c5 commit 0161114
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/main/kotlin/wotw/server/database/model/LeagueSeason.kt
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,27 @@ class LeagueSeason(id: EntityID<Long>) : LongEntity(id) {

val totalDiscardingSubmissionWeight = discardingSubmissionWeights.values.sum()

discardingSubmissionWeights.forEach { (submission, weight) ->
submission.rankingMultiplier = if (totalDiscardingSubmissionWeight > 0.0) {
(discardedGameRankingMultiplier * (worstSubmissionsToDiscardCount * (weight / totalDiscardingSubmissionWeight))).toFloat()
} else discardedGameRankingMultiplier
// Reset all to 1.0f
submissions.forEach { submission ->
submission.rankingMultiplier = 1.0f
}

submissions.drop(worstSubmissionsToDiscardCount).forEach { submission ->
submission.rankingMultiplier = 1.0f
if (totalDiscardingSubmissionWeight > 0.0) { // If any of the discarded games has > 0 points
discardingSubmissionWeights.forEach { (submission, weight) ->
submission.rankingMultiplier = (discardedGameRankingMultiplier * (worstSubmissionsToDiscardCount * (weight / totalDiscardingSubmissionWeight))).toFloat()
}
} else { // All discarded games are 0 points, we need to
// Discard the worst games right away
discardingSubmissionWeights.forEach { (submission, _) ->
submission.rankingMultiplier = 0.0f
}

// ...multiply the worst submission to account for the missing games
submissions
.firstOrNull { it.points > 0 }
?.let { worstSubmissionWithPoints ->
worstSubmissionWithPoints.rankingMultiplier = 1.0f + discardedGameRankingMultiplier * worstSubmissionsToDiscardCount
}
}

membership.points = submissions.sumOf { (it.points * it.rankingMultiplier).toInt() }
Expand Down

0 comments on commit 0161114

Please sign in to comment.