File: Games\Empires\Game.js

GamesByEmail
Class EmpiresTerritory

Object
  
 
 
GamesByEmail.Territory
 
 
GamesByEmail.EmpiresTerritory

All Implemented Interfaces:

Class


GamesByEmail.EmpiresTerritory

extends Territory

Constructor Summary
GamesByEmail.EmpiresTerritory()
// This is the base class being extended

Field Summary
static  bSkipABeat
//cancelThrob tracks this. If it misses a beat, add 10. If it works subtract one. If cancelThrob > cancelThreshhold, kill the throb!
static  bUseThrob
// This will hold our static methods and properties.
static  cancelThreshhold
//used to reverse step direction
static  maxOpacity
//set to false to turn of throb feature altogether. /* //Original settings with pngs maxOpacity:43, // eg: Use 100 for 100% opacity of the hilite image. maxThrob:3, // Number of steps to use between 0 opacity and maxOpacity //Steps = maxThrob-1. eg: If set to 2. you're using 3 // steps go from 0 to maxOpacity. throbDelay:260, //Milliseconds between updating display. */ //new settings for gifs. They look choppy. The throb has a period of //260*3
static  maxThrob
// eg: Use 100 for 100% opacity of the hilite image.
static  maxThrobDelay
//Milliseconds between updating display.
static  minThrob
//-1 to step down
static  throbCount
//Optimization: if it takes longer than this between // throbs, bail. Means rendering throbList must be faster than // maxThrobDelay-throbDelay eg(100ms, 1/10th second)
static  throbDelay
// Number of steps to use between 0 opacity and maxOpacity //Steps = maxThrob-1. eg: If set to 2. you're using 3 // steps go from 0 to maxOpacity.
static  throbIncrement
//current step

Fields inherited from GamesByEmail.Territory
adjacent, adjacentIndices, color, game, index, indexString, polygon, territories, title

Method Summary
 absorb()
//merges land into Empire without a fight
 addArmy(iEmpire, bUpdateScreen, /*opt*/)
 addBoat()
 addCity()
 addFort()
 addKingdom()
//Called when playing a kingdom card //iKingdom is empireId for Kingdom.
 addMonument(iMonument)
 addPalace()
 adjacentIndex(i)
 appendHtml()
/* initializeOffsets:function() var aOffsets = this.game.resource("offsetsAndSizes"); this.hiliteOffset=new Foundation.Point( aOffsets[ this.index ][ 0 ], aOffsets[ this.index ][ 1 ] ); this.size = new Foundation.Point( aOffsets[ this.index ][ 2 ], aOffsets[ this.index ][ 3 ] ); , */ //outputs an html "placeholder" for this territory
 appendOverlayHtml()
//This exists in the base class as a stub that returns the htmlBuilder. //Override it here to append html representing the territory overlay image.
 blurt()
// methods and properties
 canHaveArmy()
 canHaveBoat()
 canHaveMonument()
 canHavePalace()
 clear()
//removes all icons from the territory
 clearSpecialIcons()
//call at the start of a new Epoch
 contains()
//only valid for continents
 dispose()
 doDisaster()
 getAdjacentWaters(bOceans, bSeas)
 getArmyPieceHtml()
//optionally pass in a point as the second param to specify the location //of this army piece.
 getAsBits()
//Convert Territory Data into bits in a bitArray. //returns next position in array where data can be written
 getContinentHtml()
/* eg At the end of your turn, North Africa will count for 3 At least one army here 6 At least 2 and more than anyone else 9 At least 3 and no others here
 getDifficultTerrainType()
//returns 0 to 4. see constants below
 getHiliteImageSrc()
//eg: hiliteImage:"%p/h/%t.png",
 getMouseHtml()
//appends html with info about this territory to htmlBuilder. //Used for the MouseHtml dialog. //eg: Full name of territory,Player,Empire.
 getOpacity(throbCount)
 getOverlayImageSrc()
 getShortName()
 getString()
 hasAnOccupiedAdjacentTerritory()
 hasBoat()
 hasCity()
 hasCityOrCapital()
 hasFort()
 hasFortCapitalOrCity()
 hasMonument()
static  incrementThrob()
 isAdjacent()
//id is index of "other" territory.
 isAdjacentToOceanWithBoat()
 isBarren()
 isCapital()
 isContinentTag()
 isDifficultTerrainTo(toId)
 isEnemyOccupied()
 isLandAndNotBarren()
//Used to test if a territory can be invaded.
 isOccupied()
 isOcean()
 isSea()
 isUnoccupied()
 isWater()
 loseABattle()
//Handles losing a battle for a territory. //If no army is present, the territory reverts to neutral //revise input param if more scenarios are found
 numBitsNeeded()
/* EMPIRES TERRITORY BIT-ENCODING SCHEME IF WATER: this.iBoatPiece = this.NONE; // -1 to 6 1perEpoch(3Bits ) IF NOT WATER: this.iCityType=this.CITYTYPE.NONE;// -1 to 3 (2Bits) this.iInvaderPiece = this.NONE; // -1 to 75. More? (7Bits) this.bFortPiece = false; // 0|1 (1Bits) this.iMonument = this.NONE; // -1 to 55 (6Bits) this.iHoldingColor=this.NONE; //-1 to 5 (3Bits) this.iEmpireIndex=this.NONE; //-1 to 69 (7Bits) // -------- // 26bits! //Empire which built city here, used to show city names in mouse dialogs. //this.iCityEmpire=this.NONE; //-1 to 69 (7Bits)? */ //CHANGE THIS IF ENCODING CHANGES
 pSetThrobOverlayVisible()
