Board18Market3

From BOARD18 Project WIKI
Jump to navigation Jump to search
This page has been updated to comply with Release 2.5.x of BOARD18. Go Back

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

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 cancelMove()

This function calls the CanvasApp() functions to reset trays and market when canceling a move

Function historyMove(move)

This function puts moves in the BD18.history to provide undo/redo functionality

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.