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 ac741a3..134862d 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 @@ -39,20 +39,26 @@ fun Tournament<*>.getSortedPairables(round: Int, includePreliminary: Boolean = f // CB TODO - factorize history helper creation between here and solver classes 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 -> - val mmBase = pairable.mmBase() - val score = roundScore(mmBase + - (nbW(pairable) ?: 0.0) + - (1..round).map { round -> - if (playersPerRound.getOrNull(round - 1)?.contains(pairable.id) == true) 0.0 else 1.0 - }.sum() * pairing.pairingParams.main.mmsValueAbsent) - Pair( - if (pairing.pairingParams.main.sosValueAbsentUseBase) mmBase - else roundScore(mmBase + round/2), - score - ) + if (pairing.type == PairingType.SWISS) { + pairables.mapValues { + Pair(0.0, wins[it.key] ?: 0.0) + } + } + else { + pairables.mapValues { + it.value.let { pairable -> + val mmBase = pairable.mmBase() + val score = roundScore(mmBase + + (nbW(pairable) ?: 0.0) + + (1..round).map { round -> + if (playersPerRound.getOrNull(round - 1)?.contains(pairable.id) == true) 0.0 else 1.0 + }.sum() * pairing.pairingParams.main.mmsValueAbsent) + Pair( + if (pairing.pairingParams.main.sosValueAbsentUseBase) mmBase + else roundScore(mmBase + round/2), + score + ) + } } } }