File: Games\ChineseCheckers\Game.js

GamesByEmail
Class ChineseCheckersGame

Object
  
 
 
GamesByEmail.Game
 
 
GamesByEmail.ChineseCheckersGame

All Implemented Interfaces:

Hex, Class, Elemental, Resourceful, Server


GamesByEmail.ChineseCheckersGame

extends Game
implements GamesByEmail.Hex

Nested Class Summary
static ClassChineseCheckersGame.MoveData

Constructor Summary
GamesByEmail.ChineseCheckersGame()

Field Summary
static ObjectresourcePack
Resources for most of the game. Override to add resources specific to game.
 teamColorArrays

Fields inherited from GamesByEmail.Game
board, canPie, constrainer, font, id, info, isLog, lastMove, logSettings, maxMoveNumber, message, move, notify, onLeftMouseDown, onLeftMouseUp, onMiddleMouseDown, onMiddleMouseUp, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp, onRightMouseDown, onRightMouseUp, pieces, previewing, rotation, status, teams, territories, testing, title, type, verbose

Fields inherited from Foundation.Elemental
$Foundation_$registry_index

Method Summary
PointboardPointFromValueIndex(/*Number*/ index)
Gets the board point from the board value index.
StringboardValueFromValueColor(/*String*/ value, /*Number*/ color)
Gets the board value from a value and color. By default, the value is returned if color is zero, else the upper case of the value is returned.
 canMove(moveData, color)
 canMoveFrom(fromPoint, moveData, color)
 checkForWin(board, color)
BooleancheckMove(/*Point*/ toPoint, /*Point*/ fromPoint)
Checks to see if a move is legal. By default calls isMoveLegal.
NumbercolorFromBoardValue(/*String*/ boardValue)
Gets the color from a board value. By default, lower case characters return 0, uppercase 1, and everything else -1.
StringcompleteYourTurnHtml(/*String*/ resourceName)
Called when needing the complete-your-turn game prompt HTML (typically a short sentence about the move and a Send This Move button). Override and set mouse events here. Internally uses the "completeYourTurn" resource.
StringcontinueYourTurnHtml(/*String*/ resourceName)
Called when needing the continue-your-turn game prompt HTML (typically a short sentence about the move, no send move button yet). Override and set mouse events here. Internally uses the "continueYourTurn" resource.
 dispose()
 dragByClicks(up, origPoint, screenPoint)
 getLegalJumpInDirection(fromPoint, dx, dy, board, jerrysJumpMultiplier)
 getMoveData(board)
ArraygetTeamsForTitles(/*Boolean*/ top)
Gets an array of teams to display either across the top or bottom of the board. Override to alter default behavior.
voidinitialize(/*Number*/ numPlayers, /*Number*/ turnTeamIndex)
The first method to be called when a game is created, override to set up teams, players and the game state.
voidinitializeNewGameForm(/*GameForm*/ gameForm, /*Array*/ userInfo)
Seeds the game form options with values from the current game.
 isJumpLegal(toPoint, fromPoint, board, jerrysJumpMultiplier)
 isMoveLegal(toPoint, fromPoint, moveData, jerrysJumpMultiplier)
 isPointBoardJumpablyEmpty(point, board)
 isPointBoardUnoccupiedSpace(point, board)
StringitsYourTurnHtml(/*String*/ resourceName)
Called when needing the it-is-your-turn game prompt HTML (typically a short sentence about the move). Override and set mouse events here. Internally uses the "itIsYourTurnToMove" resource.
 jerrysJumpNotice()
 mouseDown(screenPoint)
 mouseMove(screenPoint)
 mouseUp(screenPoint)
StringnotYourTurnHtml(/*String*/ resourceName)
Called when needing the it-is-not-your-turn game prompt HTML (typically a short sentence with Send Reminder, Refresh Game and Close Window buttons Start Another Game button). Override to set. Internally uses the "notYourTurn" resource.
 removeMarbles(point, moveData, color)
voidresign()
Resignes the current player. Clears mouse events, sets the player as resigned, and sends the move.
StringresignHtml(/*String*/ resourceName)
Called when needing the you-may-resign prompt HTML (typically a short sentence about resiging and a Resign button). Override to set. Internally uses the "youMayResign" resource.
BooleansendMove(/*Boolean*/ sendNow, /*Player*/ player)
Gets called when the Send Move button is pushed. Override and set the game state, then call Super.sendMove.
 setEndStatus(team, teamScore, otherScore1, otherScore2)
 setMoveData(moveData)
