File: Games\Scribe\Game.js

GamesByEmail
Class ScribeGame

Object
  
 
 
GamesByEmail.Game
 
 
GamesByEmail.ScribeGame

All Implemented Interfaces:

Class, Elemental, Resourceful, Server


GamesByEmail.ScribeGame

extends Game

Nested Class Summary
static ClassScribeGame.MoveData

Constructor Summary
GamesByEmail.ScribeGame()

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

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
 arePointsAdjacent(p1, p2)
PointboardPointFromScreenXY(/*Number*/ screenX, /*Number*/ screenY)
Gets the board point from a screen coordinates.
BooleancheckMove(/*Point*/ toPoint, /*Point*/ fromPoint)
Checks to see if a move is legal. By default calls isMoveLegal.
 closeGridScore()
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.
 countWonGrid(value)
 dispose()
 extractGlyph(miniBoard)
 findGlyphTitle(glyph)
 findPreviousMovePoint(point, board, color)
 getAdjacentPiece(point, x, y)
 getCompulsaryGridIndex(board, color)
 getGlyph(glyphInfo, x, y, color)
 getGlyphExplinationHtml(miniBoard, closeButton, gridLabel)
 getGlyphList(miniBoard, color)
 getGlyphShapeHtml(glyph, color)
 getGlyphTitle(glyph)
 getGlyphValue(glyph)
 getMiniBoardShapeHtml(miniBoard, color)
 getMiniGridBoard(board, point)
 getMoveData()
 getTeamScore(team)
 glyphMouseDown(screenPoint)
 gridCenterFromIndex(index)
 gridIndexFromPoint(point)
 gridOriginFromIndex(index)
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.
 isGridAvailable(board, index)
 isMoveLegal(point, moveData, color, quick)
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.
 markGlyph(glyphInfo, x, y, color)
 markWonGrids(board, color)
 mirrorGlyph(glyph)
 mouseDown(screenPoint)
 mouseMove(screenPoint)
 mouseOut(screenPoint)
 mouseOver(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.
 rotateGlyph(glyph)
 scoreGlyph(glyph)
 scoreGlyphs(glyphs)
RectanglescreenRectFromBoardXY(/*Number*/ boardX, /*Number*/ boardY)
Gets the screen rectangle from board coordinates.
BooleansendMove(/*Boolean*/ sendNow, /*Player*/ player)
Gets called when the Send Move button is pushed. Override and set the game state, then call Super.sendMove.
 setMoveData(moveData)
 showCompulsaryAndWonGrids(board, team)
 squareIndexFromPoint(point)
voidsynch()
Called when the game should synchronize with info properties from the server.
StringyouLoseHtml(/*String*/ resourceName)
Called when needing the you-lose game prompts HTML. Override to set. Internally uses the "youLose" resource.
StringyouWinHtml(/*String*/ resourceName)
Called when needing the you-win game prompts HTML. Override to set. Internally uses the "youWin" resource.

Methods inherited from GamesByEmail.Game
aboveTeamTitleRowHtml, acceptDeclineDrawHtml, acceptDraw, acceptDrawButtonHtml, addNote, addToPage, appendAdditionalPreferencesHtml, appendBoardHtml, beginTurnHtml, belowTeamTitleRowHtml, boardPointFromScreenPoint, boardPointFromValueIndex, boardValueFromValueColor, cancelGameButtonHtml, cancelGameHtml, clearHilites, clearMouseEvents, closeWindowButtonHtml, closeWindowHtml, colorFromBoardValue, colorFromPointBoard, colorFromXYBoard, completeTurnHtml, constrainPoint, constrainRectangle, continueTurnHtml, continueYourTurnHtml, debug, diceRolls, dieRoll, drawAcceptedHeaderHtml, drawAcceptedHtml, drawDeclinedHeaderHtml, drawDeclinedHtml, drawOfferedHeaderHtml, elementTitleAttributes, findNextPlayer, findPlayer, findWinningTeam, forEachBoardPoint, 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, getTeamsForTitles, getTextHtml, getTextareaHtml, getTurnHtml, getTurnTeam, getVButtonHtml, handleMoveCollision, hiliteImageHtml, initializeNewGameForm, isBoardPointHidden, isColorAtPoint, isColorAtXY, isMyTurn, isPathClear, isPointBoardClear, isPointOnBoard, isValueColorAtPoint, isValueColorAtXY, isXYBoardClear, isXYOnBoard, maybePie, maybeResign, movePiece, nextTeam, numInPath, numTeamsPlaying, offerDrawCheckBoxHtml, offerDrawHtml, openLogAnchorHtml, openPlayerChatAnchorHtml, openPreferencesAnchorHtml, openRulesAnchorHtml, pie, pieButtonHtml, pieHtml, processSecureMove, refreshGame, refreshGameButtonHtml, reportProblemAnchorHtml, resign, resignButtonHtml, resignHtml, resignedHeaderHtml, screenRectFromBoardPoint, sendMoveButtonHtml, sendMoveHtml, sendReminderButtonHtml, setConstrainer, setEnded, setFloatHtml, setInnerHtml, setMouseHtml, setPerspective, setPlayerPrefs, setValueAtPoint, setValueAtXY, showTransactionPrompt, spectatingHtml, startAnotherGameButtonHtml, startAnotherGameHtml, synchTeam, teamColorFromTeam, theyResignedHtml, tieGameHeaderHtml, titleFromTeamColor, transformHashLinksToOnClicks, turnHeaderHtml, undo, undoButtonHtml, undoMoveHtml, update, updateTeamTitles, valueFromBoardValue, valueFromPointBoard, valueFromXYBoard, valueIndexFromBoardPoint, valueIndexFromBoardXY, wonHeaderHtml, youResignedHtml, youTiedHtml

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

ScribeGame

GamesByEmail.ScribeGame()

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

Method Detail

arePointsAdjacent

arePointsAdjacent(p1,
                  p2)
Parameters:
p1 - 

p2 - 


boardPointFromScreenXY

Point boardPointFromScreenXY(/*Number*/ screenX,
                             /*Number*/ screenY)

Gets the board point from a screen coordinates.

Overrides:
boardPointFromScreenXY in class Game
Parameters:
screenX - 
The x coordinate, in screen space.
screenY - 
The y coordinate, in screen space.
Returns:
The board point.

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

closeGridScore

closeGridScore()

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.

countWonGrid

countWonGrid(value)
Parameters:
value - 


dispose

dispose()
Overrides:
dispose in class Game

extractGlyph

extractGlyph(miniBoard)
Parameters:
miniBoard - 


findGlyphTitle

findGlyphTitle(glyph)
Parameters:
glyph - 


findPreviousMovePoint

findPreviousMovePoint(point,
                      board,
                      color)
Parameters:
point - 

board - 

color - 


getAdjacentPiece

getAdjacentPiece(point,
                 x,
                 y)
Parameters:
point - 

x - 

y - 


getCompulsaryGridIndex

getCompulsaryGridIndex(board,
                       color)
Parameters:
board - 

color - 


getGlyph

getGlyph(glyphInfo,
         x,
         y,
         color)
Parameters:
glyphInfo - 

x - 

y - 

color - 


getGlyphExplinationHtml

getGlyphExplinationHtml(miniBoard,
                        closeButton,
                        gridLabel)
Parameters:
miniBoard - 

closeButton - 

gridLabel - 


getGlyphList

getGlyphList(miniBoard,
             color)
Parameters:
miniBoard - 

color - 


getGlyphShapeHtml

getGlyphShapeHtml(glyph,
                  color)
Parameters:
glyph - 

color - 


getGlyphTitle

getGlyphTitle(glyph)
Parameters:
glyph - 


getGlyphValue

getGlyphValue(glyph)
Parameters:
glyph - 


getMiniBoardShapeHtml

getMiniBoardShapeHtml(miniBoard,
                      color)
Parameters:
miniBoard - 

color - 


getMiniGridBoard

getMiniGridBoard(board,
                 point)
Parameters:
board - 

point - 


getMoveData

getMoveData()

getTeamScore

getTeamScore(team)
Parameters:
team - 


glyphMouseDown

glyphMouseDown(screenPoint)
Parameters:
screenPoint - 


gridCenterFromIndex

gridCenterFromIndex(index)
Parameters:
index - 


gridIndexFromPoint

gridIndexFromPoint(point)
Parameters:
point - 


gridOriginFromIndex

gridOriginFromIndex(index)
Parameters:
index - 


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);
   }