//iOverlay num, 0 to maxThrob //if 0, all will be hidden
 pThrob()
//p - private method.
 removeBoat()
 sIndex()
 setOpacity()
// -moz-opacity for older Mozilla browsers. // opacity for CSS 3. // filter: alpha(opacity=50) //Maybe I need more logic here to determine what the //name of the opacity member is here. //(eg: What's supported in Opera and Safari?) // value: 0: transparent. 100 = opaque
 setString(string)
 setToBits()
//Takes bitArray, and assigns class members to data beginning at //iStartPos, using the Territory BitEncoding Scheme. //returns next position in array where data can be written
 showIcon()
//Handles showing *special* icons... usually as result of cards being played.
 showTitle()
 updateColor()
//Called whenever territory color needs to be changed.
 updateHtml()
 updateThrob()

Methods inherited from GamesByEmail.Territory
containsPoint, event, hideHilite, isColor, isOurs, setBlink, showHilite, showHiliteIfOurs

Methods inherited from Foundation.Class
getTypePath, isInstanceOf

Constructor Detail

EmpiresTerritory

GamesByEmail.EmpiresTerritory()

// This is the base class being extended

Field Detail

bSkipABeat

static bSkipABeat

//cancelThrob tracks this. If it misses a beat, add 10. If it works subtract one. If cancelThrob > cancelThreshhold, kill the throb!


bUseThrob

static bUseThrob

// This will hold our static methods and properties.


cancelThreshhold

static cancelThreshhold

//used to reverse step direction


maxOpacity

static maxOpacity

//set to false to turn of throb feature altogether. /* //Original settings with pngs maxOpacity:43, // eg: Use 100 for 100% opacity of the hilite image. maxThrob:3, // Number of steps to use between 0 opacity and maxOpacity //Steps = maxThrob-1. eg: If set to 2. you're using 3 // steps go from 0 to maxOpacity. throbDelay:260, //Milliseconds between updating display. */ //new settings for gifs. They look choppy. The throb has a period of //260*3


maxThrob

static maxThrob

// eg: Use 100 for 100% opacity of the hilite image.


maxThrobDelay

static maxThrobDelay

//Milliseconds between updating display.


minThrob

static minThrob

//-1 to step down


throbCount

static throbCount

//Optimization: if it takes longer than this between // throbs, bail. Means rendering throbList must be faster than // maxThrobDelay-throbDelay eg(100ms, 1/10th second)


throbDelay

static throbDelay

// Number of steps to use between 0 opacity and maxOpacity //Steps = maxThrob-1. eg: If set to 2. you're using 3 // steps go from 0 to maxOpacity.


throbIncrement

static throbIncrement

//current step

Method Detail

absorb

absorb()

//merges land into Empire without a fight


addArmy

addArmy(iEmpire,
        bUpdateScreen,
        /*opt*/)
Parameters:
iEmpire - 

bUpdateScreen - 

/*opt*/ - 
bDowngradeCity

addBoat

addBoat()

addCity

addCity()

addFort

addFort()

addKingdom

addKingdom()

//Called when playing a kingdom card //iKingdom is empireId for Kingdom.


addMonument

addMonument(iMonument)
Parameters:
iMonument - 


addPalace

addPalace()

adjacentIndex

adjacentIndex(i)
Parameters:
i - 


appendHtml

appendHtml()

/* initializeOffsets:function() var aOffsets = this.game.resource("offsetsAndSizes"); this.hiliteOffset=new Foundation.Point( aOffsets[ this.index ][ 0 ], aOffsets[ this.index ][ 1 ] ); this.size = new Foundation.Point( aOffsets[ this.index ][ 2 ], aOffsets[ this.index ][ 3 ] ); , */ //outputs an html "placeholder" for this territory

Overrides:
appendHtml in class Territory

appendOverlayHtml

appendOverlayHtml()

//This exists in the base class as a stub that returns the htmlBuilder. //Override it here to append html representing the territory overlay image.

