Games\Empires\Game.js
GamesByEmail
Object
GamesByEmail.Territory
All Implemented Interfaces:
GamesByEmail.EmpiresTerritory
extendsTerritory
Constructor Summary |
// 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 | |
|
//merges land into Empire without a fight
|
|
|
|
|
|
|
|
|
|
//Called when playing a kingdom card
//iKingdom is empireId for Kingdom.
|
|
|
|
|
|
|
|
/*
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 |
|
//This exists in the base class as a stub that returns the htmlBuilder.
//Override it here to append html representing the territory overlay image.
|
|
// methods and properties
|
|
|
|
|
|
|
|
|
|
//removes all icons from the territory
|
|
//call at the start of a new Epoch
|
|
//only valid for continents
|
|
|
|
|
|
|
|
//optionally pass in a point as the second param to specify the location
//of this army piece.
|
|
//Convert Territory Data into bits in a bitArray.
//returns next position in array where data can be written
|
|
/* 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
|
|
//returns 0 to 4. see constants below
|
|
//eg: hiliteImage:"%p/h/%t.png",
|
|
//appends html with info about this territory to htmlBuilder.
//Used for the MouseHtml dialog.
//eg: Full name of territory,Player,Empire.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
//id is index of "other" territory.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Used to test if a territory can be invaded.
|
|
|
|
|
|
|
|
|
|
|
|
//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
|
|
/*
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
|
|
//iOverlay num, 0 to maxThrob
//if 0, all will be hidden
|
|
//p - private method.
|
|
|
|
|
|
// -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
|
|
|
|
//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
|
|
//Handles showing *special* icons... usually as result of cards being played.
|
|
|
|
//Called whenever territory color needs to be changed.
|
|
|
|
|
Methods inherited from GamesByEmail.Territory |
containsPoint , event , hideHilite , isColor , isOurs , setBlink , showHilite , showHiliteIfOurs |
Methods inherited from Foundation.Class |
getTypePath , isInstanceOf |
Constructor Detail |
GamesByEmail.EmpiresTerritory()
// This is the base class being extended
Field Detail |
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
Method Detail |
absorb()
//merges land into Empire without a fight
addArmy(iEmpire,
bUpdateScreen,
/*opt*/)
iEmpire -
bUpdateScreen -
/*opt*/ -bDowngradeCity
addBoat()
addCity()
addFort()
addKingdom()
//Called when playing a kingdom card //iKingdom is empireId for Kingdom.
addMonument(iMonument)
iMonument -
addPalace()
adjacentIndex(i)
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
appendHtml
in class 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.
Overrides:appendOverlayHtml
in class Territory
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)
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",
Overrides:getHiliteImageSrc
in class Territory
getMouseHtml()
//appends html with info about this territory to htmlBuilder. //Used for the MouseHtml dialog. //eg: Full name of territory,Player,Empire.
getOpacity(throbCount)
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)
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)
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()