Several bugfixes and finishing touches

This commit is contained in:
Claude Brisson
2023-12-25 12:26:08 +01:00
parent 91e0bc839a
commit e33bc995c6
18 changed files with 264 additions and 38 deletions

View File

@@ -46,7 +46,7 @@ object StandingsHandler: PairgothApiHandler {
RANK -> tournament.pairables.mapValues { it.value.rank }
RATING -> tournament.pairables.mapValues { it.value.rating }
NBW -> historyHelper.wins
MMS -> historyHelper.scores
MMS -> historyHelper.mms
STS -> nullMap
CPS -> nullMap

View File

@@ -142,7 +142,10 @@ object OpenGotha {
country = player.country,
club = player.club
).also {
canonicMap.put("${player.name}${player.firstName}".uppercase(Locale.ENGLISH), it.id)
player.participating.toString().forEachIndexed { i,c ->
if (c == '0') it.skip.add(i + 1)
}
canonicMap.put("${player.name.replace(" ", "")}${player.firstName.replace(" ", "")}".uppercase(Locale.ENGLISH), it.id)
}
}.associateByTo(tournament.players) { it.id }
val gamesPerRound = ogTournament.games.game.groupBy {
@@ -155,7 +158,7 @@ object OpenGotha {
black = canonicMap[game.blackPlayer] ?: throw Error("player not found: ${game.blackPlayer}"),
white = canonicMap[game.whitePlayer] ?: throw Error("player not found: ${game.whitePlayer}"),
handicap = game.handicap,
result = when (game.result) {
result = when (game.result.removeSuffix("_BYDEF")) {
"RESULT_UNKNOWN" -> Game.Result.UNKNOWN
"RESULT_WHITEWINS" -> Game.Result.WHITE
"RESULT_BLACKWINS" -> Game.Result.BLACK

View File

@@ -15,7 +15,7 @@ open class HistoryHelper(protected val history: List<List<Game>>, scoresGetter:
else -> 0.0
}
val scores by lazy {
private val scores by lazy {
scoresGetter()
}
@@ -76,6 +76,9 @@ open class HistoryHelper(protected val history: List<List<Game>>, scoresGetter:
}
}
// define mms to be a synonym of scores
val mms by lazy { scores }
// SOS related functions given a score function
val sos by lazy {
(history.flatten().map { game ->