Difference between revisions of "The DRAFT1846Start Page"
(initial contents of this page)
Revision as of 14:59, 19 May 2020
Control is transfered 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.
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 php/makeDraft.php call. The php/makeDraft.php call returns the numeric draft_id of the new table row or the integer 0 if a failure occurred. The newDraftOK function checks for a failure (0) and then reports the new draft ID to the start page. Finally it calls the emailConfirmation.php function.
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.