Skip to content

Commit

Permalink
Round multipliers to 2 decimal places
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschwarzer committed Jul 7, 2024
1 parent 8dd7e5e commit f9b0972
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/kotlin/wotw/server/database/model/LeagueSeason.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import wotw.server.game.handlers.GameHandlerType
import wotw.server.seedgen.SeedGeneratorService
import wotw.server.util.assertTransaction
import wotw.server.util.inverseLerp
import java.math.RoundingMode
import java.time.Instant
import java.time.ZoneId
import kotlin.jvm.optionals.getOrNull
Expand Down Expand Up @@ -263,6 +264,14 @@ class LeagueSeason(id: EntityID<Long>) : LongEntity(id) {
gameNearestToAverage.rankingMultiplier += additionalMultiplier.toFloat()
}

// Pass 4: Round multipliers to 2 decimal places
submissions.forEach { submission ->
submission.rankingMultiplier = submission.rankingMultiplier
.toBigDecimal()
.setScale(2, RoundingMode.HALF_UP)
.toFloat()
}

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

0 comments on commit f9b0972

Please sign in to comment.