voidsetPerspective(/*Team*/ team)
Called when synchronizing, sets the perspective of the board based on the player. By default sets the rotation property to 0.
 showHilites(moveData, hilites)
 spaceNotation(x, y)
voidsynch()
Called when the game should synchronize with info properties from the server.
NumberteamColorFromTeam(/*Team*/ team)
Gets the team color.
StringvalueFromBoardValue(/*String*/ boardValue)
Gets the value from a board value. By default, the lower case of the board value is returned.

Methods inherited from GamesByEmail.Game
aboveTeamTitleRowHtml, acceptDeclineDrawHtml, acceptDraw, acceptDrawButtonHtml, addNote, addToPage, appendAdditionalPreferencesHtml, appendBoardHtml, beginTurnHtml, belowTeamTitleRowHtml, boardPointFromScreenPoint, cancelGameButtonHtml, cancelGameHtml, clearHilites, clearMouseEvents, closeWindowButtonHtml, closeWindowHtml, colorFromPointBoard, colorFromXYBoard, completeTurnHtml, constrainPoint, constrainRectangle, continueTurnHtml, debug, diceRolls, dieRoll, drawAcceptedHeaderHtml, drawAcceptedHtml, drawDeclinedHeaderHtml, drawDeclinedHtml, drawOfferedHeaderHtml, elementTitleAttributes, findNextPlayer, findPlayer, findWinningTeam, forEachTeam, gameInProgressHeaderHtml, gameOverHeaderHtml, gameOverHtml, getActionLinksHtml, getAnchorHtml, getButtonHtml, getCheckboxHtml, getGamePromptsHtml, getHeaderHtml, getHtml, getHtmlButtonHtml, getImageSrc, getNewGamePlayerOrder, getNextGamesTitle, getOptionHtml, getPieType, getPieceRect, getPieceSrc, getRadioHtml, getSelectHtml, getSpectatorAnchorHtml, getSpectatorUrl, getTeamAtDistance, getTeamFontColor, getTeamLogFontBgColor, getTeamLogFontColor, getTeamTitleAlignment, getTeamTitleHtml, getTeamTitlesHtml, getTextHtml, getTextareaHtml, getTurnHtml, getTurnTeam, getVButtonHtml, handleMoveCollision, hiliteImageHtml, isBoardPointHidden, isColorAtPoint, isColorAtXY, isMyTurn, isPathClear, isPointBoardClear, isPointOnBoard, isValueColorAtPoint, isValueColorAtXY, isXYBoardClear, isXYOnBoard, maybePie, maybeResign, movePiece, nextTeam, numTeamsPlaying, offerDrawCheckBoxHtml, offerDrawHtml, openLogAnchorHtml, openPlayerChatAnchorHtml, openPreferencesAnchorHtml, openRulesAnchorHtml, pie, pieButtonHtml, pieHtml, processSecureMove, refreshGame, refreshGameButtonHtml, reportProblemAnchorHtml, resignButtonHtml, resignedHeaderHtml, screenRectFromBoardPoint, sendMoveButtonHtml, sendMoveHtml, sendReminderButtonHtml, setConstrainer, setEnded, setFloatHtml, setInnerHtml, setMouseHtml, setPlayerPrefs, setValueAtPoint, setValueAtXY, showTransactionPrompt, spectatingHtml, startAnotherGameButtonHtml, startAnotherGameHtml, synchTeam, theyResignedHtml, tieGameHeaderHtml, titleFromTeamColor, transformHashLinksToOnClicks, turnHeaderHtml, undo, undoButtonHtml, undoMoveHtml, update, updateTeamTitles, valueFromPointBoard, valueFromXYBoard, valueIndexFromBoardPoint, wonHeaderHtml, youLoseHtml, youResignedHtml, youTiedHtml, youWinHtml

Methods inherited from GamesByEmail.Hex
boardPointFromScreenXY, forEachBoardPoint, numInPath, screenRectFromBoardXY, valueIndexFromBoardXY

Methods inherited from Foundation.Class
getTypePath, isInstanceOf

Methods inherited from Foundation.Elemental
attachEvent, detachEvent, elementId, event, getById, getElement, getElementValue, getElements, getFirst, getNext, parseElementId, processHtml, processHtml

Methods inherited from Foundation.Resourceful
resource, resource, resourceUrl, resourceUrl

Methods inherited from Foundation.Server
server, serverSerialized, serverSynchronous

Constructor Detail

ChineseCheckersGame

GamesByEmail.ChineseCheckersGame()

Field Detail

resourcePack

static Object resourcePack

Resources for most of the game. Override to add resources specific to game.

Overrides:
resourcePack in class Game
See Also:
Foundation.Resourceful.resource