Overrides:
appendOverlayHtml in class Territory

blurt

blurt()

// methods and properties


canHaveArmy

canHaveArmy()

canHaveBoat

canHaveBoat()

canHaveMonument

canHaveMonument()

canHavePalace

canHavePalace()

clear

clear()

//removes all icons from the territory


clearSpecialIcons

clearSpecialIcons()

//call at the start of a new Epoch


contains

contains()

//only valid for continents


dispose

dispose()
Overrides:
dispose in class Territory

doDisaster

doDisaster()

getAdjacentWaters

getAdjacentWaters(bOceans,
                  bSeas)
Parameters:
bOceans - 

bSeas - 


getArmyPieceHtml

getArmyPieceHtml()

//optionally pass in a point as the second param to specify the location //of this army piece.


getAsBits

getAsBits()

//Convert Territory Data into bits in a bitArray. //returns next position in array where data can be written


getContinentHtml

getContinentHtml()

/* eg At the end of your turn, North Africa will count for 3 At least one army here 6 At least 2 and more than anyone else 9 At least 3 and no others here


getDifficultTerrainType

getDifficultTerrainType()

//returns 0 to 4. see constants below


getHiliteImageSrc

getHiliteImageSrc()

//eg: hiliteImage:"%p/h/%t.png",

Overrides:
getHiliteImageSrc in class Territory

getMouseHtml

getMouseHtml()

//appends html with info about this territory to htmlBuilder. //Used for the MouseHtml dialog. //eg: Full name of territory,Player,Empire.


getOpacity

getOpacity(throbCount)
Parameters:
throbCount - 


getOverlayImageSrc

getOverlayImageSrc()

getShortName

getShortName()

getString

getString()

hasAnOccupiedAdjacentTerritory

hasAnOccupiedAdjacentTerritory()

hasBoat

hasBoat()

hasCity

hasCity()

hasCityOrCapital

hasCityOrCapital()

hasFort

hasFort()

hasFortCapitalOrCity

hasFortCapitalOrCity()

hasMonument

hasMonument()

incrementThrob

static incrementThrob()

isAdjacent

isAdjacent()

//id is index of "other" territory.


isAdjacentToOceanWithBoat

isAdjacentToOceanWithBoat()

isBarren

isBarren()

isCapital

isCapital()

isContinentTag

isContinentTag()

isDifficultTerrainTo

isDifficultTerrainTo(toId)
Parameters:
toId - 


isEnemyOccupied

isEnemyOccupied()

isLandAndNotBarren

isLandAndNotBarren()

//Used to test if a territory can be invaded.


isOccupied

isOccupied()

isOcean

isOcean()

isSea

isSea()

isUnoccupied

isUnoccupied()

isWater

isWater()

loseABattle

loseABattle()

//Handles losing a battle for a territory. //If no army is present, the territory reverts to neutral //revise input param if more scenarios are found


numBitsNeeded

numBitsNeeded()

/* EMPIRES TERRITORY BIT-ENCODING SCHEME IF WATER: this.iBoatPiece = this.NONE; // -1 to 6 1perEpoch(3Bits ) IF NOT WATER: this.iCityType=this.CITYTYPE.NONE;// -1 to 3 (2Bits) this.iInvaderPiece = this.NONE; // -1 to 75. More? (7Bits) this.bFortPiece = false; // 0|1 (1Bits) this.iMonument = this.NONE; // -1 to 55 (6Bits) this.iHoldingColor=this.NONE; //-1 to 5 (3Bits) this.iEmpireIndex=this.NONE; //-1 to 69 (7Bits) // -------- // 26bits! //Empire which built city here, used to show city names in mouse dialogs. //this.iCityEmpire=this.NONE; //-1 to 69 (7Bits)? */ //CHANGE THIS IF ENCODING CHANGES


pSetThrobOverlayVisible

pSetThrobOverlayVisible()

//iOverlay num, 0 to maxThrob //if 0, all will be hidden


pThrob

pThrob()

//p - private method.


removeBoat

removeBoat()

sIndex

sIndex()

setOpacity

setOpacity()

// -moz-opacity for older Mozilla browsers. // opacity for CSS 3. // filter: alpha(opacity=50) //Maybe I need more logic here to determine what the //name of the opacity member is here. //(eg: What's supported in Opera and Safari?) // value: 0: transparent. 100 = opaque


setString

setString(string)
Parameters:
string - 


setToBits

setToBits()

//Takes bitArray, and assigns class members to data beginning at //iStartPos, using the Territory BitEncoding Scheme. //returns next position in array where data can be written


showIcon

showIcon()

//Handles showing *special* icons... usually as result of cards being played.


showTitle

showTitle()

updateColor

updateColor()

//Called whenever territory color needs to be changed.


updateHtml

updateHtml()

updateThrob

updateThrob()