improved theming, error handling, table sort

This commit is contained in:
Vinzenz Schroeter 2024-04-14 18:26:13 +02:00
parent 35256ba88d
commit 7ce0e543ec
11 changed files with 151 additions and 68 deletions

View file

@ -5,4 +5,16 @@ internal sealed record class Scores(int Kills = 0, int Deaths = 0)
public int Kills { get; set; } = Kills;
public int Deaths { get; set; } = Deaths;
public double Ratio
{
get
{
if (Kills == 0)
return 0;
if (Deaths == 0)
return Kills;
return Kills / (double)Deaths;
}
}
}

View file

@ -32,6 +32,8 @@ public static class Program
name = name.Trim().ToUpperInvariant();
if (name == string.Empty)
return Results.BadRequest("name cannot be blank");
if (name.Length > 12)
return Results.BadRequest("name too long");
var player = playerService.GetOrAdd(name, id);
return player != null
@ -53,7 +55,7 @@ public static class Program
using var ws = await context.WebSockets.AcceptWebSocketAsync();
await clientScreenServer.HandleClient(ws);
return null;
return Results.Empty;
});
app.Map("/controls", async (HttpContext context, [FromQuery] Guid playerId) =>
@ -66,7 +68,7 @@ public static class Program
using var ws = await context.WebSockets.AcceptWebSocketAsync();
await controlsServer.HandleClient(ws, player);
return null;
return Results.Empty;
});
app.Run();