teamColorArrays

teamColorArrays

Method Detail

boardPointFromValueIndex

Point boardPointFromValueIndex(/*Number*/ index)

Gets the board point from the board value index.

Overrides:
boardPointFromValueIndex in class Hex
Parameters:
index - 
The board value index.
Returns:
The board point.

boardValueFromValueColor

String boardValueFromValueColor(/*String*/ value,
                                /*Number*/ color)

Gets the board value from a value and color. By default, the value is returned if color is zero, else the upper case of the value is returned.

Overrides:
boardValueFromValueColor in class Game
Parameters:
value - 
The value.
color - 
The color.
Returns:
The board value.

canMove

canMove(moveData,
        color)
Parameters:
moveData - 

color - 


canMoveFrom

canMoveFrom(fromPoint,
            moveData,
            color)
Parameters:
fromPoint - 

moveData - 

color - 


checkForWin

checkForWin(board,
            color)
Parameters:
board - 

color - 


checkMove

Boolean checkMove(/*Point*/ toPoint,
                  /*Point*/ fromPoint)

Checks to see if a move is legal. By default calls isMoveLegal.

Overrides:
checkMove in class Game
Parameters:
toPoint - 
The board point moving to.
fromPoint - 
The board point moving from.
Returns:
true if the move is legal.
See Also:
isMoveLegal

colorFromBoardValue

Number colorFromBoardValue(/*String*/ boardValue)

Gets the color from a board value. By default, lower case characters return 0, uppercase 1, and everything else -1.

Overrides:
colorFromBoardValue in class Game
Parameters:
boardValue - 
The value to check, by default a single character.
Returns:
The color number.

completeYourTurnHtml

String completeYourTurnHtml(/*String*/ resourceName)

Called when needing the complete-your-turn game prompt HTML (typically a short sentence about the move and a Send This Move button). Override and set mouse events here. Internally uses the "completeYourTurn" resource.

Overrides:
completeYourTurnHtml in class Game
Parameters:
resourceName - 
(Optional) A resource name to override the default resource to use.
Returns:
HTML for the game prompts.

continueYourTurnHtml

String continueYourTurnHtml(/*String*/ resourceName)

Called when needing the continue-your-turn game prompt HTML (typically a short sentence about the move, no send move button yet). Override and set mouse events here. Internally uses the "continueYourTurn" resource.

Overrides:
continueYourTurnHtml in class Game
Parameters:
resourceName - 
(Optional) A resource name to override the default resource to use.
Returns:
HTML for the game prompts.

dispose

dispose()
Overrides:
dispose in class Game

dragByClicks

dragByClicks(up,
             origPoint,
             screenPoint)
Parameters:
up - 

origPoint - 

screenPoint - 


getLegalJumpInDirection

getLegalJumpInDirection(fromPoint,
                        dx,
                        dy,
                        board,
                        jerrysJumpMultiplier)
Parameters:
fromPoint - 

dx - 

dy - 

board - 

jerrysJumpMultiplier - 


getMoveData

getMoveData(board)
Parameters:
board - 


getTeamsForTitles

Array getTeamsForTitles(/*Boolean*/ top)

Gets an array of teams to display either across the top or bottom of the board. Override to alter default behavior.

Overrides:
getTeamsForTitles in class Game
Parameters:
top - 
Will be true if getting teams for the top, else false for the bottom.
Returns:
The array of teams.

initialize

void initialize(/*Number*/ numPlayers,
                /*Number*/ turnTeamIndex)

The first method to be called when a game is created, override to set up teams, players and the game state.

Overrides:
initialize in class Game
Parameters:
numPlayers - 
The number of players from the game form.
turnTeamIndex - 
The index of the team to set the initial turn. Call the Super with -1 to set all teams turn.

Example:

// Override initialize
   initialize:function(numPlayers,turnTeamIndex)
   {
      // Call the Super.initialize to add default teams.
      Super.initialize(numPlayers,turnTeamIndex);
 
      // Initialize the board state.
      this.info["board"]="rnbqkbnrpppppppp                                PPPPPPPPRNBQKBNR";
      var team=this.teams[0];
      team.info["i_ep"]=-1;
      team.info["b_cs"]=true;
      team.info["b_cl"]=true;
      team=this.teams[1];
      team.info["i_ep"]=-1;
      team.info["b_cs"]=true;
      team.info["b_cl"]=true;
      
      // Log the start of game.
      this.move.log=this.logEntry(44);
   }

initializeNewGameForm

void initializeNewGameForm(/*GameForm*/ gameForm,
                           /*Array*/ userInfo)

