Editing Create game API
Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | The CreateGame API will create multi-player | + | 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 JSON to | + | To create games via the API, you must POST some JSON to http://warlight.net/API/CreateGame that contains the details about the game you're creating. Here's an example: |
Line 19: | Line 19: | ||
{ token: "123456789" team: "None" }, | { token: "123456789" team: "None" }, | ||
{ token: "13453531543" team: "None" } | { token: "13453531543" team: "None" } | ||
− | ] | + | ] |
− | + | ||
} | } | ||
Line 26: | Line 25: | ||
* 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. | * 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 | + | * 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. | ||
* 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: | * 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 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 | + | ** player token: The token identifies the player you're inviting. Players can find their token by visiting http://warlight.net/InviteToken. 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 | + | ** 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 60: | Line 58: | ||
{ | { | ||
− | hostEmail: | + | hostEmail: your@email.com, |
... | ... | ||
players: [ | players: [ | ||
Line 73: | Line 71: | ||
Values specified here will replace any values specified by the template in use. | Values specified here will replace any values specified by the template in use. | ||
− | Typically you will specify bonuses by name as shown above. However, if a map has multiple bonuses with the same name, you can specify a "bonusID" attribute instead of the "bonusName" attribute shown above. To find the ID of a bonus, use the [[ | + | Typically you will specify bonuses by name as shown above. However, if a map has multiple bonuses with the same name, you can specify a "bonusID" attribute instead of the "bonusName" attribute shown above. To find the ID of a bonus, use the [[Game Feed API]] on a game using the same map. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | == Member Restriction == | |
− | + | Member-only features (such as custom scenarios, luck levels below 75%, etc.) can only be used in games created by the Create Game API if all players being invited to the game are members (or otherwise have access to the feature, such as if they made the map that's in use.) | |
− | + | This restriction exists to prevent players from bypassing WarLight's member restrictions completely. For example, if this restriction did not exist, someone could make a website that allowed any non-member to create a game for themselves using all of the member-only features. | |
− | + | If you create a game that uses a member-only feature, such as a low luck level, and invite non-members, the game will simply revert to using 75% luck. This allows you to freely create games without having to worry about this restriction -- the created games will use low luck when the can, and 75% luck when they can't. | |
− | + | If you want to ensure that everyone you're inviting is a member, call the [[Validate invite token API]] and check the isMember flag. | |
==See Also== | ==See Also== |