File: Games\GamesByEmail.js

GamesByEmail
Class Territory

Object
  
 
 
GamesByEmail.Territory

All Implemented Interfaces:

Class


GamesByEmail.Territory

implements Foundation.Class

A territory class for games like Gambit. May be used directly or extended.

See Also:

GamesByEmail.Territories

Constructor Summary
GamesByEmail.Territory(/*Territories*/ territories, /*Number*/ index, /*String*/ indexString, /*Game*/ game, /*Object*/ territory)
Creates a territory.

Field Summary
Arrayadjacent
The territories that are adjacent to this territory.
ArrayadjacentIndices
The indices of territories that are adjacent to this territory.
Numbercolor
The color of the owner of this territory.
Gamegame
The game this territory belongs to.
Numberindex
The position of this territory in the parent territores collection.
NumberindexString
A zero-padded index string, automatically padded to accomodate the number of territories in the collection.
Polygonpolygon
The polygon of this territory.
Territoriesterritories
The parent territories object.
Stringtitle
The name of this territory.

Method Summary
StringBuilderappendHtml(/*StringBuilder*/ htmlBuilder)
Appends the HTML necessary for the territory. By default adds an image element and calls the appendOverlayHtml method.
StringBuilderappendOverlayHtml(/*StringBuilder*/ htmlBuilder)
Override to add HTML that shows above the territory.
BooleancontainsPoint(/*Point*/ point)
Checks to see if a point is inside the territory's polygon.
 dispose()
Stringevent(/*String*/ code, /*Boolean*/ delayed)
Returns code that can be used in DOM events to invoke methods and properties of the territory.
BooleanhideHilite()
Turns the territory's highlight off.
BooleanisColor(/*Boolean*/ color)
Checks to see if a territory is a color.
BooleanisOurs()
Checks to see if a territory belongs to the current player. By default, checks to see if the color matches the team color.
voidsetBlink(/*Boolean*/ show)
Turns the territory's blinking on or off.
BooleanshowHilite()
Turns the territory's highlight on.
BooleanshowHiliteIfOurs()
Highlights the territory if it belongs to the current player based on the isOurs method.

Methods inherited from Foundation.Class
getTypePath, isInstanceOf

Constructor Detail

Territory

GamesByEmail.Territory(/*Territories*/ territories,
                       /*Number*/ index,
                       /*String*/ indexString,
                       /*Game*/ game,
                       /*Object*/ territory)

Creates a territory.

Parameters:
territories - 
The parent territories collection.
index - 
The position of this piece in the parent pieces object.
indexString - 
The zero-padded index string of the position of this piece in the parent pieces object.
game - 
The game this territory is in.
territory - 
The data for this territory to inherit.

Field Detail

adjacent

Array adjacent

The territories that are adjacent to this territory.


adjacentIndices

Array adjacentIndices

The indices of territories that are adjacent to this territory.


color

Number color

The color of the owner of this territory.


game

Game game

The game this territory belongs to.


index

Number index

The position of this territory in the parent territores collection.


indexString

Number indexString

A zero-padded index string, automatically padded to accomodate the number of territories in the collection.


polygon

Polygon polygon

The polygon of this territory.


territories

Territories territories

The parent territories object.


title

String title

The name of this territory.

Method Detail

appendHtml

StringBuilder appendHtml(/*StringBuilder*/ htmlBuilder)

Appends the HTML necessary for the territory. By default adds an image element and calls the appendOverlayHtml method.

Parameters:
htmlBuilder - 
The builder to append the HTML for the territory.
Returns:
The string builder.
See Also:
appendOverlayHtml

appendOverlayHtml

StringBuilder appendOverlayHtml(/*StringBuilder*/ htmlBuilder)

Override to add HTML that shows above the territory.

Parameters:
htmlBuilder - 
The builder to append the HTML for the territory.
Returns:
The string builder.

containsPoint

Boolean containsPoint(/*Point*/ point)

Checks to see if a point is inside the territory's polygon.

Parameters:
point - 
The point to check.
Returns:
True if the point is inclusively inside the polygon, else false.

dispose

dispose()
Overrides:
dispose in class Class

event

String event(/*String*/ code,
             /*Boolean*/ delayed)

Returns code that can be used in DOM events to invoke methods and properties of the territory.

Parameters:
code - 
The code of this territory to be executed. If no parameters passed, returns the fully qualified territory (to this).
delayed - 
Delay the event using window.setTimeout. Set to true if the HTML element invoking the event will be destroyed during the event.
Returns:
The fully qualified code string for the event of the territory.

Example:

// The following div will call the reset method of the territory when clicked.
htmlBuilder.append("<div onclick=\""+this.event("reset()")+"\">click here to reset territory</div>");

hideHilite

Boolean hideHilite()

Turns the territory's highlight off.

Returns:
true

isColor

Boolean isColor(/*Boolean*/ color)

Checks to see if a territory is a color.

Parameters:
color - 
The color to check.
Returns:
true if the territory's color matches.

isOurs

Boolean isOurs()

Checks to see if a territory belongs to the current player. By default, checks to see if the color matches the team color.

Returns:
true if the territory belongs to the current player.
See Also:
isColor

setBlink

void setBlink(/*Boolean*/ show)

Turns the territory's blinking on or off.

Parameters:
show - 
Starts or stops the blinking.

showHilite

Boolean showHilite()

Turns the territory's highlight on.

Returns:
true

showHiliteIfOurs

Boolean showHiliteIfOurs()

Highlights the territory if it belongs to the current player based on the isOurs method.

Returns:
true if the territory belongs to the current player.