Game edition ok, and other minor tweaks

This commit is contained in:
Claude Brisson
2024-01-19 05:43:07 +01:00
parent 897246c7a6
commit cffa4ce699
9 changed files with 131 additions and 14 deletions

View File

@@ -13,7 +13,7 @@ interface ApiHandler {
when (request.method) {
"GET" -> get(request, response)
"POST" -> post(request)
"PUT" -> put(request)
"PUT" -> put(request)
"DELETE" -> delete(request)
else -> notImplemented()
}

View File

@@ -16,7 +16,7 @@ interface PairgothApiHandler: ApiHandler {
fun Tournament<*>.dispatchEvent(event: Event, data: Json? = null) {
Event.dispatch(event, Json.Object("tournament" to id, "data" to data))
// when storage is not in memory, the tournament has to be persisted
if (event != Event.tournamentAdded && event != Event.tournamentDeleted && event != Event.gameUpdated)
if (event != Event.tournamentAdded && event != Event.tournamentDeleted)
Store.replaceTournament(this)
}

View File

@@ -71,6 +71,7 @@ object PairingHandler: PairgothApiHandler {
val playing = (tournament.games(round).values).filter { it.id != gameId }.flatMap {
listOf(it.black, it.white)
}.toSet()
if (game.result != Game.Result.UNKNOWN) badRequest("Game already has a result");
game.black = payload.getID("b") ?: badRequest("missing black player id")
game.white = payload.getID("w") ?: badRequest("missing white player id")
tournament.recomputeDUDD(round, game.id)