Game Box Creation - Control File Syntax
Game Box Creation edit | |
Control Tables
The control tables for a game box are implemented as one large JSON data structure. More information on JSON can be found here.
"Syntax – the form – is contrasted with semantics – the meaning." This is a quote from the WIKIPEDIA article on syntax.
This page discusses the syntax of a JSON control structure.
In other words it discusses how to properly form the structure.
The Control Semantics page discusses the semantics of the game box.
In other words it discusses what the fields mean.
JSON Game Box Control File Syntax
The JSON control file must be formatted exactly as described below. A JSON file resembles a Javascript object but has a far more restrictive format than Javascript.
It will be very helpfull to pass the finished JSON file through a JSON validator like JSON lint.
Overall Structure
The Game Box JSON file is a nested series of JSON objects and JSON arrays.
A JSON object is always contained in a pair of curly brackets { }
A JSON array is always contained in a pair of square brackets [ ]
An example of the overall structure of a Game Box JSON file is shown here:
{ "bname":"1826", "version":"REP01", "author":"Rich Price", "board": { }, "market": { }, "tray": [ ] }
I would like to point out a number of things about the example above:
- Each blank line marks a point where details have been omitted.
- Items within a object consist of two fields (name and value) separated by a colon
- The name field is always a string.
- The value field can be an array, another object, an integer, a boolean value or a string.
- All strings (both name and value) MUST be within double quotes.
- All boolean values must be either true or false. Do not put boolean values in quotes.
- If an object or array contains more than one item, the items must be separated by commas.
- There must not be a comma after the last item in an object or array.
Board
The "board" item in the Game Box JSON file is an object which contains 7 simple items as shown in the example below:
"board": { "imgLoc":"images/1826-REP01/Map.png", "xStart":0, "xStep":50, "yStart":0, "yStep":87 },
Note: The imgHght and imgWdth fields are deprecated and should no longer be used as of BOARD18 version 0.3.0
Market
The "market" item in the Game Box JSON file is an object which contains 7 simple items as shown in the example below:
"market": { "imgLoc":"images/1826-REP01/Stock.png", "imgHght":527, "imgWdth":1174, "xStart":80, "xStep":60, "yStart":80, "yStep":50 },
Note: The imgHght and imgWdth fields are deprecated and should no longer be used as of BOARD18 version 0.3.0
Trays
The "tray" item in the Game Box JSON file is an array with a very complex structure. The "tray" array is an array that contains a variable number of objects:
"tray": [ { }, { }, { }, { }, { }]
Each of these objects will be one of three possible types with each type having a different structure. The first item in each of these objects has a name of "type" and can be used to determine the structure of the object. The sections below will discuss the syntax of each of these object types.
Tile Tray
Tile tray objects have a "type" of "tile". These objects contain 9 simple items and one complex item named "tile". This structure is shown in the example below:
{ "type":"tile", "tName":"Yellow Tiles", "imgLoc":"images/1826-REP01/Yellow1.png", "xStart":89, "xSize":70, "xStep":89, "yStart":79, "ySize":71, "yStep":79, "tile":[ { }, { }, { }, { }, { }] }
The "tile" item is an array that contains one element for each tile type [ie: column in the tile sheet]. Each such array element is an object with 2 simple items. These objects have the following format:
{ "dups":6, "rots":6 }
Board Token Tray
Board token trays have a "type" of "btok". There should be a "btok" object for every token sheet that will be available on the game board. These objects contain 9 simple items and one complex item named "token". This structure is shown in the example below:
{ "type":"btok", "tName":"Tokens", "imgLoc":"images/1826-REP01/Tokens.png", "xStart":5, "xSize":50, "xStep":60, "yStart":5, "ySize":50, "yStep":56, "token":[{ }, { }, { }, { }, { }] }
The "token" item is an array that contains one element for each token type [ie: row in the token sheet]. Each such array element is an object with 2 simple items. These objects have the following format:
{ "dups":5, "flip":false }
Market Token Tray
Market token trays have a "type" of "mtok".
There should be a "mtok" object for every token sheet that will be available for the stock market.
It is quite possible that the same tile sheet image could be referenced by both a "btok" and a "mtok" object.
"mtok" objects
contain 9 simple items and one complex item named "token".
This structure is shown in the example below:
{ "type":"mtok", "tName":"Tokens", "imgLoc":"images/1826-REP01/Tokens.png", "xStart":5, "xSize":50, "xStep":60, "yStart":5, "ySize":50, "yStep":56, "token":[{ }, { }, { }, { }, { }] }
The "token" item is an array that contains one element for each token type [ie: row in the token sheet]. Each such array element is an object with 1 simple item. These objects have the following format:
{ "flip":false }
ALL market token trays must be at the end of the control file!