Games\GamesByEmail.jsObject
GamesByEmail
Namespace for all of GamesByEmail.com's classes.
| Interface Summary | |
static | Hex
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. |
| Class Summary | |
static | Game
Base class for all games.
|
static | GameNotify
The notification flag structure of
GamesByEmail.Game.notify. Set appropriate flags for events in the game and players who have suscribed to those events will get notified. |
static | GameStatus
The status structure of
GamesByEmail.Game.status. |
static | HexH
A background class for games with a hexagonal board having a horizontal axis, such as Triversi. The behind-the-scenes methods support the
GamesByEmail.Hex class. |
static | HexV
A background class for games with a hexagonal board having a vertical axis, such as McCooey Hex Chess. The behind-the-scenes methods support the
GamesByEmail.Hex class. |
static | Info
A generic repository for key value pairs. Used to save state data in the game and team, and preferences for the player.
|
static | LogSettings
Log settings...
|
static | Move
Information about the last move.
|
static | Piece
A piece class for games like chess. May be used directly or extended.
|
static | Pieces
A collection of pieces in a game, like chess. May be used directly or extended. Implemented as an
Array. |
static | Player
Information about a player.
|
static | Players
A collection of
GamesByEmail.Player objects. Implemented as an Array. |
static | Team
Information about a team.
|
static | TeamNotify
The notification flag structure of
GamesByEmail.Team.notify. Set appropriate flags for events in the game and players who have suscribed to those events will get notified. |
static | TeamStatus
The status structure of
GamesByEmail.Game.status. |
static | Teams
A collection of
GamesByEmail.Team objects. Implemented as an Array. |
static | Territories
A collection of territories in a game, like Gambit. May be used directly or extended. Implemented as an
Array. |
static | Territory
A territory class for games like Gambit. May be used directly or extended.
|
| Enum Summary | |
static | ARROW_KEY_CODE
Arrow key codes for use against event.keyCode.
|
static | CURSOR
Cross browser hand cursor value for element.style.cursor.
|
static | GAME_TYPE
Type of game, set in the
GamesByEmail.Game.type field. |
| Function Summary | |
static |
Generates the HTML necessary to show an inline clipped image.
|
static |
Writes a message to the first game on the page's message area.
|
static |
Makes a simple classless copy of an object. Each sub object is copied as well.
|
static |
Returns an array of pseudo-random integers from 1 to 6 inclusive.
|
static |
Returns a pseudo-random integer from 1 to 6 inclusive.
|
static |
|
static |
Gets the top left offset of an element from its layout parent.
|
static |
Gets the rectangle of an element from its layout parent.
|
static |
Generates HTML element attributes necessary to have an HTML hover title on an element.
|
static |
Generates the HTML necessary for a textarea that displays as a single line, but grows (overlaying elements above it) as the user types. Used to generate the game message chat areas.
|
static |
Finds the first game in the page.
|
static |
Gets the best black or white contrast for a color.
|
static |
Tests for best black or white contrast for an r-g-b color triplet.
|
static |
Converts a numeric value to a 0 padded hex string.
|
static |
Clips and positions an image element and/or returns the style properties necessary to clip an element. Low level, you should probably be using
positionImage. |
static |
Cross-browser detection whether a mouse event is a left button event. Always pass true for allowKeyboardModifier.
|
static |
Cross-browser detection whether a mouse event is a middle button event.
|
static |
Cross-browser detection whether a mouse event is a right button event. Always pass true for allowKeyboardModifier.
|
static |
Clips and positions an image element and/or returns the style properties necessary to clip an element.
|
static |
Returns a pseudo-random integer between a low and a high, inclusive.
|
static |
Makes a simple classless copy of an object. Sub object are not copied, but are shared between the instances.
|
| Enum Detail |
static Number ARROW_KEY_CODE
Arrow key codes for use against event.keyCode.
Values:LEFT -Left arrow.
RIGHT -Right arrow.
UP -Up arrow.
DOWN -Down arrow.
static String CURSOR
Cross browser hand cursor value for element.style.cursor.
Values:HAND -Hand cursor.
static Number GAME_TYPE
Type of game, set in the GamesByEmail.Game.type field.
CHESS -Chess.
BACKGAMMON -Backgammon.
CHECKERS -Checkers.
REVERSI -Reversi.
LINK_4 -Link 4.
ATAXX -Ataxx.
TWIXT -Twixt.
XIANGQI -Xiangqi.
DARK_CHESS -Dark chess.
OMEGA_CHESS -Omega Chess.
DARK_OMEGA_CHESS -Dark Omega Chess.
CHINESE_CHECKERS -Chinese checkers.
TRIVERSI -Triversi.
DEADGAMMON -Deadgammon.
HYPERGAMMON -Hypergammon.
NACKGAMMON -Nackgammon.
GAMBIT -Gambit.
DARK_GAMBIT -Dark Gambit.
BLIND_GAMBIT -Blind Gambit.
SPY_GAMBIT -Spy Gambit.
GIPF -GIPF.
ZERTZ -ZERTZ.
DVONN -DVONN.
DARK_XIANGQI -Dark Xiangqi.
TIC_TAC_TOE -Tic Tac Toe.
REFLEKTIT -Reflektit.
BLIND_TRIVERSI -Blind Triversi.
MCCOOEY_HEX_CHESS -Mccooey Hex Chess.
DARK_MCCOOEY_HEX_CHESS -Dark Mccooey Hex Chess.
GO -Go on an 19x19 board.
GO_13X13 -Go on a 13x13 board.
GO_9X9 -Go on a 9x9 board.
POLITICS -Politics.
WW2 -W.W.II
YINSH -YINSH.
BLITZ_YINSH -Blitz YINSH.
BYTE_8X8 -Byte on an 8x8 board.
BYTE_10X10 -Byte on a 10x10 board.
SNAG -Snag.
ELUDE -Elude.
DARK_ELUDE -Dark Elude.
PLOT -Plot.
DARK_PLOT -Dark Plot.
BLIND_PLOT -Blind Plot.
MERGERS -Mergers.
FIVES -Fives.
DARK_ATAXX -Dark Ataxx.
NINE_MENS_MORRIS -Nine Mens Morris.
TANBO -Tanbo.
DIPOLE -Dipole.
CEPHALOPOD -Cephalopod.
ATOLL -Atoll.
RUSH -Rush.
CROSSWAY -Crossway.
CROSSWAY_PIED -Crossway pied.
SCRIBE -Scribe.
SUPERGLYPH_SCRIBE -Scribe.
DIFFUSION -Diffusion.
COPOLYMER -Copolymer.
OUST_SQUARE_OLD -Oust (square on too big board).
BEGIRD -Begird.
BEGIRD_PIED -Begird pied.
PALISADE -Palisade.
IMPASSE -Impasse.
QUADRATURE -Quadrature.
MECHA -War Mechs.
EMPIRES -Empires.
LARIAT -Lariat.
LARIAT_PIED -Lariat pied.
VIKTORY2 -Viktory II.
ATOLL_PIED -Atoll pied.
LOOPHOLE_2D -Loophole 2D
GOMOKU -Gomoku
PLATEAU -Plateau
CAPTURE_THE_FLAG -Capture the flag.
BATTLE_BOATS -Battle Boats.
CAGE -Cage
OUST_SQUARE -Oust (square).
OUST_HEX -Oust (hex).
FLUME_SQUARE -Flume (square).
FLUME_SQUARE_PIED -Flume (square) pied.
FLUME_HEX -Flume (hex).
FLUME_HEX_PIED -Flume (hex) pied.
FRACTAL -Fractal.
X -X.
RIVE -Rive.
PHALANX -Phalanx
| Function Detail |
static String clippedImageHtml(/*String*/ src,
/*Rectangle*/ clipRect,
/*String*/ styles,
/*String*/ attibutes)
Generates the HTML necessary to show an inline clipped image.
Parameters:src -The image src.
clipRect -The clipping rectangle for the image.
styles -(Optional) Additional styles surrounding the image, as a CSS string.
attibutes -(Optional) Additional HTML attributes of the image.
static Boolean debug(/*String*/ value)
Writes a message to the first game on the page's message area.
Parameters:value -(Optional) The value to display. Call with no parameters to clear the message board.
true.
static Object deepCopy(/*Object*/ object)
Makes a simple classless copy of an object. Each sub object is copied as well.
Parameters:object -The object to copy.
static Array diceRolls(/*Number*/ num)
Returns an array of pseudo-random integers from 1 to 6 inclusive.
Parameters:num -The number of die rolls to return.
num numbers number greater than or equal to 1 and less than or equal to 6, generated locally from Math.random.
static Number dieRoll()
Returns a pseudo-random integer from 1 to 6 inclusive.
Returns:
static elementHasIdInHierarchy(element,
id)
element -
id -
static Point elementPageOffset(/*Element*/ element)
Gets the top left offset of an element from its layout parent.
Parameters:element -The document element to check.
x is the left offset, and y is the top offset.
static Rectangle elementPageRectangle(/*Element*/ element)
Gets the rectangle of an element from its layout parent.
Parameters:element -The document element to check.
x is the left offset, and y is the top offset, and the width and height match that of the element.
static String elementTitleAttributes(/*String*/ title)
Generates HTML element attributes necessary to have an HTML hover title on an element.
Parameters:title -The HTML to dislpay when the user hovers the mouse over the element.
Example:
var title="<H1>Big bold hover title!</H1>"; html+="<div "+GamesByEmail.elementTitleAttributes(title)+">Hover here to see big text.</div>";
static String expandingTextareaHtml(/*String*/ id,
/*String*/ width,
/*Number*/ lineHeight,
/*Number*/ maxLines,
/*String*/ additionalStyle,
/*String*/ additionalAttributes)
Generates the HTML necessary for a textarea that displays as a single line, but grows (overlaying elements above it) as the user types. Used to generate the game message chat areas.
Parameters:id -The id of the element.
width -The width of the element, as a CSS string.
lineHeight -The height of a line of text. 16 seems to work well.
maxLines -The maximum number of lines to grow. After this size is reached, the contents will start scrolling.
additionalStyle -(Optional) Any additional style attributes to add, as a CSS string.
additionalAttributes -(Optional) Any additional attributes to add.
static Game findFirstGame()
Finds the first game in the page.
Returns:
static String getBestBwContrast(/*String*/ color)
Gets the best black or white contrast for a color.
Parameters:color -The color to test in '#hhhhhh' format.
static Boolean getBestBwContrast(/*Number*/ red,
/*Number*/ blue,
/*Number*/ green)
Tests for best black or white contrast for an r-g-b color triplet.
Parameters:red -The red component of the color [0-255].
blue -The green component of the color [0-255].
green -The blue component of the color [0-255].
static String getHexString(/*Number*/ value,
/*Number*/ minLength)
Converts a numeric value to a 0 padded hex string.
Parameters:value -The value to convert.
minLength -(Optional) The minimum string length returned. Leading 0s are padded if necessary to meet this length.
static String imgSetClip(/*Element*/ Image,
/*Number*/ positionX,
/*Number*/ positionY,
/*Number*/ clipX,
/*Number*/ clipY,
/*Number*/ clipWidth,
/*Number*/ clipHeight)
Clips and positions an image element and/or returns the style properties necessary to clip an element. Low level, you should probably be using positionImage.
Image -element to clip or
null.positionX -The x position of image.
positionY -The y position of image.
clipX -The x position of the clipping.
clipY -The y position of the clipping.
clipWidth -The width of the clipping.
clipHeight -The height of the clipping.
Example:
// Both examples will position an image left/top at 20,30 clipped to show only the
// part of the image from 5,12 to 7,18 (clipped width of 3, height of 7).
//To clip an existing image element:
var myImage=game.getElement("myImage");
GamesByEmail.imgSetClip(myImage,20,30,5,12,3,7);
//To build HTML for a new image element. Note null passed for first parameter.
html+="<IMG src=\"myImage.gif\" style=\""+GamesByEmail.imgSetClip(null,20,30,5,12,3,7)+"\">";
See Also:
static Boolean isLeftButtonEvent(/*Event*/ event,
/*Boolean*/ allowKeyboardModifier)
Cross-browser detection whether a mouse event is a left button event. Always pass true for allowKeyboardModifier.
Parameters:event -The document event object.
allowKeyboardModifier -Allow a CTRL-Left click equal a right click. Some crappy browsers do not allow capture of right click events.
static Boolean isMiddleButtonEvent(/*Event*/ event)
Cross-browser detection whether a mouse event is a middle button event.
Parameters:event -The document event object.
static Boolean isRightButtonEvent(/*Event*/ event,
/*Boolean*/ allowKeyboardModifier)
Cross-browser detection whether a mouse event is a right button event. Always pass true for allowKeyboardModifier.
Parameters:event -The document event object.
allowKeyboardModifier -Allow a CTRL-Left click to equal a right click. Some crappy browsers do not allow capture of right click events.
static String positionImage(/*Element*/ element,
/*Point|Rectangle*/ position,
/*Rectangle*/ clipRect)
Clips and positions an image element and/or returns the style properties necessary to clip an element.
Parameters:element -Image element to clip or
null.position -The center of where to position the image.
clipRect -The clipping rectangle for the image.
Example:
// Both examples will position an image *centered* at 20,30 clipped to show only the
// part of the image from 5,12 to 7,18 (clipped width of 3, height of 7).
var center=new Foundation.Point(20,30);
var clip=new Foundation.Rectangle(5,12,3,7);
//To clip an existing image element:
var myImage=game.getElement("myImage");
GamesByEmail.positionImage(myImage,center,clip);
//To build HTML for a new image element. Note null passed for first parameter.
html+="<IMG src=\"myImage.gif\" style=\""+GamesByEmail.positionImage(null,center,clip)+"\">";
static Number random(/*Number*/ high,
/*Number*/ low)
Returns a pseudo-random integer between a low and a high, inclusive.
Parameters:high -The highest value to be returned.
low -(Optional) The lowest value to be returned (defaults to zero).
GamesByEmail.Game.random
static Object shallowCopy(/*Object*/ object)
Makes a simple classless copy of an object. Sub object are not copied, but are shared between the instances.
Parameters:object -The object to copy.