Design Document Server Side Overview

From BOARD18 Project WIKI
Revision as of 08:22, 26 June 2015 by Rich (talk | contribs) (→‎The Game Check Point Table: replace with The Game Snapshot Table)
Jump to navigation Jump to search
This page has been updated to comply with Release 1.0.x of BOARD18.

The server side of the BOARD18 application will use a minimalist approach. In other words, anything that can be done on the client side, will be done on the client side. This philosophy limits the server mostly to data base access and game logging tasks. The server side of the BOARD18 application will also provide conflict resolution for multi thread database accesses.

Design Document edit


Data Base

BOARD 18 uses MySQL for its data management. A single database, with a data base name of BOARD18, is used. The database consists of six tables:

  1. The Box Table
  2. The Game Table
  3. The Game Check Point Table
  4. The Game Link Table
  5. The Game Player Table
  6. The Players Table

The Box Table

Each row in the table named “box” contains a game box. The table layout is shown below. The json_text field contains a stringified JSON game box object as described in section 5.2.1.

Column Type Null Default
box_id Int (11) No
bname Varchar (25) No
version Varchar (25) Yes NULL
create_date Timestamp Yes NULL
activity_date Timestamp No CURRENT_TIMESTAMP
author Varchar (25) No
status Varchar (10) No 'Active'
json_text MediumText Yes NULL

The Game Table

The “game” table contains a row for each game that is being tracked by BOARD18. The table layout is shown below. The json_text field contains a stringified JSON game session object as described in section 5.2.2.

Column Type Null Default
game_id Int (11) No
gname Varchar (25) No
start_date Timestamp Yes NULL
activity_date Timestamp No CURRENT_TIMESTAMP
update_counter Int (11) No 0
last_updater Varchar (16) No
box_id Int (11) No
cp_count Int (11) No 0
status Varchar (10) No 'Active'
json_text MediumText Yes NULL

The Game Snapshot Table

The “game_snap” table contains a row for each snapshot taken for each game that is being tracked by BOARD18. The table layout is shown below. The json_text field contains a stringified JSON game session object as described in section 5.2.2.

Column Type Null Default
game_id Int (11) No
cp_id Int (11) No
cp_date Timestamp No CURRENT_TIMESTAMP
update_counter Int (11) No 0
player Varchar (16) No
last_updater Varchar (16) No
game_round Varchar (16) No
json_text MediumText Yes NULL

The Game Link Table

The “game_link” table contains a row for each link that will be available to each game that is being tracked by BOARD18. The table layout is shown below.

Column Type Null Default
game_id Int (11) No
link_type Varchar (15) No
link_url Varchar (100) Yes NULL
activity_date Timestamp No CURRENT_TIMESTAMP

The Game Player Table

The “game_player” table contains a row for each player of each active game that is being tracked by BOARD18. The table layout is shown below. This table is the link between players and the game sessions that they are playing.

Column Type Null Default
game_id Int (11) No
player_id Int (11) No
status Varchar (10) No 'P'

The Players Table

The “players” table contains a row for each player that has a login ID in BOARD18. The table layout is shown below. This table is used to control player access to the application.

Column Type Null Default
player_id Int (11) No
firstname Varchar (25) No
lastname Varchar (25) Yes NULL
email Varchar (25) No
login Varchar (16) No
passwd Varchar (64) No
create_date Timestamp No CURRENT_TIMESTAMP
level Varchar (10) No player
changeit Tinyint (1) No 0

Logic

AJAX Called Programs

PHP files that are called by Javascript files
File Name Called Via Called By[1] Return Type[2] MySQL?
allGameList.php post board18View.php JSON file Yes
changePlayers.php post board18Misc.js echo status Yes
checkForUpdate.php post board18Map3.js echo status Yes
createGame.php post board18New.js echo status Yes
emailPlayerAdd.php post board18New.js echo status Yes
emailPlayerRem.php post board18Misc.js echo status Yes
emailPlayerID.php post board18index.js echo status Yes
emailPassword.php post board18index.js echo status Yes
forcePasswd.php post board18Admin.js echo status Yes
gameBox.php getJSON board18Map2.js JSON file Yes
gameSession.php getJSON board18Map.php JSON file Yes
logout.php post board18Main.php echo status No
myGameList.php post board18Main.php JSON file Yes
newUser.php post board18index.js echo status Yes
statSwap.php post board18Map6.js echo status Yes
updateGame.php post board18Map3.js echo status Yes
updateUser.php post board18Admin.js echo status Yes
validateUser.php post board18index.js JSON file Yes

Most of the server side processing for BOARD18 is done in stand alone PHP programs that are executed from the web pages via AJAX calls. These programs are listed here with brief descriptions. They are also listed in the table to the right.

  • allGameList.php Returns a list of all the games that are in the database.
  • changePlayers.php Adds and/or removes players from existing game sessions.
  • checkForUpdate.php Checks the database to see if another player has made an update.
  • createGame.php Creates a new row in the game table and adds a row in the game_player table for each player in the game.
  • emailPlayerAdd.php Sends an Email a player who has been added to a game.
  • emailPlayerRem.php Sends an Email a player who has been removed from a game.
  • emailPlayerID.php Sends an Email containing the player ID to the player's Email address.
  • emailPassword.php Sends an Email containing a temporary password to the player's Email address.
  • forcePasswd.php Processes a forced password change.
  • gameBox.php Returns a game box in JSON format.
  • gameSession.php Returns game activity information in JSON format.
  • logout.php Logs the current user out of BOARD18.
  • myGameList.php Returns a list of the games that a player is playing.
  • newUser.php Creates a new row in the players table.
  • statSwap.php Toggles game status in the database.
  • updateGame.php Loads game updates into the database.
  • updateUser.php Updates a row in the players table.
  • validateUser.php Logs the current user in to BOARD18.

Notes for Table to Right

  1. Lists only first calling program.
  2. This standards document describes return types.

Include Modules

There are also a number of php modules that are included (using require once) by some of the above programs to reduce redundant code.

  • auth.php is included at the front of every php program that is listed above [except logout.php, emailPlayerID.php and emailPassword.php] and of every php enabled page. This module checks that the session is signed on and redirects control to access-denied.html if it is not.
  • configMail.php is included at the front of the sendEmail.php module. It contains information used to locate and access a SMTP server.
  • config.php is included at the front of every php program and php enabled page that accesses the board18 database. It contains information used to locate and access the BOARD18 database.
  • sendEmail.php is included at the front of every php program or module that sends Email. It accesses a SMTP server to actually send the email. This module includes some modules obtained from the PHPMailer application.
  • makeTables.php is included into various board18 PHP pages. It supplies a number of functions for creating the HTML to display various tables on those pages.