Create game API: Difference between revisions

From Warzone Wiki
Jump to navigation Jump to search
Matma Rex (talk | contribs)
→‎Usage: I'm pretty sure that XML was malformed
No edit summary
Line 1: Line 1:
The CreateGame API will create a single WarLight game.  You can specify the game settings, game name, boot times, and what players are invited to the game.
The CreateGame API will create multi-player WarLight games programmatically.  You can specify the game settings, game name, and what players are invited to the game.


==Usage==
==Usage==
Line 5: Line 5:
Using this can allow you to create a program that hosts your own tournaments or ladder-type systems.
Using this can allow you to create a program that hosts your own tournaments or ladder-type systems.


To create games via the API, you must POST some xml to http://warlight.net/API/CreateGame.aspx that contains the details about the game you're creating.  Here's an example:
To create games via the API, you must POST some JSON to http://warlight.net/API/CreateGame.aspx that contains the details about the game you're creating.  Here's an example:




   <createGame>
   {
     <hostEmail>your@email.com</hostEmail>
     hostEmail: your@email.com,
     <hostPassword>yourPassword</hostPassword>
     hostAPIToken: yourApiToken,
     <templateID>1234</templateID>
     templateID: 1234,
     <gameName>Game name here (max 50 chars)</gameName>
     gameName: 'Game name here (max 50 chars)',
     <personalMessage>Include a description to include with the game. (Max 1024 characters)</personalMessage>
     personalMessage: 'Include a description to include with the game. (Max 1024 characters)',
    <realTime>false</realTime>
     players:  [
    <voteBootTimeInMinutes>Never</voteBootTimeInMinutes>
       { token="player1@email.com" team="None" },
    <directBootTimeInMinutes>2880</directBootTimeInMinutes>
       { token="player2@email.com" team="None" },
    <autoBootTimeInMinutes>4320</autoBootTimeInMinutes>
       { token="123456789" team="None" },
    <practiceGame>false</practiceGame>
       { token="player4@email.com" team="None" }
     ]
     <invite>
   }
       <player token="player1@email.com" team="None" />
       <player token="player2@email.com" team="None" />
       <player token="123456789" team="None" />
       <player token="player4@email.com" team="None" />
     </invite>
   </createGame>




   
   
* hostEmail / hostPassword: These elements identify you.  The game will be recorded as created by you.
* hostEmail / hostAPIToken: These elements identify you.  You can get your APIToken from the [[Get API Token API]].  The game will be recorded as created by you.
* templateID:  This specifies the ID of a template that you create through the normal game GUI.  You can either use a built-in template or you can create your own.  It does not matter if you create a single-player or multi-player template.
* templateID:  This specifies the ID of a template that you create through the normal game GUI.  You can either use a built-in template or you can create your own.  It does not matter if you create a single-player or multi-player template.
* gameName:  This will show up as the name of the game.  Maximum 50 characters.
* gameName:  This will show up as the name of the game.  Maximum 50 characters.
* personalMessage: This will show up in the Lobby as well as the Settings.  Maximum 1024 characters.
* personalMessage: This will show up in the Lobby as well as the Settings.  Maximum 1024 characters.
* realTime:  True for real-time game, false for a multi-day game.  This is typically false.
* players:  This node defines the players that will be invited.  It consists of 'player' elements, each of which contains a 'token' attribute and a 'team' attribute:
* voteBootTimeInMinutes / directBootTimeInMinutes / autoBootTimeInMinutes:  These define the boot times for the game.  2880 is 2 days, 4320 is 3 days.
* practiceGame: True for a practice game, false for a ranked game.
* invite:  This node defines the players that will be invited.  It consists of 'player' elements, each of which contains a 'token' attribute and a 'team' attribute:
** player team:  This can be the string 'None' if you're not creating a team game.  If you are creating a team game, then supply a number for each player identifying the team that they're on.  0 is team A, 1 is team B, 2 is team C, etc.
** player team:  This can be the string 'None' if you're not creating a team game.  If you are creating a team game, then supply a number for each player identifying the team that they're on.  0 is team A, 1 is team B, 2 is team C, etc.
** player token:  The token identifies the player you're inviting.  You can either pass an e-mail address or a player token.  Using tokens is an option provided only because some players may not want to dilvulge their e-mail address to you.  These players can instead give you their invite token.  To find a player's invite token, they can visit http://warlight.net/InviteToken.aspx.  The invite token is the same as the number displayed in the address bar when you view a player's profile page.
** player token:  The token identifies the player you're inviting.  You can either pass an e-mail address or a player token.  Using tokens is an option provided only because some players may not want to dilvulge their e-mail address to you.  These players can instead give you their invite token.  To find a player's invite token, they can visit http://warlight.net/InviteToken.aspx.  The invite token is the same as the number displayed in the address bar when you view a player's profile page.
** slot:  If you're making a game that uses a custom scenario, you must provide a "slot" attribute on each player that let's WarLight know what scenario to give this player.  This should be an integer, where 0 is slot A, 1 is slot B, 2 is slot C, etc.
** slot:  If you're making a game that uses a custom scenario, you must also provide a "slot" attribute on each player that let's WarLight know what scenario to give this player.  This should be an integer, where 0 is slot A, 1 is slot B, 2 is slot C, etc.


