diff --git a/DDApp/DDApplication/DDApplication.csproj b/DDApp/DDApplication/DDApplication.csproj index be2c0e3..c744914 100644 --- a/DDApp/DDApplication/DDApplication.csproj +++ b/DDApp/DDApplication/DDApplication.csproj @@ -5,17 +5,26 @@ enable app.manifest true - - + c93b84d8-b4e9-4725-84e3-00a10f74073f + - - - - + + + + None All + + + + + + - + + + + \ No newline at end of file diff --git a/DDApp/DDApplication/DigitalDojoApi.json b/DDApp/DDApplication/DigitalDojoApi.json new file mode 100644 index 0000000..189762a --- /dev/null +++ b/DDApp/DDApplication/DigitalDojoApi.json @@ -0,0 +1,1253 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "CIT.Gaming.Web.API", + "version": "1.0" + }, + "paths": { + "/api/player/{playerToken}/hit/{dir}": { + "post": { + "tags": [ + "Player" + ], + "parameters": [ + { + "name": "playerToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "name": "dir", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/HitEntityAsyncResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/HitEntityAsyncResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/HitEntityAsyncResponse" + } + } + } + } + } + } + }, + "/api/player/{playerToken}/move/{dir}": { + "post": { + "tags": [ + "Player" + ], + "parameters": [ + { + "name": "playerToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "name": "dir", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/MoveEntityAsyncResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/MoveEntityAsyncResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/MoveEntityAsyncResponse" + } + } + } + } + } + } + }, + "/api/player/{playerToken}/peek/{dir}": { + "get": { + "tags": [ + "Player" + ], + "parameters": [ + { + "name": "playerToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "name": "dir", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/PeekEntitiesAsyncResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/PeekEntitiesAsyncResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/PeekEntitiesAsyncResponse" + } + } + } + } + } + } + }, + "/api/player/{playerToken}/stats": { + "get": { + "tags": [ + "Player" + ], + "parameters": [ + { + "name": "playerToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/PlayerStatisticsResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/PlayerStatisticsResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/PlayerStatisticsResponse" + } + } + } + } + } + } + }, + "/api/player/{playerToken}/scan": { + "get": { + "tags": [ + "Player" + ], + "parameters": [ + { + "name": "playerToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ScanAsyncResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ScanAsyncResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ScanAsyncResponse" + } + } + } + } + } + } + }, + "/api/player/{playerToken}/specialattack": { + "post": { + "tags": [ + "Player" + ], + "parameters": [ + { + "name": "playerToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/SpecialAttackAsyncResult" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/SpecialAttackAsyncResult" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/SpecialAttackAsyncResult" + } + } + } + } + } + } + }, + "/api/player/{playerToken}/radar": { + "get": { + "tags": [ + "Player" + ], + "parameters": [ + { + "name": "playerToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/RadarAsyncResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/RadarAsyncResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/RadarAsyncResponse" + } + } + } + } + } + } + }, + "/api/player/{playerToken}/dash/{direction}": { + "post": { + "tags": [ + "Player" + ], + "parameters": [ + { + "name": "playerToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "name": "direction", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/DashAsyncResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/DashAsyncResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/DashAsyncResponse" + } + } + } + } + } + } + }, + "/api/player/{playerToken}/teleport/{x}/{y}": { + "get": { + "tags": [ + "Player" + ], + "parameters": [ + { + "name": "playerToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "name": "x", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "y", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/TeleportAsyncResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/TeleportAsyncResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/TeleportAsyncResponse" + } + } + } + } + } + } + }, + "/api/player/{playerToken}/shoot/{direction}": { + "post": { + "tags": [ + "Player" + ], + "parameters": [ + { + "name": "playerToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "name": "direction", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ShootAsyncResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ShootAsyncResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ShootAsyncResponse" + } + } + } + } + } + } + }, + "/api/game/{playerToken}/status": { + "get": { + "tags": [ + "Singleplayer" + ], + "parameters": [ + { + "name": "playerToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/GetStatusResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetStatusResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/GetStatusResponse" + } + } + } + } + } + } + }, + "/api/game/{playerToken}/create": { + "post": { + "tags": [ + "Singleplayer" + ], + "parameters": [ + { + "name": "playerToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/StartGameAsyncResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/StartGameAsyncResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/StartGameAsyncResponse" + } + } + } + } + } + } + }, + "/api/game/{playerToken}/close": { + "post": { + "tags": [ + "Singleplayer" + ], + "parameters": [ + { + "name": "playerToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/StopGameResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/StopGameResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/StopGameResponse" + } + } + } + } + } + } + }, + "/api/game/{gameToken}/remainingtime": { + "get": { + "tags": [ + "Singleplayer" + ], + "parameters": [ + { + "name": "gameToken", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/GetRemainingTimeResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetRemainingTimeResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/GetRemainingTimeResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "DashAsyncResponse": { + "type": "object", + "properties": { + "Action": { + "type": "string", + "nullable": true + }, + "Executed": { + "type": "boolean" + }, + "BlocksDashed": { + "type": "integer", + "format": "int32" + }, + "DamageTaken": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "ErrorResponse": { + "type": "object", + "properties": { + "Description": { + "type": "string", + "nullable": true + }, + "Error": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "GetRemainingTimeResponse": { + "type": "object", + "properties": { + "RemainingTime": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "GetStatusResponse": { + "type": "object", + "properties": { + "Action": { + "type": "string", + "nullable": true + }, + "Gameid": { + "type": "string", + "nullable": true + }, + "Level": { + "type": "string", + "nullable": true + }, + "Running": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "HitEntityAsyncResponse": { + "type": "object", + "properties": { + "Action": { + "type": "string", + "nullable": true + }, + "Executed": { + "type": "boolean" + }, + "Critical": { + "type": "integer", + "format": "int32" + }, + "Hit": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "MoveEntityAsyncResponse": { + "type": "object", + "properties": { + "Action": { + "type": "string", + "nullable": true + }, + "Executed": { + "type": "boolean" + }, + "Move": { + "type": "boolean", + "nullable": true + } + }, + "additionalProperties": false + }, + "PeekEntitiesAsyncResponse": { + "type": "object", + "properties": { + "Action": { + "type": "string", + "nullable": true + }, + "Executed": { + "type": "boolean" + }, + "PlayersInSight": { + "type": "integer", + "format": "int32" + }, + "SightedPlayerDistance": { + "type": "integer", + "format": "int32", + "nullable": true + } + }, + "additionalProperties": false + }, + "PlayerStatisticsResponse": { + "type": "object", + "properties": { + "Action": { + "type": "string", + "nullable": true + }, + "Executed": { + "type": "boolean" + }, + "Health": { + "$ref": "#/components/schemas/PlayerStatisticsResponseHealth" + }, + "Level": { + "$ref": "#/components/schemas/PlayerStatisticsResponseLevel" + }, + "Stats": { + "$ref": "#/components/schemas/PlayerStatisticsResponseStats" + } + }, + "additionalProperties": false + }, + "PlayerStatisticsResponseHealth": { + "type": "object", + "properties": { + "Currenthealth": { + "type": "number", + "format": "double" + }, + "Maxhealth": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "PlayerStatisticsResponseLevel": { + "type": "object", + "properties": { + "Deathsleft": { + "type": "integer", + "format": "int32" + }, + "Levelid": { + "type": "integer", + "format": "int32" + }, + "Name": { + "type": "string", + "nullable": true + }, + "Progress": { + "type": "number", + "format": "double" + }, + "Remainingtime": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "PlayerStatisticsResponseStats": { + "type": "object", + "properties": { + "Deaths": { + "type": "integer", + "format": "int32" + }, + "Kills": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "RadarAsyncResponse": { + "type": "object", + "properties": { + "Executed": { + "type": "boolean" + }, + "Action": { + "type": "string", + "nullable": true + }, + "RadarResults": { + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int32" + }, + "nullable": true + } + }, + "additionalProperties": false + }, + "ScanAsyncResponse": { + "type": "object", + "properties": { + "Action": { + "type": "string", + "nullable": true + }, + "DifferenceToNearestPlayer": { + "$ref": "#/components/schemas/ScanAsyncResponseDifference" + }, + "Executed": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "ScanAsyncResponseDifference": { + "type": "object", + "properties": { + "X": { + "type": "integer", + "format": "int32", + "nullable": true + }, + "Y": { + "type": "integer", + "format": "int32", + "nullable": true + } + }, + "additionalProperties": false + }, + "ShootAsyncResponse": { + "type": "object", + "properties": { + "Action": { + "type": "string", + "nullable": true + }, + "Executed": { + "type": "boolean" + }, + "HitSomeone": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "SpecialAttackAsyncResult": { + "type": "object", + "properties": { + "Action": { + "type": "string", + "nullable": true + }, + "Executed": { + "type": "boolean" + }, + "Hitcount": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "StartGameAsyncResponse": { + "type": "object", + "properties": { + "Gameid": { + "type": "string", + "nullable": true + }, + "Level": { + "type": "string", + "nullable": true + }, + "Running": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "StopGameResponse": { + "type": "object", + "properties": { + "Gameid": { + "type": "string", + "nullable": true + }, + "Level": { + "type": "string", + "nullable": true + }, + "Running": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "TeleportAsyncResponse": { + "type": "object", + "properties": { + "Action": { + "type": "string", + "nullable": true + }, + "Executed": { + "type": "boolean" + }, + "LandedInWall": { + "type": "boolean" + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/DDApp/DDApplication/MainWindow.axaml.cs b/DDApp/DDApplication/MainWindow.axaml.cs index 1f68232..2907ab2 100644 --- a/DDApp/DDApplication/MainWindow.axaml.cs +++ b/DDApp/DDApplication/MainWindow.axaml.cs @@ -1,9 +1,11 @@ +using System; using Avalonia.Controls; namespace DDApplication; public partial class MainWindow : Window { + private readonly string _apiKey = Program.Configuration["APIKEY"] ?? throw new ArgumentNullException(nameof(_apiKey)); public MainWindow() { InitializeComponent(); diff --git a/DDApp/DDApplication/Program.cs b/DDApp/DDApplication/Program.cs index e087ce1..1dd4d4c 100644 --- a/DDApp/DDApplication/Program.cs +++ b/DDApp/DDApplication/Program.cs @@ -1,16 +1,26 @@ using Avalonia; using System; +using Microsoft.Extensions.Configuration; namespace DDApplication; -internal static class Program +internal class Program { + public static IConfiguration Configuration { get; private set; } = null!; // Initialization code. Don't use any Avalonia, third-party APIs or any // SynchronizationContext-reliant code before AppMain is called: things aren't initialized // yet and stuff might break. [STAThread] - public static void Main(string[] args) => BuildAvaloniaApp() - .StartWithClassicDesktopLifetime(args); + public static int Main(string[] args) + { + Configuration = new ConfigurationBuilder() + .AddJsonFile("appsettings.json", optional: true) + .AddUserSecrets(optional: true) + .AddEnvironmentVariables() + .Build(); + return BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + } // Avalonia configuration, don't remove; also used by visual designer. private static AppBuilder BuildAvaloniaApp()