isGridAvailable

isGridAvailable(board,
                index)
Parameters:
board - 

index - 


isMoveLegal

isMoveLegal(point,
            moveData,
            color,
            quick)
Parameters:
point - 

moveData - 

color - 

quick - 


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.

markGlyph

markGlyph(glyphInfo,
          x,
          y,
          color)
Parameters:
glyphInfo - 

x - 

y - 

color - 


markWonGrids

markWonGrids(board,
             color)
Parameters:
board - 

color - 


mirrorGlyph

mirrorGlyph(glyph)
Parameters:
glyph - 


mouseDown

mouseDown(screenPoint)
Parameters:
screenPoint - 


mouseMove

mouseMove(screenPoint)
Parameters:
screenPoint - 


mouseOut

mouseOut(screenPoint)
Parameters:
screenPoint - 


mouseOver

mouseOver(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.

rotateGlyph

rotateGlyph(glyph)
Parameters:
glyph - 


scoreGlyph

scoreGlyph(glyph)
Parameters:
glyph - 


scoreGlyphs

scoreGlyphs(glyphs)
Parameters:
glyphs - 


screenRectFromBoardXY

Rectangle screenRectFromBoardXY(/*Number*/ boardX,
                                /*Number*/ boardY)

Gets the screen rectangle from board coordinates.

Overrides:
screenRectFromBoardXY in class Game
Parameters:
boardX - 
The x coordinate, in board point space.
boardY - 
The y coordinate, in board point space.
Returns:
The screen rectangle.

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.

setMoveData

setMoveData(moveData)
Parameters:
moveData - 


showCompulsaryAndWonGrids

showCompulsaryAndWonGrids(board,
                          team)
Parameters:
board - 

team - 


squareIndexFromPoint

squareIndexFromPoint(point)
Parameters:
point - 


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.

youLoseHtml

String youLoseHtml(/*String*/ resourceName)

Called when needing the you-lose game prompts HTML. Override to set. Internally uses the "youLose" resource.

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

youWinHtml

String youWinHtml(/*String*/ resourceName)

Called when needing the you-win game prompts HTML. Override to set. Internally uses the "youWin" resource.

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