Design Document JSON Data Structures

From BOARD18 Project WIKI
Revision as of 15:08, 20 February 2018 by Rich (talk | contribs) (initial contents)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
This page has been updated to comply with Release 2.5.x of BOARD18.
Design Document edit


The JSON Game Session Data Structure

Each BOARD18 game session has its own JSON data structure. This data structure is stored in the “json_text” field of the game table. The gname, and boxID keys are used to identify the JSON Game Session and specify the game box that the game session uses. These are followed by four array structures.

The following is a depiction of the top levels of this data structure:

{
  "gname":"The Name of the Game", 
  "boxID":"The numeric ID of the Game Box", 
  "brdTls": {
    
  },
  "brdTks": {

  },
  "mktTks": [
  
  ],
  "trayCounts": [
 
  ]
}

The array with the key of brdTls tracks the tiles that have been placed on the board. The array with the key of brdTks tracks the tokens that have been placed on the board. The array with the key of mktTks tracks the tokens that have been placed on the stock market. And the array with the key of trayCounts tracks the number of remaining tiles and tokens available to be played on the game board.

These arrays are stored in the global variable BD18.gm. This global variable is loaded by the gameBox.php server function and the loadSession() javascript function which is in both the board18Map2.js file and the board18Market2.js file.

The brdTls array

This array is built and modified dynamically. This is a part of such an array which is currently tracking 63 tiles on the game board.

brdTls:Array(63)
  0:
    rotate:2
    sheetNumber:0
    tileNumber:10
    xCoord:5
    yCoord:15

  1:
    rotate:2
    sheetNumber:0
    tileNumber:15
    xCoord:3
    yCoord:13

 . . . .

  62:
   rotate:0
   sheetNumber:0
   tileNumber:9
   xCoord:4
   yCoord:10

The brdTks array

This array is built and modified dynamically. This is a part of such an array which is currently tracking 29 tokens on the game board.

brdTks:Array(29)
  0:
    flip:false
    sheetNumber:5
    tokenNumber:5
    xCoord:447
    yCoord:466

  1:
    flip:false
    sheetNumber:5
    tokenNumber:6
    xCoord:467
    yCoord:497

 . . . .

  28:
    flip:false
    sheetNumber:5
    tokenNumber:10
    xCoord:301
    yCoord:855.4444580078125

The mktTks array

This array is built and modified dynamically. This is a part of such an array which is currently tracking 29 tokens on the stock market.

mktTks:Array(29)
  0:
    flip:false
    sheetNumber:0
    stack:0
    tokenNumber:0
    xCoord:216
    yCoord:113

  1:
    flip:false
    sheetNumber:0
    stack:0
    tokenNumber:16
    xCoord:214
    yCoord:272

 . . . .

  28:
    flip:false
    sheetNumber:0
    stack:0
    tokenNumber:2
    xCoord:1339
    yCoord:198

The trayCounts array

This array is initialized by the javascript loadBox() function if it is found to be uninitialized. The loadBox() function is in the board18Map2.js file. This is such an array which is currently tracking the remaining counts of 75 token/tile items in 6 different tile sheets..

trayCounts:Array(6)
  0:(16) [2, 8, 10, 6, 4, 6, 1, 5, 4, 3, 0, 1, 1, 2, 0, 1]
  1:(14) [2, 1, 1, 2, 2, 3, 1, 3, 2, 2, 2, 1, 1, 1]
  2:(14) [2, 4, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 4, 3]
  3:(8) [0, 0, 0, 0, 2, 1, 1, 3]
  4:(5) [3, 3, 1, 1, 1]
  5:(18) [0, 1, 2, 0, 1, 0, 0, 2, 2, 0, 2, 2, 1, 0, 1, 1, 1, 1]