diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/ApiTools.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/ApiTools.kt index 635910f..22817dd 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/ApiTools.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/ApiTools.kt @@ -34,9 +34,7 @@ fun Tournament<*>.getSortedPairables(round: Int, includePreliminary: Boolean = f else ceil(score - epsilon) } - val historyHelper = HistoryHelper( - historyBefore(round + 1), - scoresGetter = { + val historyHelper = HistoryHelper(historyBefore(round + 1)) { if (pairing.type == PairingType.SWISS) wins.mapValues { Pair(0.0, it.value) } else pairables.mapValues { it.value.let { pairable -> @@ -53,16 +51,7 @@ fun Tournament<*>.getSortedPairables(round: Int, includePreliminary: Boolean = f ) } } - }, - scoresXGetter = { - if (pairing.type == PairingType.SWISS) wins.mapValues { it.value } - else pairables.mapValues { - it.value.let { pairable -> - roundScore(pairable.mmBase() + (nbW(pairable) ?: 0.0)) - } - } - } - ) + } val neededCriteria = ArrayList(pairing.placementParams.criteria) if (!neededCriteria.contains(Criterion.NBW)) neededCriteria.add(Criterion.NBW) if (!neededCriteria.contains(Criterion.RATING)) neededCriteria.add(Criterion.RATING) diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/BasePairingHelper.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/BasePairingHelper.kt index 39ba8b5..05b47fd 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/BasePairingHelper.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/BasePairingHelper.kt @@ -18,7 +18,7 @@ abstract class BasePairingHelper( if (pairables.first().let { it is TeamTournament.Team && it.teamOfIndividuals }) TeamOfIndividualsHistoryHelper( history ) { scores } - else HistoryHelper(history, scoresGetter = { scores }, scoresXGetter = { scoresX }) + else HistoryHelper(history) { scores } // Extend pairables with members from all rounds diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/HistoryHelper.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/HistoryHelper.kt index 373954d..14572e5 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/HistoryHelper.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/HistoryHelper.kt @@ -6,12 +6,7 @@ import org.jeudego.pairgoth.model.Game.Result.* open class HistoryHelper( protected val history: List>, // scoresGetter() returns Pair(absentSosValueForOthers, score) where score is nbw for Swiss, mms for MM, ... - scoresGetter: HistoryHelper.()-> Map>, - // scoresXGetter(), defined by default as score - scoresXGetter: HistoryHelper.()-> Map = { - scoresGetter().mapValues { entry -> entry.value.second - } -}) { + scoresGetter: HistoryHelper.()-> Map>) { // List of all the pairables ID present in the history val allPairables = history.flatten() @@ -33,7 +28,9 @@ open class HistoryHelper( } val scoresX by lazy { - scoresXGetter() + scoresGetter().mapValues { entry -> + entry.value.first + (wins[entry.key] ?: 0.0) + } } // Generic helper functions