The DRAFT1846Next Page

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


The draft1846Next page is called from an email generated by a previous iteration of draft1846Next or by draft1846Cfrm. It first accesses the table record from the database. It then deals a new hand and displays it to the player. When the player makes a choice it updates the database. And then it sends an email to the next player for him to take his turn.

If there is only one private left it passes control to the draft1846Last page. If the current player takes the last private (leaving one or more blank cards behind) then the draft is over and the draft1846Last page is not needed.

function getDraftResult(result)

The getDraftResult function is the call back function for the ajax calls to getDraft.php. It checks that it is the current players turn and sets up the first part of the draft1846Next 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.

function processSelection()

The processSelection function uses the entered card select value to update the current player's holding. And also to remove the card from the delt hand. It then calls updateDraft.php to update the table row.

function updateDraftResult(result)

The updateDraftResult function is the call back function for the ajax calls to updateDraft.php. It checks for collisions. Then it 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 properly the updateDraftResult(result) function must first check if only one private and no blank cards are left. If this is true, it will send an email directing the next player to the draft1846Last page. If it is not true, it will send an email directing the next player to the draft1846Next page.

function nextEmailResult(response)

Function nextEmailsResult is the call back function for both the ajax call to emailNext.php and the ajax call to emailLast.php. It only needs to check for errors.

function finishDraft()

The finishDraft function updates the draft status to "Done". It uses updtDraft.php to do this.

function finishDraftResult(result)

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.

function doneEmailResult(response)

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.