Board18Map3

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

board18Map3.js contains tile and token manipulation functions. These functions manipulate obects on the map board.

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 dropTile(xI,yI)

The dropTile function places a tile at a specified location on the map board. It calls the BoardTile constructor function and then updates some global variables to keep tract of the new tile. Note that this new tile has not yet been permanently added to the list of placed tiles in BD18.gm.brdTls. It is tracked instead in the BD18.tempTile array.

Function rotateTile(dir)

The rotateTile function replaces the tile at a specified location on the map board with a rotated version of that tile. The tile it modifies is the one pointed to by BD18.tempTile.

This function calls the BoardTile constructor function after modifying the rotation counter in BD18.curRot.

Function getToken(index)

The getToken function selects a token at a specified location on the map board. It sets the selected token and hex fields in BD18.

Function dropToken(x,y,xI,yI)

The dropToken function places a token at a specified location on the map board. It calls the BoardToken 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.brdTks. 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 tile. It calls the BoardToken constructor function. Note that this new token has not yet been permanently added to the list of placed tokens in BD18.gm.brdTks. It is tracked instead in the BD18.tempToken array.

Function flipToken()

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

Function reduceCount(sheet,ind)

This function reduces the available count for a specific tile or token [item]. These counts are stored in the BD18.gm.trayCounts array which is indexed by the sheet number and the item index. This function returns false if no item is available and true otherwise.

Function increaseCount(sheet,ind)

This function increases the available count for a specific tile or token [item]. These counts are stored in the BD18.gm.trayCounts array which is indexed by the sheet number and the item index.

Function deleteTile(ix)

The deleteTile function deletes a board tile object from the BD18.boardTiles array. The ix parameter is the index of the tile to be deleted. This function also increases the count of available tiles for the tile that is being deleted. This function returns false if no tile is deleted and true otherwise.

Function deleteToken(ix)

The deleteToken function deletes a board token object from the BD18.boardTokens array. The ix parameter is the index of the tile to be deleted. This function also increases the count of available tokens for the token that is being deleted. This function returns false if no token is deleted and true otherwise.

Function updateGmBrdTiles()

This function uses the contents of the the BD18.boardTiles array and the BoardTile.togm method to update the BD18.gm.brdTls array.

Function updateGmBrdTokens()

This function uses the contents of the the BD18.boardTokens array and the BoardToken.togm method to update the BD18.gm.brdTks 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 addTile function if the hex is selected and the tile is selected. It calls the addToken function if the hex is selected and the token is selected. Otherwise it does nothing.

Function cancelMove()

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

Function historyMove()

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

Function addTile()

This function adds the current board tile object to the BD18.boardTiles array. If a tile is already in the hex in question then that existing tile is deleted via the deleteTile function. If the tile count for the tile is already 0 then an error has occured. This should never happen.

Function addToken()

This function adds the current board token object to the BD18.boardTokens array. If the token count for the token is already 0 then an error has occured. This should never happen.