Skip to content

Commit

Permalink
JSON API: GameMode
Browse files Browse the repository at this point in the history
  • Loading branch information
Istador committed Oct 13, 2024
1 parent 7bc6d13 commit e94c2f7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Server/JsonApi/ApiRequestStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ private static class Player {
private static Mutators Mutators = new Mutators {
["Status/Players/ID"] = (dynamic p, Client c) => p.ID = c.Id,
["Status/Players/Name"] = (dynamic p, Client c) => p.Name = c.Name,
["Status/Players/GameMode"] = (dynamic p, Client c) => p.GameMode = Player.GetGameMode(c),
["Status/Players/Kingdom"] = (dynamic p, Client c) => p.Kingdom = Player.GetKingdom(c),
["Status/Players/Stage"] = (dynamic p, Client c) => p.Stage = Player.GetGamePacket(c)?.Stage ?? null,
["Status/Players/Scenario"] = (dynamic p, Client c) => p.Scenario = Player.GetGamePacket(c)?.ScenarioNum ?? null,
Expand All @@ -110,7 +111,7 @@ private static class Player {


private static dynamic FromClient(Context ctx, Client c) {
dynamic player = new ExpandoObject();
dynamic player = new ExpandoObject();
foreach (var (perm, mutate) in Mutators) {
if (ctx.HasPermission(perm)) {
mutate(player, c);
Expand All @@ -136,6 +137,13 @@ private static dynamic FromClient(Context ctx, Client c) {
}


private static GameMode? GetGameMode(Client c) {
object? gamemode = null;
c.Metadata.TryGetValue("gameMode", out gamemode);
return (GameMode?) gamemode;
}


private static bool? GetTagged(Client c) {
object? seeking = null;
c.Metadata.TryGetValue("seeking", out seeking);
Expand Down

0 comments on commit e94c2f7

Please sign in to comment.