The DRAFT1846Start Page

From BOARD18 Project WIKI
Jump to navigation Jump to search
DRAFT1846 Design edit

Control is transferred to the draft1846Start page from the index page. The index page also supplies the number of players the draft1846Start page as a URL parameter.
The draft1846Start page displays a form in to which the names and email addresses of the players should be entered. For less than 5 players, it also displays a selection box which should be used to select the unused privates.

function SetupDraft()

The SetupDraft function uses the functions below to setup a new draft by creating a new row in the draft_table and then sending a confirmation email to each player in the draft.

function makeDeck()

The makeDeck function sets up a D1846.deck array with all private companies present in the array. It then removes the privates that will not be used in the game. Then it adds the required number of blank cards to the array. And finally it shuffles the array.

function shuffle(array)

Function shuffle is used to shuffle a javascript array. I found various forms of this function on many web pages. This particular one is a modified version of the function shown on the page at

The shuffle function accepts an array as input and shuffles the array in place.

function purgeitem(array, item)

Function purgeitem is used to remove an item from a javascript array.

The purgeitem function accepts two parameters:

  1. The first is the array that will be modified.
  2. The second is the item that will be removed.

The function modifies the array in place.

function makePinfo()

The makePinfo function sets up the D1846.nlist array and the D1846.elist array by accessing the player name and email addresse fields from the setup form on the draft1846Start page. It also checks for duplicate names.

function makeDraftRow()

Function makeDraftRow creates "D1846.draft", and then uses JSON.stringify to convert it to the JSON component of the new draft_table row for this usage of DRAFT1846. It then does an ajax call to makeDraft.php.

function newDraftOK(response)

Function newDraftOK is the success callback function for the ajax makeDraft.php call. It checks for a failure and then reports the new draft ID to the start page.
Finally it adds a psudorandom url key to the array for each player and calls the updatedraftNpi.php function.

The php/makeDraft.php call returns the numeric draft_id of the new table row or the intiger 0 if a failure occured.

function updtDraftResult(result)

Function updtDraftResult is the success callback function for the ajax updtDraftNpi.php call made by the newDraftOK() function. It checks for a failure or a collision and then it calls the emailConfirmation.php function.

Output from updateDraft is an echo return status of "success", "collision" or "fail".

function startupEmailsResult(response)

Function startupEmailsResult is the call back function for the ajax calls to emailConfirmation.php. It will have to process returns from multiple emails for the same call. It only needs to check for errors and it only needs to report the first error.

function urlKeyGen(draftID, playerID)

The urlKeyGen() function creates a pseudo random url key for a given draftID and playerID.

Input consists of the draftID and the playerID

Output is the pseudo random url key based on the input.