File: Games\Reflektit\Game.js

GamesByEmail
Class ReflektitGame

Object
  
 
 
GamesByEmail.Game
 
 
GamesByEmail.ReflektitGame

All Implemented Interfaces:

Class, Elemental, Resourceful, Server


GamesByEmail.ReflektitGame

extends Game

Constructor Summary
GamesByEmail.ReflektitGame()
// This is the base class that we are extending.

Field Summary
static  resourcePack
// This will hold our static methods and properties. // the resourcePack is a collection of information // used throughout the class.

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
 canMoveTo(color, toPoint)
 canRotate(value)
BooleancheckMove(/*Point*/ toPoint, /*Point*/ fromPoint)
Checks to see if a move is legal. By default calls isMoveLegal.
 dispose()
 dragByClicks(up, origPoint, screenPoint)
RectanglegetPieceRect(/*String*/ value, /*Number*/ color, /*Point*/ boardPoint)
Gets the clipping rectangle for a piece.
 getPieceRotation(value, angle)
StringgetTeamTitleHtml(/*Team*/ team, /*Boolean*/ top)
Gets the HTML for the team title on the board. By default uses resources 'turnTeamTitle' or 'teamTitle'.
 hitPiece()
// Processes a mirror hit on a laser. Returns the new direction, or -1 if something was hit.
 hoverPiece(screenPoint)
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.
 isInRange(toPoint, fromPoint)
 isMoveLegal(toPoint, piece)
 isSwappable(value)
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.
 mouseDown(screenPoint, ev)
 moveLaser()
// Laser directions: 0 is north, 1 is west, 2 is south, 3 is east.
 pieceNotation(pieceChar, color)
 placePiece(screenPoint)
 processLaser()
 removeLaser()
 rotatePiece(screenPoint)
 rotatedPiece()
BooleansendMove(/*Boolean*/ sendNow, /*Player*/ player)
Gets called when the Send Move button is pushed. Override and set the game state, then call Super.sendMove.
 setHilites()
voidsetPerspective(/*Team*/ team)
Called when synchronizing, sets the perspective of the board based on the player. By default sets the rotation property to 0.
 spaceNotation(x, y)
voidsynch()
Called when the game should synchronize with info properties from the server.
 synchTeam()
// This will hold our methods and properties.

Methods inherited from GamesByEmail.Game
aboveTeamTitleRowHtml, acceptDeclineDrawHtml, acceptDraw, acceptDrawButtonHtml, addNote, addToPage, appendAdditionalPreferencesHtml, appendBoardHtml, beginTurnHtml, belowTeamTitleRowHtml, boardPointFromScreenPoint, boardPointFromScreenXY, boardPointFromValueIndex, boardValueFromValueColor, cancelGameButtonHtml, cancelGameHtml, clearHilites, clearMouseEvents, closeWindowButtonHtml, closeWindowHtml, colorFromBoardValue, colorFromPointBoard, colorFromXYBoard, completeTurnHtml, completeYourTurnHtml, 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, getPieceSrc, getRadioHtml, getSelectHtml, getSpectatorAnchorHtml, getSpectatorUrl, getTeamAtDistance, getTeamFontColor, getTeamLogFontBgColor, getTeamLogFontColor, getTeamTitleAlignment, 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, notYourTurnHtml, numInPath, numTeamsPlaying, offerDrawCheckBoxHtml, offerDrawHtml, openLogAnchorHtml, openPlayerChatAnchorHtml, openPreferencesAnchorHtml, openRulesAnchorHtml, pie, pieButtonHtml, pieHtml, processSecureMove, refreshGame, refreshGameButtonHtml, reportProblemAnchorHtml, resign, resignButtonHtml, resignHtml, resignedHeaderHtml, screenRectFromBoardPoint, screenRectFromBoardXY, sendMoveButtonHtml, sendMoveHtml, sendReminderButtonHtml, setConstrainer, setEnded, setFloatHtml, setInnerHtml, setMouseHtml, setPlayerPrefs, setValueAtPoint, setValueAtXY, showTransactionPrompt, spectatingHtml, startAnotherGameButtonHtml, startAnotherGameHtml, teamColorFromTeam, theyResignedHtml, tieGameHeaderHtml, titleFromTeamColor, transformHashLinksToOnClicks, turnHeaderHtml, undo, undoButtonHtml, undoMoveHtml, update, updateTeamTitles, valueFromBoardValue, valueFromPointBoard, valueFromXYBoard, valueIndexFromBoardPoint, valueIndexFromBoardXY, wonHeaderHtml, youLoseHtml, youResignedHtml, youTiedHtml, youWinHtml

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

ReflektitGame

GamesByEmail.ReflektitGame()

// This is the base class that we are extending.

Field Detail

resourcePack

static resourcePack

// This will hold our static methods and properties. // the resourcePack is a collection of information // used throughout the class.

Overrides:
resourcePack in class Game

Method Detail

canMoveTo

canMoveTo(color,
          toPoint)
Parameters:
color - 

toPoint - 


canRotate

canRotate(value)
Parameters:
value - 


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

dispose

dispose()
Overrides:
dispose in class Game

dragByClicks

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

origPoint - 

screenPoint - 


getPieceRect

Rectangle getPieceRect(/*String*/ value,
                       /*Number*/ color,
                       /*Point*/ boardPoint)

Gets the clipping rectangle for a piece.

Overrides:
getPieceRect in class Game
Parameters:
value - 
The value of the piece.
color - 
(Optional) The color of the piece. Not used by default.
boardPoint - 
(Optional) The board point of the piece. Not used by default.
Returns:
The clipping rectangle.

getPieceRotation

getPieceRotation(value,
                 angle)
Parameters:
value - 

angle - 


getTeamTitleHtml

String getTeamTitleHtml(/*Team*/ team,
                        /*Boolean*/ top)

Gets the HTML for the team title on the board. By default uses resources 'turnTeamTitle' or 'teamTitle'.

Overrides:
getTeamTitleHtml in class Game
Parameters:
team - 
The team to get the color for.
top - 
Whether this team's title will be displayed above the board or below.
Returns:
The log background color.

hitPiece

hitPiece()

// Processes a mirror hit on a laser. Returns the new direction, or -1 if something was hit.


hoverPiece

hoverPiece(screenPoint)
Parameters:
screenPoint - 


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

isInRange

isInRange(toPoint,
          fromPoint)
Parameters:
toPoint - 

fromPoint - 


isMoveLegal

isMoveLegal(toPoint,
            piece)
Parameters:
toPoint - 

piece - 


isSwappable

isSwappable(value)
Parameters:
value - 


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.

mouseDown

mouseDown(screenPoint,
          ev)
Parameters:
screenPoint - 

ev - 


moveLaser

moveLaser()

// Laser directions: 0 is north, 1 is west, 2 is south, 3 is east.


pieceNotation

pieceNotation(pieceChar,
              color)
Parameters:
pieceChar - 

color - 


placePiece

placePiece(screenPoint)
Parameters:
screenPoint - 


processLaser

processLaser()

removeLaser

removeLaser()

rotatePiece

rotatePiece(screenPoint)
Parameters:
screenPoint - 


rotatedPiece

rotatedPiece()

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.

setHilites

setHilites()

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.

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.

synchTeam

synchTeam()

// This will hold our methods and properties.

Overrides:
synchTeam in class Game