The DRAFT1846Last Page
|DRAFT1846 Design edit|
The draft1846Last page is called from an email generated by a previous iteration of draft1846Last or by draft1846Next.
This page handles the special case when only one private and no blank cards are left to be chosen.
If the active player takes the private the draft is over.
But if he passes then the draft1846Last page sends an email to the next player for him to take his turn.
The getDraftResult function is the call back function for the ajax call to getDraft.php. It checks that it is the current players turn and sets up the first part of the draft1846Last page.
Output from getDraft.php is a json encoded array. The "return" value will be either "success" or "fail". If it is "fail" then it will be the only item in the array. If the "return" value is "success", then the rest of the array will be the json string from the specified table row.
The processLastSelection function uses the last card to update the current player's hand.It then calls updateDraft.php to update the draft record.
The processPass function saves the updated value of D1846.draft.cpd to the database. It then causes updateDraftResult to send an email to the next player.
The updateDraftResult function is the call back function for the ajax calls to updateDraft.php. It checks for collisions. Then I checks if the draft has completed. If the draft is over then it calls the finishDraft() function.
If the draft is not over then the next player needs to be informed that it is now his turn. To do this the updateDraftResult function will send an email directing the next player to the draft1846Last page.
Function nextEmailsResult is the call back function for the ajax call to emailNext.php. It only needs to check for errors.
The finishDraft function updates the draft status to "Done". It then calls updtDraft.php to do the final update to the draft.
The finishDraftResult function is the call back function for the ajax call by the finishDraft function to updtDraft.php. It checks for collisions. Then it uses emailDone.php to send a completed email to each player and finally it calls the draftDone() function.
The doneEmailResult function is the call back function for the ajax call to emailDone.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.