The DRAFT1846Start Page
|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.
- 1 function SetupDraft()
- 2 function makeDeck()
- 3 function shuffle(array)
- 4 function purgeitem(array, item)
- 5 function makePinfo()
- 6 function makeDraftRow()
- 7 function newDraftOK(response)
- 8 function updtDraftResult(result)
- 9 function startupEmailsResult(response)
- 10 function urlKeyGen(draftID, playerID)
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.
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.
The shuffle function accepts an array as input and shuffles the array in place.
function purgeitem(array, item)
The purgeitem function accepts two parameters:
- The first is the array that will be modified.
- The second is the item that will be removed.
The function modifies the array in place.
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 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 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 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 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.