File: Games\GamesByEmail.js

GamesByEmail
Interface Hex

Object
  
 
 
GamesByEmail.Hex

All Implemented Interfaces:

Interface


GamesByEmail.Hex

implements Foundation.Interface

An interface for games with a hexagonal board. Has precedent methods to for converting to and from screen points, and board point to value indices, path and looping. A class should also implement either GamesByEmail.HexH or GamesByEmail.HexV.

Note: This interface should be implemented, not extended.
Do not pass as first argument to Foundation.createClass function.

See Also:

GamesByEmail.HexH, GamesByEmail.HexV

Method Summary
precedence PointboardPointFromScreenXY(/*Number*/ screenX, /*Number*/ screenY)
Gets the board point from a screen coordinates.
precedence PointboardPointFromValueIndex(/*Number*/ index)
Gets the board point from the board value index.
 dispose()
precedence VariantforEachBoardPoint(/*String*/ methodName, /*Variant*/ parameters, ...)
Calls a method of the game for each point on the board, with the board point as the first parameter. The looping stops if the method returns an expression that evaluates to true.
precedence NumbernumInPath(/*Point*/ toPoint, /*Point*/ fromPoint, /*String*/ board)
Counts the number of non-blank values lie in between two points. The points must be separated in one of the 6 hexorthogonal directions.
precedence RectanglescreenRectFromBoardXY(/*Number*/ boardX, /*Number*/ boardY)
Gets the screen rectangle from board coordinates.
private static  $setSides(hex, args)
precedence StringvalueIndexFromBoardXY(/*Number*/ x, /*Number*/ y, /*String*/ board)
Gets the board value at a coordinate.

Methods inherited from Foundation.Interface
getTypePath

Method Detail

boardPointFromScreenXY

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

Gets the board point from a screen coordinates.

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

boardPointFromValueIndex

precedence Point boardPointFromValueIndex(/*Number*/ index)

Gets the board point from the board value index.

Parameters:
index - 
The board value index.
Returns:
The board point.

dispose

dispose()
Overrides:
dispose in class Interface

forEachBoardPoint

precedence Variant forEachBoardPoint(/*String*/ methodName,
                                     /*Variant*/ parameters,
                                     ...)

Calls a method of the game for each point on the board, with the board point as the first parameter. The looping stops if the method returns an expression that evaluates to true.

Parameters:
methodName - 
The name of the game method to call.
parameters - 
(Optional)(Repeatable) Additional parameters to pass to the method after the board point.
Returns:
The first expression from the method that evaluated to true, or null.

numInPath

precedence Number numInPath(/*Point*/ toPoint,
                            /*Point*/ fromPoint,
                            /*String*/ board)

Counts the number of non-blank values lie in between two points. The points must be separated in one of the 6 hexorthogonal directions.

Parameters:
toPoint - 
One end of the straight line.
fromPoint - 
One end of the straight line.
board - 
The board string (a representation of the board state as a string).
Returns:
The number of non-blank spaces, excluding toPoint and fromPoint.
Notes:
fromPoint and toPoint must be separated in one of the 6 hexorthogonal directions. Pieces on fromPoint or toPoint are not counted.

screenRectFromBoardXY

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

Gets the screen rectangle from board coordinates.

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

$setSides

private static $setSides(hex,
                         args)
Parameters:
hex - 

args - 


valueIndexFromBoardXY

precedence String valueIndexFromBoardXY(/*Number*/ x,
                                        /*Number*/ y,
                                        /*String*/ board)

Gets the board value at a coordinate.

Parameters:
x - 
The x coordinate, in board point space.
y - 
The y coordinate, in board point space.
board - 
The board string (a representation of the board state as a string).
Returns:
The value at the coordinate.