Game Box Creation - Control File Syntax

From BOARD18 Project WIKI
Jump to navigation Jump to search
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": [
  
  ],
  "links": [
 
  ]
}

I would like to point out a number of things about the example above:

  1. Each blank line marks a point where details have been omitted.
  2. Items within a object consist of two fields (name and value) separated by a colon
  3. The name field is always a string.
  4. The value field can be an array, another object, an integer, a boolean value or a string.
  5. All strings (both name and value) MUST be within double quotes.
  6. All boolean values must be either true or false. Do not put boolean values in quotes.
  7. If an object or array contains more than one item, the items must be separated by commas.
  8. 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 6 simple items as shown in the example below:

  "board": {
    "imgLoc":"images/1826-REP01/Map.png", 
    "orientation":"P",
    "xStart":0, 
    "xStep":50, 
    "yStart":0, 
    "yStep":87
  },

Market

The "market" item in the Game Box JSON file is an object which contains 5 simple items as shown in the example below:

  "market": {
    "imgLoc":"images/1826-REP01/Stock.png", 
    "xStart":80, 
    "xStep":60, 
    "yStart":80, 
    "yStep":50
  },

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":20, 
    "xSize":100, 
    "xStep":120, 
    "yStart":20, 
    "ySize":116, 
    "yStep":130, 
    "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":10, 
    "xSize":30, 
    "xStep":40, 
    "yStart":10, 
    "ySize":30, 
    "yStep":40, 
    "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":10, 
    "xSize":30, 
    "xStep":40, 
    "yStart":10, 
    "ySize":30, 
    "yStep":40, 
    "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 Trays object!

Links

The "links" item in the Game Box JSON file is an array each element of which contains 2 simple items as shown in the example below:

  "links": [
    {
      "link_name":"Rules",
      "link_url":"https://drive.google.com/file/d/0B-wwptMMyHTAZHRRejFkYzd5OTQ"
    },
    {
      "link_name":"Rules Summary",
      "link_url":"https://docs.google.com/document/d/1yyvSMACgakSY0G4vW8vHf-kgMYIQ2miCwpNNoQr_ZFM"
    }
  ]