==Output==
==Output==
Line 48: Line 39:
Success:
Success:


   <root>
   {
       <gameID>1234567</gameID>
       gameID: 1234567
   </root>
   }


Failure:
Failure:




   <root>
   {
       <error>Description of the error</error>
       error: 'Description of the error'
   </root>
   }


==See Also==
==See Also==

Revision as of 14:09, 17 September 2012

The CreateGame API will create multi-player WarLight games programmatically. You can specify the game settings, game name, and what players are invited to the game.

Usage

Using this can allow you to create a program that hosts your own tournaments or ladder-type systems.

To create games via the API, you must POST some JSON to http://warlight.net/API/CreateGame.aspx that contains the details about the game you're creating. Here's an example:


 {
   hostEmail: your@email.com,
   hostAPIToken: yourApiToken,
   templateID: 1234,
   gameName: 'Game name here (max 50 chars)',
   personalMessage: 'Include a description to include with the game. (Max 1024 characters)',
   players:  [
     { token="player1@email.com" team="None" },
     { token="player2@email.com" team="None" },
     { token="123456789" team="None" },
     { token="player4@email.com" team="None" }
   ]
 }


  • hostEmail / hostAPIToken: These elements identify you. You can get your APIToken from the Get API Token API. The game will be recorded as created by you.
  • templateID: This specifies the ID of a template that you create through the normal game GUI. You can either use a built-in template or you can create your own. It does not matter if you create a single-player or multi-player template.
  • gameName: This will show up as the name of the game. Maximum 50 characters.
  • personalMessage: This will show up in the Lobby as well as the Settings. Maximum 1024 characters.
  • players: This node defines the players that will be invited. It consists of 'player' elements, each of which contains a 'token' attribute and a 'team' attribute:
    • player team: This can be the string 'None' if you're not creating a team game. If you are creating a team game, then supply a number for each player identifying the team that they're on. 0 is team A, 1 is team B, 2 is team C, etc.
    • player token: The token identifies the player you're inviting. You can either pass an e-mail address or a player token. Using tokens is an option provided only because some players may not want to dilvulge their e-mail address to you. These players can instead give you their invite token. To find a player's invite token, they can visit http://warlight.net/InviteToken.aspx. The invite token is the same as the number displayed in the address bar when you view a player's profile page.
    • slot: If you're making a game that uses a custom scenario, you must also provide a "slot" attribute on each player that let's WarLight know what scenario to give this player. This should be an integer, where 0 is slot A, 1 is slot B, 2 is slot C, etc.

Output

The CreateGame API will output the ID of the newly created game if it is successful. If it is unsuccessful, it will output an 'error' node. Here are some examples:

Success:

 {
     gameID: 1234567
 }

Failure:


 {
     error: 'Description of the error'
 }

See Also