Skip to content

Latest commit

 

History

History
404 lines (316 loc) · 12.4 KB

PlayersApi.md

File metadata and controls

404 lines (316 loc) · 12.4 KB

Tgm.Roborally.Api.Api.PlayersApi

All URIs are relative to http://game.host/v1

Method HTTP request Description
ChooseRobot PATCH /games/{game_id}/players/{player_id} Set Robots
GetAllPlayers GET /games/{game_id}/players/ Get all players
GetPlayer GET /games/{game_id}/players/{player_id} Get player
Join POST /games/{game_id}/players/ Join game
KickPlayer DELETE /games/{game_id}/players/{player_id} Remove Player

ChooseRobot

void ChooseRobot (int gameId, int playerId, List robots = null)

Set Robots

DEPRECATET > This feature is useless in this version. It will be usefull in newer versions Sets the type of robot(s) the player is controlling

Example

using System.Collections.Generic;
using System.Diagnostics;
using Tgm.Roborally.Api.Api;
using Tgm.Roborally.Api.Client;
using Tgm.Roborally.Api.Model;

namespace Example
{
    public class ChooseRobotExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "http://game.host/v1";
            // Configure API key authorization: player-auth
            config.AddApiKey("pat", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.AddApiKeyPrefix("pat", "Bearer");

            var apiInstance = new PlayersApi(config);
            var gameId = 56;  // int | The id of the game to interact with
            var playerId = 56;  // int | the id of the player to interact with
            var robots = new List<Robots>(); // List<Robots> | The robots assigned to the player (optional) 

            try
            {
                // Set Robots
                apiInstance.ChooseRobot(gameId, playerId, robots);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling PlayersApi.ChooseRobot: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Parameters

Name Type Description Notes
gameId int The id of the game to interact with
playerId int the id of the player to interact with
robots List<Robots> The robots assigned to the player [optional]

Return type

void (empty response body)

Authorization

player-auth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
404 Not Found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetAllPlayers

List<int> GetAllPlayers (int gameId)

Get all players

Returns the index of all players

Example

using System.Collections.Generic;
using System.Diagnostics;
using Tgm.Roborally.Api.Api;
using Tgm.Roborally.Api.Client;
using Tgm.Roborally.Api.Model;

namespace Example
{
    public class GetAllPlayersExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "http://game.host/v1";
            // Configure API key authorization: player-auth
            config.AddApiKey("pat", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.AddApiKeyPrefix("pat", "Bearer");

            var apiInstance = new PlayersApi(config);
            var gameId = 56;  // int | The id of the game to interact with

            try
            {
                // Get all players
                List<int> result = apiInstance.GetAllPlayers(gameId);
                Debug.WriteLine(result);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling PlayersApi.GetAllPlayers: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Parameters

Name Type Description Notes
gameId int The id of the game to interact with

Return type

List

Authorization

player-auth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
404 Not Found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetPlayer

Player GetPlayer (int gameId, int playerId)

Get player

Get closer information about the player

Example

using System.Collections.Generic;
using System.Diagnostics;
using Tgm.Roborally.Api.Api;
using Tgm.Roborally.Api.Client;
using Tgm.Roborally.Api.Model;

namespace Example
{
    public class GetPlayerExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "http://game.host/v1";
            // Configure API key authorization: player-auth
            config.AddApiKey("pat", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.AddApiKeyPrefix("pat", "Bearer");

            var apiInstance = new PlayersApi(config);
            var gameId = 56;  // int | The id of the game to interact with
            var playerId = 56;  // int | the id of the player to interact with

            try
            {
                // Get player
                Player result = apiInstance.GetPlayer(gameId, playerId);
                Debug.WriteLine(result);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling PlayersApi.GetPlayer: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Parameters

Name Type Description Notes
gameId int The id of the game to interact with
playerId int the id of the player to interact with

Return type

Player

Authorization

player-auth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
404 Not Found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

Join

JoinResponse Join (int gameId, string password = null, string name = null)

Join game

Join the given game. You will get your ID by doing this, if you already in the game you can get your ID again if you lost it.
The id is neccessary for any further API calls

Example

using System.Collections.Generic;
using System.Diagnostics;
using Tgm.Roborally.Api.Api;
using Tgm.Roborally.Api.Client;
using Tgm.Roborally.Api.Model;

namespace Example
{
    public class JoinExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "http://game.host/v1";
            var apiInstance = new PlayersApi(config);
            var gameId = 56;  // int | The id of the game to interact with
            var password = password_example;  // string | The password of the game if the lobby is password protected (optional) 
            var name = name_example;  // string | The name to be displayed as username (optional) 

            try
            {
                // Join game
                JoinResponse result = apiInstance.Join(gameId, password, name);
                Debug.WriteLine(result);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling PlayersApi.Join: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Parameters

Name Type Description Notes
gameId int The id of the game to interact with
password string The password of the game if the lobby is password protected [optional]
name string The name to be displayed as username [optional]

Return type

JoinResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Joined -
401 Wrong/No password -
404 Not Found -
409 Not Joinable -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

KickPlayer

void KickPlayer (int gameId, int playerId)

Remove Player

Removes a player from the game. This can be done by the player itsself or by the host.

Example

using System.Collections.Generic;
using System.Diagnostics;
using Tgm.Roborally.Api.Api;
using Tgm.Roborally.Api.Client;
using Tgm.Roborally.Api.Model;

namespace Example
{
    public class KickPlayerExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "http://game.host/v1";
            // Configure API key authorization: admin-access
            config.AddApiKey("skey", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.AddApiKeyPrefix("skey", "Bearer");
            // Configure API key authorization: player-auth
            config.AddApiKey("pat", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.AddApiKeyPrefix("pat", "Bearer");

            var apiInstance = new PlayersApi(config);
            var gameId = 56;  // int | The id of the game to interact with
            var playerId = 56;  // int | the id of the player to interact with

            try
            {
                // Remove Player
                apiInstance.KickPlayer(gameId, playerId);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling PlayersApi.KickPlayer: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Parameters

Name Type Description Notes
gameId int The id of the game to interact with
playerId int the id of the player to interact with

Return type

void (empty response body)

Authorization

admin-access, player-auth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK -
404 Not Found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]