From dbdbdfe7464cd976d5232f6d191376066eac115a Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Wed, 4 Sep 2024 17:34:56 +0200 Subject: [PATCH] Correctly import opengotha bye players --- .../main/kotlin/org/jeudego/pairgoth/ext/OpenGotha.kt | 11 +++++++++++ api-webapp/src/main/resources/xsd/opengotha.xsd | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/ext/OpenGotha.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/ext/OpenGotha.kt index 6ad2b47..fb87922 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/ext/OpenGotha.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/ext/OpenGotha.kt @@ -181,6 +181,7 @@ object OpenGotha { canonicMap.put("${player.name.replace(" ", "")}${player.firstName.replace(" ", "")}".uppercase(Locale.ENGLISH), it.id) } }.associateByTo(tournament.players) { it.id } + // import games val gamesPerRound = ogTournament.games.game.groupBy { it.roundNumber }.entries.sortedBy { it.key }.map { @@ -206,6 +207,16 @@ object OpenGotha { gamesPerRound.forEachIndexed { index, games -> tournament.games(index + 1).putAll(games) } + // import bye players + if (ogTournament.byePlayers != null) { + for (byePlayer in ogTournament.byePlayers.byePlayer) { + val playerId = canonicMap[byePlayer.player] ?: throw Error("player not found: ${byePlayer.player}") + val round = byePlayer.roundNumber + val game = Game(id = nextGameId, table = 0, white = playerId, black = 0, result = Game.Result.WHITE) + tournament.games(round)[game.id] = game + } + } + return tournament } diff --git a/api-webapp/src/main/resources/xsd/opengotha.xsd b/api-webapp/src/main/resources/xsd/opengotha.xsd index cc11101..4329242 100644 --- a/api-webapp/src/main/resources/xsd/opengotha.xsd +++ b/api-webapp/src/main/resources/xsd/opengotha.xsd @@ -56,7 +56,7 @@ - +