Seeds the game form options with values from the current game.

Overrides:
initializeNewGameForm in class Game
Parameters:
gameForm - 
The game form to seed.
userInfo - 
An array of user information.

isJumpLegal

isJumpLegal(toPoint,
            fromPoint,
            board,
            jerrysJumpMultiplier)
Parameters:
toPoint - 

fromPoint - 

board - 

jerrysJumpMultiplier - 


isMoveLegal

isMoveLegal(toPoint,
            fromPoint,
            moveData,
            jerrysJumpMultiplier)
Parameters:
toPoint - 

fromPoint - 

moveData - 

jerrysJumpMultiplier - 


isPointBoardJumpablyEmpty

isPointBoardJumpablyEmpty(point,
                          board)
Parameters:
point - 

board - 


isPointBoardUnoccupiedSpace

isPointBoardUnoccupiedSpace(point,
                            board)
Parameters:
point - 

board - 


itsYourTurnHtml

String itsYourTurnHtml(/*String*/ resourceName)

Called when needing the it-is-your-turn game prompt HTML (typically a short sentence about the move). Override and set mouse events here. Internally uses the "itIsYourTurnToMove" resource.

Overrides:
itsYourTurnHtml in class Game
Parameters:
resourceName - 
(Optional) A resource name to override the default resource to use.
Returns:
HTML for the game prompts.

jerrysJumpNotice

jerrysJumpNotice()

mouseDown

mouseDown(screenPoint)
Parameters:
screenPoint - 


mouseMove

mouseMove(screenPoint)
Parameters:
screenPoint - 


mouseUp

mouseUp(screenPoint)
Parameters:
screenPoint - 


notYourTurnHtml

String notYourTurnHtml(/*String*/ resourceName)

Called when needing the it-is-not-your-turn game prompt HTML (typically a short sentence with Send Reminder, Refresh Game and Close Window buttons Start Another Game button). Override to set. Internally uses the "notYourTurn" resource.

Overrides:
notYourTurnHtml in class Game
Parameters:
resourceName - 
(Optional) A resource name to override the default resource to use.
Returns:
HTML for the game prompts.

removeMarbles

removeMarbles(point,
              moveData,
              color)
Parameters:
point - 

moveData - 

color - 


resign

void resign()

Resignes the current player. Clears mouse events, sets the player as resigned, and sends the move.

Overrides:
resign in class Game

resignHtml

String resignHtml(/*String*/ resourceName)

Called when needing the you-may-resign prompt HTML (typically a short sentence about resiging and a Resign button). Override to set. Internally uses the "youMayResign" resource.

Overrides:
resignHtml in class Game
Parameters:
resourceName - 
(Optional) A resource name to override the default resource to use.
Returns:
HTML for the game prompts.

sendMove

Boolean sendMove(/*Boolean*/ sendNow,
                 /*Player*/ player)

Gets called when the Send Move button is pushed. Override and set the game state, then call Super.sendMove.

Overrides:
sendMove in class Game
Parameters:
sendNow - 
(Optional) Send the moves to the server now. Else, save the move for sending later. Defaults to true.
player - 
(Optional) The player responsible for the move. Defaults to the current player (game.player).
Returns:
true.

setEndStatus

setEndStatus(team,
             teamScore,
             otherScore1,
             otherScore2)
Parameters:
team - 

teamScore - 

otherScore1 - 

otherScore2 - 


setMoveData

setMoveData(moveData)
Parameters:
moveData - 


setPerspective

void setPerspective(/*Team*/ team)

Called when synchronizing, sets the perspective of the board based on the player. By default sets the rotation property to 0.

Overrides:
setPerspective in class Game
Parameters:
team - 
The team to synchronize.

showHilites

showHilites(moveData,
            hilites)
Parameters:
moveData - 

hilites - 


spaceNotation

spaceNotation(x,
              y)
Parameters:
x - 

y - 


synch

void synch()

Called when the game should synchronize with info properties from the server.

Overrides:
synch in class Game
Notes:
The game should set tangible properties or states for each custom property set in the info collection. The info collection should not be referenced outside the scope of the synch or sendMove methods.

teamColorFromTeam

Number teamColorFromTeam(/*Team*/ team)

Gets the team color.

Overrides:
teamColorFromTeam in class Game
Parameters:
team - 
The team to get the color of.
Returns:
The team color.

valueFromBoardValue

String valueFromBoardValue(/*String*/ boardValue)

Gets the value from a board value. By default, the lower case of the board value is returned.

Overrides:
valueFromBoardValue in class Game
Parameters:
boardValue - 
The value to check, by default a single character.
Returns:
The value.