Difference between revisions of "Board18Market3"

From BOARD18 Project WIKI
Jump to navigation Jump to search
(Initial version of this page)
 
(→‎Function updateDatabase(): But, it first calls the resetCheckForUpdate function.)
Line 59: Line 59:
This function sends the stringified BD18.gm object
This function sends the stringified BD18.gm object
to the updateGame.php function via an AJAX call.
to the updateGame.php function via an AJAX call.
But, it first calls the resetCheckForUpdate function.


==Function acceptMove()==
==Function acceptMove()==

Revision as of 14:11, 27 October 2014

board18Market3.js contains token manipulation functions. These functions manipulate tokens on the stock market chart.

Function logoutOK(resp)

Function logoutOK is the callback function for the ajax lgout call.

Function fromUpdateGm(resp)

The fromUpdateGm function is a callback function for the updateGame.php function. It reports on the status returned by the updateGame.php AJAX call.

Function dropToken(x, y, xI, yI)

The dropToken function places a token at a specified location on the stock market. It calls the MarketToken constructor function and then updates some global variables to keep track of the new token. Note that this new token has not yet been permanently added to the list of placed tokens in BD18.gm.mktTks. It is tracked instead in the BD18.tempToken array.

Function repositionToken(xI, yI)

The repositionToken function moves the current token to a specified new location on the selected price box. It calls the MarketToken constructor function. Note that this new token has not yet been permanently added to the list of placed tokens in BD18.gm.mktTks. It is tracked instead in the BD18.tempToken array.

Function flipToken()

The flipToken function flips the current token. If flip is disallowed, it does nothing and returns. Else it calls the MarketToken constructor function. Note that this flipped token has not yet been permanently added to the list of placed tokens in BD18.gm.mktTks. It is tracked instead in the BD18.tempToken array.

Function deleteToken(ix)

The deleteToken function deletes a market token object from the BD18.marketTokens array. The ix parameter is the index of the tile to be deleted. This function returns false if no token is deleted and true otherwise.

Function tokenSort(tokA, tokB)

The tokenSort function sorts an array of MarketToken objects so that tokens in the same price box are placed in reverse order of their stack values.

Function updateMarketTokens()

This function first sorts the BD18.marketTokens array. It then uses the contents of this array and the MarketToken.togm method to update the BD18.gm.mktTks array.

Function updateDatabase()

This function sends the stringified BD18.gm object to the updateGame.php function via an AJAX call. But, it first calls the resetCheckForUpdate function.

Function acceptMove()

This function calls the addToken function if the market price box is selected and the token is selected. Otherwise it does nothing.

Function addToken()

This function adds the current board token object to the BD18.marketTokens array. It then calls the finishMove function.

Function finishMove()

This function updates the Market Tokens array and the board18 database. It also redisplays the stock market.