From 8a0d5884099e46ead9289ec340759e5be1da2c8b Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Fri, 1 Mar 2024 14:21:20 +0100 Subject: [PATCH] Fix .tou format --- .../jeudego/pairgoth/api/StandingsHandler.kt | 20 ++++++++++++++++--- .../src/main/webapp/tour-information.inc.html | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/StandingsHandler.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/StandingsHandler.kt index ad97f1c..dbb6c77 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/StandingsHandler.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/StandingsHandler.kt @@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletResponse import kotlin.math.max import kotlin.math.min import org.jeudego.pairgoth.model.TimeSystem.TimeSystemType.* +import org.jeudego.pairgoth.server.WebappManager import java.io.OutputStreamWriter import java.nio.charset.StandardCharsets import java.text.DecimalFormat @@ -173,6 +174,7 @@ ${ } private fun exportToFFGFormat(tournament: Tournament<*>, lines: List, writer: PrintWriter) { + val version = WebappManager.properties.getProperty("version")!! val ret = """;name=${tournament.shortName} ;date=${frDate.format(tournament.startDate)} @@ -183,6 +185,15 @@ ${ ;ta=${tournament.timeSystem.adjustedTime() / 60} ;size=${tournament.gobanSize} ;komi=${tournament.komi} +; Generated by Pairgoth $version +; ${ + when (tournament.timeSystem.type) { + CANADIAN -> "Canadian ${tournament.timeSystem.mainTime / 60} minutes, ${tournament.timeSystem.stones} stones / ${tournament.timeSystem.byoyomi / 60} minutes" + JAPANESE -> "Japanese ${tournament.timeSystem.mainTime / 60} minutes, ${tournament.timeSystem.periods} periods of ${tournament.timeSystem.byoyomi / 60} minutes" + FISCHER -> "Fisher ${tournament.timeSystem.mainTime / 60} minutes + ${tournament.timeSystem.increment} seconds${ if (tournament.timeSystem.maxTime > 0) ", max ${tournament.timeSystem.maxTime / 60} minutes" else "" }" + SUDDEN_DEATH -> "Sudden death ${tournament.timeSystem.mainTime / 60} minutes" + } +} ; ;Num Nom Prenom Niv Licence Club ${ @@ -195,11 +206,14 @@ ${ displayRank(player.getInt("rank")!!).uppercase().padStart(3, ' ') } ${ player.getString("ffg") ?: " " - } ${ - (player.getString("club") ?: "").padStart(6).take(6) + } ${ + if (player.getString("country") == "FR") + (player.getString("club") ?: "").padEnd(4).take(4) + else + (player.getString("country") ?: "").padEnd(4).take(4) } ${ player.getArray("results")!!.joinToString(" ") { - (it as String).replace("/", "").replace(Regex("(?<=[bw])$"), "0").padStart(7, ' ') + (it as String).replace(Regex("(?<=[bw])$"), "0").replace("0=", "0= ").padStart(7, ' ') } }" } diff --git a/view-webapp/src/main/webapp/tour-information.inc.html b/view-webapp/src/main/webapp/tour-information.inc.html index 5b3f5d6..f98cbe5 100644 --- a/view-webapp/src/main/webapp/tour-information.inc.html +++ b/view-webapp/src/main/webapp/tour-information.inc.html @@ -10,7 +10,7 @@
- +