File: Games\Empires\Game.js

GamesByEmail
Class EmpiresGame

Object
  
 
 
GamesByEmail.Game
 
 
GamesByEmail.EmpiresGame

All Implemented Interfaces:

Class, Elemental, Resourceful, Server


GamesByEmail.EmpiresGame

extends Game

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

Field Summary
static  bResourcesInitialized
//see initializeResources:function()
static  isIE
// This will hold our static methods and properties. //as a member, instead of a function
static  resourcePack
// the resourcePack is a collection of information // used throughout the class.

Fields inherited from GamesByEmail.Game
board, canPie, constrainer, font, id, info, isLog, lastMove, logSettings, maxMoveNumber, message, move, notify, onLeftMouseDown, onLeftMouseUp, onMiddleMouseDown, onMiddleMouseUp, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp, onRightMouseDown, onRightMouseUp, pieces, previewing, rotation, status, teams, territories, testing, title, type, verbose

Fields inherited from Foundation.Elemental
$Foundation_$registry_index

Method Summary
 allPlayersHavePickedEmpires()
 appendBoardSpaceHtml()
/////////////////////////////////////////////////////////////////////// //I'm overriding this to remove everything but the boardSpace // eg: topTeamTitles & bottomTeamTitles
 appendControlsHtml()
///////////////////////////////////////////////////////////////////////
 appendHtml()
/////////////// mouse Handler stubs for EmpiresTester /////////////////// ///////////////////////////////////////////////////////////////////////// //Override the parent html bulder.
 appendInnerHtml()
/////////////////////////////////////////////////////////////////////// //I'm overriding this such that the board appears above //the control space.
 applyParams()
//replaces occurrences of % delimited tokens in sHtml with //a value from sParams. sParams can be blank //sText= "%greeting% there %name%" and sParams="%greeting%:Hi|%name%:Bob" //gives "hi there Bob"
 assignDefaultMembersToTeams()
 assignGameOverMouseHandlers()
 assignMouseHandlers()
//Todo: Clean this up a bit... at the moment, the code branching //for game-state is being done in onMouseDown. Instead, assign //a few different mouse down handlers here for differing game //game state. //Assign MouseHandlersForEmpireExpansion
 assignSpectatorMouseHandlers()
 blinkMap(blinkCount)
 blinkMapEvent()
 calculateScore()
//Called from the monument Dialog
 cardWizMouseDown(screenPoint)
 cardWizMouseMove(screenPoint)
 cardWizMouseOut(screenPoint)
 centerContentWrapperHtml()
//Happens all the time I want content centered and css is a pain cuz //requires browser specific blah blah to valign. So use a table instead. //sPadding: Optional: something to set the cell padding attribute to. //returns start of centerContent Wrapper. call endCenterContentWrapperHtml() //to finish.
 checkAndPlayAnyMinorEmpires()
 checkAndPlayAnyPseudoEmpires()
/////////////// End Pre-Empire Phase/////////////////////////
 clearBoardOfMessages()
 clearMouseHandlers()
 convertArrayOfArraysToRectangles(a)
 convertArrayOfStringsToNumbers(inArray)
 convertArrayToRectangle()
//r: array of integers defining rectange. x,y,width,height
 createStylesheet(sCssRules)
 dealCards()
 deleteAllHelperObjects()
//Call to reset game state: eg: when setting state for next turn, or //during initialize.
 determineNextPlayer()
 determineWinnerAndEndGame()
 discardCard(iCardIndex)
 discardCardInPlay()
//sometimes it's easier to discard once the card has been played //instead of at the end of the turn.
 discardCardsInPlay()
//Removes played cards from the player's hand
 displayStartGameForm()
//Overridden. Scott finally found the problem with this one. I don't //have a gameForm element. Instead, assign the html to a parchment. //I am so impressed with how this all works!
 dispose()
 doSpectatorOrNotYourTurn()
//false for spectator mode. true for notYourTurn mode.
 enableUndoButton(bEnabled)
 endCenterContentWrapperHtml()
 endEmpireExpansion()
 endPickCardPhase()
 endPlayEmpireModCards()
 endPlayPreEmpireCards()
 endTurn()
 getActionLinksHtml()
/* //Consider moving this into territories.appendOverlayHtml() !!!! appendThrobContainer:function() if(this.getElement( 'throbContainer' ) ) return; if(this.testing && !this.bRelease) this.debug(" **appending Throb container**"); var container = document.createElement('div'); container.id=this.elementId("throbContainer"); var imageSize=this.board.image.size; //<div id=\"throbContainer\" style=\"position:absolute;top:0;left:0;width:947;height:622;visibility:hidden\"> container.setAttribute("style", "position:absolute;top:0;left:0;width:"+imageSize.x+"px; height:"+imageSize.y+"px;overflow:hidden;z-index:100"); var html=new Foundation.StringBuilder(); var src=this.getImageSrc("images/blank.png"); var t=this.territories, len=this.territories.length; for(var i=0;i<len;i++) undefined html.append("<img id=\""+this.elementId("territoryThrob_"+i)+"\" border=0 src=\""+src+"\" style=\"position:absolute; left:0; top:0; display:block; visibility:hidden;\" galleryimg=false>"); container.innerHTML=html.toString(); var b=this.getElement('boardContainer'); b.appendChild(container); if(this.testing && !this.bRelease) this.debug(" **DONE appending Throb container**");
 getBoardImageSrc(sName)
 getButtonHtml()
//Override Parent class to detect if it's not current player's //turn. If so, then disable whatever button is being output. //Hack: But this disables the "refresh game" and "send reminder" buttons // too? No problem. Use a temporary variable called: // bTempEnableButtonsWhenNotYourTurn. When true, allow the buttons to be // emitted without the "disabled" attribute. // Remarks: This was a last second fix. Hacky, but it'll do.
 getButtonHtmlNoDisable()
//Provide a means where any class can get a button which is never disabled. //Use this for buttons which players can click even if it's not their turn. //remarks: Bad hack, I should do this the other way on, but this is fast.
 getCardsInPlay()
 getCompositeBgImageDivs()
//returns string containing html with 2 divs. Outer div has outer gif // image with transparency & jagged edges. Inner div has jpg. //Inputs: iLeft,iTop: Optional params to specify absolute position of dialog. //Preconditions: CompositeBG resource has all members used herein // Tests show single gif = 154KB. Composite Gif+jpg=40kb.
 getDefaultFloatStyle()
 getDiceHtml()
//getDiceHtml( num, ColorZeroForWhiteOneForRed ) //iNum= 1-6. iColor 0 for white, 1 for Red
 getEmpireNameForScoreBoard(oTeam)
 getFirstEmpireForThisEpoch()
 getFloatHtml()
 getGameFormSetting(sSettingName, bDefaultVal)
 getGameOverMessage(bWithBreaks)
 getGameOverlayStubHtml(htmlBuilder)
StringgetGamePromptsHtml()
Called when needing the game prompts HTML. Override to set. Internally clears the mouse events, then returns either spectatingHtml, gameOverHtml, notYourTurnHtml or getTurnHtml.
 getMysteryNameOrPrivateEmpireLink(oTeam)
 getName()
//Ensures player's names aren't overly long. Long names cause //the display to distort in places.
 getNotYourTurnMouseHtml()
/* getSpectatingPromptHtml:function( html ) //What about GamePhase? //Determine which player is going to go next. var player = this.teams.getTurnTeam().players[0]; var sParams="%playerName%:"+player.title.htmlEncode(); //sParams+="%empireName%:"+ this.empireData[ this.player.team.majorEmpireIndex ].name var sPrompt = this.mousePrompts[ this.iCurrentMousePrompt ]; sPrompt=this.applyParams(sPrompt, sParams); html.append( '<br>'+sPrompt ); ,
 getPlayerPromptHtml(htmlBuilder, t)
 getPositionInTurnOrder()
//Returns a teams position within the current turnOrder array
 getRemainingArmiesHtml()
//empire object is optional. empire could be either instance of empire //class, or static data EmpiresData entry.
 getResourceImageSrc(sName)
 getScoreHtml()
//returns html text containing team titles + scores. //called from both getTeamTitlesHtml to build the initial page, //and from updateTeamTitles to update to "teamTitles" div.
 getShowTempHideMessage()
// Preconditions: Meant to be placed inside a relatively // positioned div
 getStartTurnLogMsg()
 getStateString()
 getString()
//Convert class state to string and return it //Current Format: //~GameState~CardWizardState~CurrentEmpire~BattleDialogState~TeamsState~Territories
 getTeamString(team)
StringgetTeamTitlesHtml(/*Boolean*/ top)
Gets the HTML for the team titles on the board.
 getTeamsString()
 getWaitingForNextPlayerMsgHtml()
 getWinner()
 getYellowButtonHtml(title, id, eventCode)
 goIntoExpansionMode()
 hasTeamPlayedThisEpochYet(oTeam)
 hideBuildFortDialog()
//iBuildOrCancel: -1 = cancel. 0 = spend army to build 1 = spend coin.
 hideDialog()
 hideEmpireDialog()
//Invoked when user clicks ok.
 hideEndEmpireDialog()
// Preconditions: // Could be hiding barbarians, Crusaders, a minor Empire, or // the major empire
 hideMouseDialog()
 importLog()
//overridden so logIndex can get set.
 initialize()
// Methods and Properties.
 initializeGameInBrowser()
//preconditions: Called once game board has been loaded.
 initializeResources()
//Attempt to reduce number of "new Foundation.Rectangle" declarations in resourcePack, //instead, only store arrays of x,y,width,height in the resource pack, and convert //them before attempting to load the board. Still not sure best place to invoke this from though
 isCardInPlay(iCardId)
 isMyTurn()
//Override this to provide a stub within the Framework object. //In the EmpiresTester, this function will get re-defined to //return false to allow for testing.
 isPresent()
//Test if input param exists
 isStringPresent()
//Test if input param exists and is a string.
StringitsYourTurnHtml(/*String*/ resourceName)
Called when needing the it-is-your-turn game prompt HTML (typically a short sentence about the move). Override and set mouse events here. Internally uses the "itIsYourTurnToMove" resource.
 logMouseDown(screenPoint)
 logMouseMove(screenPoint)
 logMouseOut(screenPoint)
 maybeEndTempHide()
//This event is called whenever a key is released
 maybeStartTempHide()
//re-using Scott's name. It's semantically ideal. Some slight differences //in implementation (of course I borrowed and hacked his code. :P ) //This event is called whenever a key is pressed
 monumentMouseDown(screenPoint)
 monumentMouseMove(screenPoint)
 monumentMouseOut(screenPoint)
 mouseDown(screenPoint)
 mouseDownGameOver(screenPoint)
 mouseDownPickTerritoryToAttackFrom(screenPoint)
 mouseDownSpectator(screenPoint)
 mouseMove()
///////////////////////////////////////////// ///////////////////////////////////////////// /////////////////////////////////////////////
 mouseMoveHidePrevious(territory)
 mouseMovePickTerritoryToAttackFrom(screenPoint)
 mouseMoveSpectator(screenPoint)
 mouseOut(screenPoint)
 mousedownBarbarians(empire, territory)
StringnotYourTurnHtml(/*String*/ resourceName)
Called when needing the it-is-not-your-turn game prompt HTML (typically a short sentence with Send Reminder, Refresh Game and Close Window buttons Start Another Game button). Override to set. Internally uses the "notYourTurn" resource.
 onBattleDialogClosed()
//called by battleDialog.
 openLog()
//Overridden API method. Sets window height and gives it scroll bars.
 placeEmpireOnBoard(empire)
 playEmpire(empireId)
 playEmpireModCards()
 playMajorEmpire()
//playEmpire Wrapper to account for Incas/Aztecs custom logic.
 playPreEmpireCards()
/////////////// Pre-Empire Phase////////////////////////////
 playSomeCards()
 processLogMove()
//Overridden method - called by API while creating a list of log moves
 refreshContinentPresence()
 refreshScreen()
 resign()
//override the parent class to ensure game state is // set for next player.
 restoreDefaultFloatStyle()
 restoreMouseHandlers()
//Used with saveAndClearMouseHandlers()
 restoreMouseMoveOnly()
 resumeCivilWar()
 resumeEmpireExpansion()
//Preconditions: Called from both game and EmpiresLog. //Called from game to intercept empireExpansion after sync when some special //scenario has happened. //Called from Log to re-use the dialogs of those scenarios.
 saveAndClearMouseHandlers()
//Used to compensate for floatHtml allowing mouse clicks to board below // in IE. Instead, pull the handlers altogether, show dialog, restore // handlers later.
 scramblePlayersWhoHaventGoneYet(aTeams)
BooleansendMove(/*Boolean*/ sendNow, /*Player*/ player)
Gets called when the Send Move button is pushed. Override and set the game state, then call Super.sendMove.
voidsetFloatHtml(/*String*/ html, /*Number*/ width, /*Number*/ height)
Shows HTML in a simple box centered over the board. Board mouse messages are suspended while box is shown.
 setFloatHtmlWithBgImage()
// Preconditions: set iLastDlgRegion to show dlg centered around one of the // pre-set dlgRegions. -1 to leave it centered. // BG Objects. have src, style & srcGif
 setFloatHtmlWithCompositeBgImage(sCompBgImageResourceName, sHtmlMsg)
 setFloatHtmlWithTransparentBG()
//Discovered I can't set a float html with a transparent bg. //Use this method instead. //Original float style will be restored on the next call to //setFloatHtml. //Also, calling this method with no html will restore the //default style.
 setGameStateForNextTurn()
 setHasUsedAllArmies()
 setNextPlayerForPickEmpirePhase()
// Preconditions: turnOrder array has already been set.
 setNextPlayerForPlayEmpirePhase()
//inputs: iNextEmpireIndex or 0 for the start of the game. // The index of the empire to start looking for. // During Empire Expansion, players play in the order of their empires. // This method takes an input Empire Index and checks if any of the // players are currently assigned to play it. // If no players are assigned, the EmpireIndex is incremented and another // search is made. // Once the team holding the "next empire" is found, the turn is set to // that player. // If no player is found, it is assumed to be the end of the Epoch.
 setOptionalData(sNameValuePair)
 setStateString(string)
 setString()
//Assigns string containing encoded "game state" to members like teams & territories.
 setTeamByBase64String(team, sB64Data)
 setTeamByString(team, string)
 setTeamByStringV2()
// ** Backward Compatibility Method
 setTeamToBitData()
/* EMPIRES TEAM Encoding Scheme this.majorEmpireIndex ( -1 to 69 ) (7Bits) this.points ( 0 to 300+ ) (10 bits) max score of 1024. this.teamWhoDealtUsThisEmpire ( 0-5 ) (3 bits) this.cardsInHand[] ( array each can be ( 0 to 41 ) n * 6 bits )
 setTeamsByString(teams, string)
 setTurnOrder()
 setupPlayersForNextEpoch()
 setupPlayersForPlayEmpirePhase()
 shallowCopy(inArray)
 showBigParchment(sHtmlMsg)
 showBigParchmentDialog()
// "Opt=optional"
 showBuildFortDialog()
 showChatWindow(html)
 showCompassPrompt(sHtml)
 showCompassPromptParchment(sHtml, sOnClick)
 showCompassPromptWithTransparentBG(sBgImageResourceName, sHtml)
 showEmpireDialog()
//maybe move this to the empire class.
 showEmpireDialogForBarbarians()
 showEmpireDialogForCrusaders()
 showEndBarbarianDialog()
 showEndCrusaderDialog()
 showEndEmpireDialog(sParams)
 showExpandEmpireCompassPrompt()
 showGameOverCompassPrompt()
 showItsYourTurnCompassPrompt()
 showItsYourTurnDialog()
// PLAY_EMPIRE Logic Flow // Show ItsYourTurnDialog for Active Empire //Show Play A Card Dialog //Play Pre-Empire Cards //If card played is Minor Empire //Show Empire Dialog for Minor Empire //Play minor empire //Play Cards which apply to major empire //Show Empire Dialog for major Empire //Play major Empire //Place Monuments & Score
 showLastEmpireInTitleAndMakeItThrob()
 showMonumentDialog()
 showNotesWindow(html)
 showScoreSummaryInMessageWindow()
 showSendMoveDialog()
 showSmallParchment(sHtmlMsg)
 showSmallParchmentDialog(sHtml, sOptEvent, sOptOkBtnName, sOptPadding)
 showSpectatorOrNotYourTurnCompassPrompt()
//false for spectator mode. true for notYourTurn mode.
 shuffle()
//shuffles items in input array and //returns result. //input array can contain anything
StringspectatingHtml()
Called when needing the you-are-spectating game prompts HTML. Override to set. Internally returns the following combined: refreshGameButtonHtml and closeWindowButtonHtml.
 startEmpireExpansion(empire)
 startTurnForThisPlayer()
 substitute()
// eg: .substitute("Hi %n %greeting%", '%n', 'Jim', %greeting%, "what's new"); // gives: Hi Jim, what's new //inputs: token1,value1, token2, value2
 synch()
//synchronize the game to it's current state.
 tellUserNoArmiesLeft()
 testerMouseDown(screenPoint)
 testerMouseMove()
///////////////////////////////////////////////////////////////////////// /////////////// mouse Handler delegators for EmpiresTester //////////////
 testerMouseOut(screenPoint)
 undo()
//Overridden to try testing if this.info["board"] is getting //corrupted somewhere (it is)
 updateEmpireDataRow()
//empire: could be integer or empire object
 updateMouseHtml()
//Called to update the markup displayed in the mouse prompt. //Called whenever mouse is supposed to be on and territory changes. //Also called during "itsYourTurnHtml()" //territory: Optional. If not passed in, current x,y under mouse is used //to get territory. If still no territory no territory data will be //added to the mousePrompt.
 updateOneTeamScore()
/* // REVISIT: add some logic to scramble remaining players who haven't // played their empires during empire expansion. tempTeams = this.scramblePlayersWhoHaventGoneYet(tempTeams);
 updateScore()
 viewCards()
 viewEmpires()

Methods inherited from GamesByEmail.Game
aboveTeamTitleRowHtml, acceptDeclineDrawHtml, acceptDraw, acceptDrawButtonHtml, addNote, addToPage, appendAdditionalPreferencesHtml, appendBoardHtml, beginTurnHtml, belowTeamTitleRowHtml, boardPointFromScreenPoint, boardPointFromScreenXY, boardPointFromValueIndex, boardValueFromValueColor, cancelGameButtonHtml, cancelGameHtml, checkMove, clearHilites, clearMouseEvents, closeWindowButtonHtml, closeWindowHtml, colorFromBoardValue, colorFromPointBoard, colorFromXYBoard, completeTurnHtml, completeYourTurnHtml, constrainPoint, constrainRectangle, continueTurnHtml, continueYourTurnHtml, debug, diceRolls, dieRoll, drawAcceptedHeaderHtml, drawAcceptedHtml, drawDeclinedHeaderHtml, drawDeclinedHtml, drawOfferedHeaderHtml, elementTitleAttributes, findNextPlayer, findPlayer, findWinningTeam, forEachBoardPoint, forEachTeam, gameInProgressHeaderHtml, gameOverHeaderHtml, gameOverHtml, getAnchorHtml, getCheckboxHtml, getHeaderHtml, getHtml, getHtmlButtonHtml, getImageSrc, getNewGamePlayerOrder, getNextGamesTitle, getOptionHtml, getPieType, getPieceRect, getPieceSrc, getRadioHtml, getSelectHtml, getSpectatorAnchorHtml, getSpectatorUrl, getTeamAtDistance, getTeamFontColor, getTeamLogFontBgColor, getTeamLogFontColor, getTeamTitleAlignment, getTeamTitleHtml, getTeamsForTitles, getTextHtml, getTextareaHtml, getTurnHtml, getTurnTeam, getVButtonHtml, handleMoveCollision, hiliteImageHtml, initializeNewGameForm, isBoardPointHidden, isColorAtPoint, isColorAtXY, isPathClear, isPointBoardClear, isPointOnBoard, isValueColorAtPoint, isValueColorAtXY, isXYBoardClear, isXYOnBoard, maybePie, maybeResign, movePiece, nextTeam, numInPath, numTeamsPlaying, offerDrawCheckBoxHtml, offerDrawHtml, openLogAnchorHtml, openPlayerChatAnchorHtml, openPreferencesAnchorHtml, openRulesAnchorHtml, pie, pieButtonHtml, pieHtml, processSecureMove, refreshGame, refreshGameButtonHtml, reportProblemAnchorHtml, resignButtonHtml, resignHtml, resignedHeaderHtml, screenRectFromBoardPoint, screenRectFromBoardXY, sendMoveButtonHtml, sendMoveHtml, sendReminderButtonHtml, setConstrainer, setEnded, setInnerHtml, setMouseHtml, setPerspective, setPlayerPrefs, setValueAtPoint, setValueAtXY, showTransactionPrompt, startAnotherGameButtonHtml, startAnotherGameHtml, synchTeam, teamColorFromTeam, theyResignedHtml, tieGameHeaderHtml, titleFromTeamColor, transformHashLinksToOnClicks, turnHeaderHtml, undoButtonHtml, undoMoveHtml, update, updateTeamTitles, valueFromBoardValue, valueFromPointBoard, valueFromXYBoard, valueIndexFromBoardPoint, valueIndexFromBoardXY, wonHeaderHtml, youLoseHtml, youResignedHtml, youTiedHtml, youWinHtml

Methods inherited from Foundation.Class
getTypePath, isInstanceOf

Methods inherited from Foundation.Elemental
attachEvent, detachEvent, elementId, event, getById, getElement, getElementValue, getElements, getFirst, getNext, parseElementId, processHtml, processHtml

Methods inherited from Foundation.Resourceful
resource, resource, resourceUrl, resourceUrl

Methods inherited from Foundation.Server
server, serverSerialized, serverSynchronous

Constructor Detail

EmpiresGame

GamesByEmail.EmpiresGame()

// This is the base class being extended

Field Detail

bResourcesInitialized

static bResourcesInitialized

//see initializeResources:function()


isIE

static isIE

// This will hold our static methods and properties. //as a member, instead of a function


resourcePack

static resourcePack

// the resourcePack is a collection of information // used throughout the class.

Overrides:
resourcePack in class Game

Method Detail

allPlayersHavePickedEmpires

allPlayersHavePickedEmpires()

appendBoardSpaceHtml

appendBoardSpaceHtml()

/////////////////////////////////////////////////////////////////////// //I'm overriding this to remove everything but the boardSpace // eg: topTeamTitles & bottomTeamTitles

Overrides:
appendBoardSpaceHtml in class Game

appendControlsHtml

appendControlsHtml()

///////////////////////////////////////////////////////////////////////

Overrides:
appendControlsHtml in class Game

appendHtml

appendHtml()

/////////////// mouse Handler stubs for EmpiresTester /////////////////// ///////////////////////////////////////////////////////////////////////// //Override the parent html bulder.

Overrides:
appendHtml in class Game

appendInnerHtml

appendInnerHtml()

/////////////////////////////////////////////////////////////////////// //I'm overriding this such that the board appears above //the control space.

Overrides:
appendInnerHtml in class Game

applyParams

applyParams()

//replaces occurrences of % delimited tokens in sHtml with //a value from sParams. sParams can be blank //sText= "%greeting% there %name%" and sParams="%greeting%:Hi|%name%:Bob" //gives "hi there Bob"


assignDefaultMembersToTeams

assignDefaultMembersToTeams()

assignGameOverMouseHandlers

assignGameOverMouseHandlers()

assignMouseHandlers

assignMouseHandlers()

//Todo: Clean this up a bit... at the moment, the code branching //for game-state is being done in onMouseDown. Instead, assign //a few different mouse down handlers here for differing game //game state. //Assign MouseHandlersForEmpireExpansion


assignSpectatorMouseHandlers

assignSpectatorMouseHandlers()

blinkMap

blinkMap(blinkCount)
Parameters:
blinkCount - 


blinkMapEvent

blinkMapEvent()

calculateScore

calculateScore()

//Called from the monument Dialog


cardWizMouseDown

cardWizMouseDown(screenPoint)
Parameters:
screenPoint - 


cardWizMouseMove

cardWizMouseMove(screenPoint)
Parameters:
screenPoint - 


cardWizMouseOut

cardWizMouseOut(screenPoint)
Parameters:
screenPoint - 


centerContentWrapperHtml

centerContentWrapperHtml()

//Happens all the time I want content centered and css is a pain cuz //requires browser specific blah blah to valign. So use a table instead. //sPadding: Optional: something to set the cell padding attribute to. //returns start of centerContent Wrapper. call endCenterContentWrapperHtml() //to finish.


checkAndPlayAnyMinorEmpires

checkAndPlayAnyMinorEmpires()

checkAndPlayAnyPseudoEmpires

checkAndPlayAnyPseudoEmpires()

/////////////// End Pre-Empire Phase/////////////////////////


clearBoardOfMessages

clearBoardOfMessages()

clearMouseHandlers

clearMouseHandlers()

convertArrayOfArraysToRectangles

convertArrayOfArraysToRectangles(a)
Parameters:
a - 


convertArrayOfStringsToNumbers

convertArrayOfStringsToNumbers(inArray)
Parameters:
inArray - 


convertArrayToRectangle

convertArrayToRectangle()

//r: array of integers defining rectange. x,y,width,height


createStylesheet

createStylesheet(sCssRules)
Parameters:
sCssRules - 


dealCards

dealCards()

deleteAllHelperObjects

deleteAllHelperObjects()

//Call to reset game state: eg: when setting state for next turn, or //during initialize.


determineNextPlayer

determineNextPlayer()

determineWinnerAndEndGame

determineWinnerAndEndGame()

discardCard

discardCard(iCardIndex)
Parameters:
iCardIndex - 


discardCardInPlay

discardCardInPlay()

//sometimes it's easier to discard once the card has been played //instead of at the end of the turn.


discardCardsInPlay

discardCardsInPlay()

//Removes played cards from the player's hand


displayStartGameForm

displayStartGameForm()

//Overridden. Scott finally found the problem with this one. I don't //have a gameForm element. Instead, assign the html to a parchment. //I am so impressed with how this all works!

Overrides:
displayStartGameForm in class Game

dispose

dispose()
Overrides:
dispose in class Game

doSpectatorOrNotYourTurn

doSpectatorOrNotYourTurn()

//false for spectator mode. true for notYourTurn mode.


enableUndoButton

enableUndoButton(bEnabled)
Parameters:
bEnabled - 


endCenterContentWrapperHtml

endCenterContentWrapperHtml()

endEmpireExpansion

endEmpireExpansion()

endPickCardPhase

endPickCardPhase()

endPlayEmpireModCards

endPlayEmpireModCards()

endPlayPreEmpireCards

endPlayPreEmpireCards()

endTurn

endTurn()

getActionLinksHtml

getActionLinksHtml()

/* //Consider moving this into territories.appendOverlayHtml() !!!! appendThrobContainer:function() if(this.getElement( 'throbContainer' ) ) return; if(this.testing && !this.bRelease) this.debug(" **appending Throb container**"); var container = document.createElement('div'); container.id=this.elementId("throbContainer"); var imageSize=this.board.image.size; //<div id=\"throbContainer\" style=\"position:absolute;top:0;left:0;width:947;height:622;visibility:hidden\"> container.setAttribute("style", "position:absolute;top:0;left:0;width:"+imageSize.x+"px; height:"+imageSize.y+"px;overflow:hidden;z-index:100"); var html=new Foundation.StringBuilder(); var src=this.getImageSrc("images/blank.png"); var t=this.territories, len=this.territories.length; for(var i=0;i<len;i++) undefined html.append("<img id=\""+this.elementId("territoryThrob_"+i)+"\" border=0 src=\""+src+"\" style=\"position:absolute; left:0; top:0; display:block; visibility:hidden;\" galleryimg=false>"); container.innerHTML=html.toString(); var b=this.getElement('boardContainer'); b.appendChild(container); if(this.testing && !this.bRelease) this.debug(" **DONE appending Throb container**");

Overrides:
getActionLinksHtml in class Game

getBoardImageSrc

getBoardImageSrc(sName)
Parameters:
sName - 


getButtonHtml

getButtonHtml()

//Override Parent class to detect if it's not current player's //turn. If so, then disable whatever button is being output. //Hack: But this disables the "refresh game" and "send reminder" buttons // too? No problem. Use a temporary variable called: // bTempEnableButtonsWhenNotYourTurn. When true, allow the buttons to be // emitted without the "disabled" attribute. // Remarks: This was a last second fix. Hacky, but it'll do.

Overrides:
getButtonHtml in class Game

getButtonHtmlNoDisable

getButtonHtmlNoDisable()

//Provide a means where any class can get a button which is never disabled. //Use this for buttons which players can click even if it's not their turn. //remarks: Bad hack, I should do this the other way on, but this is fast.


getCardsInPlay

getCardsInPlay()

getCompositeBgImageDivs

getCompositeBgImageDivs()

//returns string containing html with 2 divs. Outer div has outer gif // image with transparency & jagged edges. Inner div has jpg. //Inputs: iLeft,iTop: Optional params to specify absolute position of dialog. //Preconditions: CompositeBG resource has all members used herein // Tests show single gif = 154KB. Composite Gif+jpg=40kb.


getDefaultFloatStyle

getDefaultFloatStyle()

getDiceHtml

getDiceHtml()

//getDiceHtml( num, ColorZeroForWhiteOneForRed ) //iNum= 1-6. iColor 0 for white, 1 for Red


getEmpireNameForScoreBoard

getEmpireNameForScoreBoard(oTeam)
Parameters:
oTeam - 


getFirstEmpireForThisEpoch

getFirstEmpireForThisEpoch()

getFloatHtml

getFloatHtml()

getGameFormSetting

getGameFormSetting(sSettingName,
                   bDefaultVal)
Parameters:
sSettingName - 

bDefaultVal - 


getGameOverMessage

getGameOverMessage(bWithBreaks)
Parameters:
bWithBreaks - 


getGameOverlayStubHtml

getGameOverlayStubHtml(htmlBuilder)
Parameters:
htmlBuilder - 


getGamePromptsHtml

String getGamePromptsHtml()

Called when needing the game prompts HTML. Override to set. Internally clears the mouse events, then returns either spectatingHtml, gameOverHtml, notYourTurnHtml or getTurnHtml.

Overrides:
getGamePromptsHtml in class Game
Returns:
HTML for the game prompts.

getMysteryNameOrPrivateEmpireLink

getMysteryNameOrPrivateEmpireLink(oTeam)
Parameters:
oTeam - 


getName

getName()

//Ensures player's names aren't overly long. Long names cause //the display to distort in places.


getNotYourTurnMouseHtml

getNotYourTurnMouseHtml()

/* getSpectatingPromptHtml:function( html ) //What about GamePhase? //Determine which player is going to go next. var player = this.teams.getTurnTeam().players[0]; var sParams="%playerName%:"+player.title.htmlEncode(); //sParams+="%empireName%:"+ this.empireData[ this.player.team.majorEmpireIndex ].name var sPrompt = this.mousePrompts[ this.iCurrentMousePrompt ]; sPrompt=this.applyParams(sPrompt, sParams); html.append( '<br>'+sPrompt ); ,


getPlayerPromptHtml

getPlayerPromptHtml(htmlBuilder,
                    t)
Parameters:
htmlBuilder - 

t - 
/*territory

getPositionInTurnOrder

getPositionInTurnOrder()

//Returns a teams position within the current turnOrder array


getRemainingArmiesHtml

getRemainingArmiesHtml()

//empire object is optional. empire could be either instance of empire //class, or static data EmpiresData entry.


getResourceImageSrc

getResourceImageSrc(sName)
Parameters:
sName - 


getScoreHtml

getScoreHtml()

//returns html text containing team titles + scores. //called from both getTeamTitlesHtml to build the initial page, //and from updateTeamTitles to update to "teamTitles" div.


getShowTempHideMessage

getShowTempHideMessage()

// Preconditions: Meant to be placed inside a relatively // positioned div


getStartTurnLogMsg

getStartTurnLogMsg()

getStateString

getStateString()

getString

getString()

//Convert class state to string and return it //Current Format: //~GameState~CardWizardState~CurrentEmpire~BattleDialogState~TeamsState~Territories


getTeamString

getTeamString(team)
Parameters:
team - 


getTeamTitlesHtml

String getTeamTitlesHtml(/*Boolean*/ top)

Gets the HTML for the team titles on the board.

Overrides:
getTeamTitlesHtml in class Game
Parameters:
top - 
Whether this teams' titles will be displayed above the board or below.
Returns:
The titles for all teams across the top or bottom.

getTeamsString

getTeamsString()

getWaitingForNextPlayerMsgHtml

getWaitingForNextPlayerMsgHtml()

getWinner

getWinner()

getYellowButtonHtml

getYellowButtonHtml(title,
                    id,
                    eventCode)
Parameters:
title - 

id - 

eventCode - 


goIntoExpansionMode

goIntoExpansionMode()

hasTeamPlayedThisEpochYet

hasTeamPlayedThisEpochYet(oTeam)
Parameters:
oTeam - 


hideBuildFortDialog

hideBuildFortDialog()

//iBuildOrCancel: -1 = cancel. 0 = spend army to build 1 = spend coin.


hideDialog

hideDialog()

hideEmpireDialog

hideEmpireDialog()

//Invoked when user clicks ok.


hideEndEmpireDialog

hideEndEmpireDialog()

// Preconditions: // Could be hiding barbarians, Crusaders, a minor Empire, or // the major empire


hideMouseDialog

hideMouseDialog()

importLog

importLog()

//overridden so logIndex can get set.

Overrides:
importLog in class Game

initialize

initialize()

// Methods and Properties.

Overrides:
initialize in class Game

initializeGameInBrowser

initializeGameInBrowser()

//preconditions: Called once game board has been loaded.


initializeResources

initializeResources()

//Attempt to reduce number of "new Foundation.Rectangle" declarations in resourcePack, //instead, only store arrays of x,y,width,height in the resource pack, and convert //them before attempting to load the board. Still not sure best place to invoke this from though


isCardInPlay

isCardInPlay(iCardId)
Parameters:
iCardId - 


isMyTurn

isMyTurn()

//Override this to provide a stub within the Framework object. //In the EmpiresTester, this function will get re-defined to //return false to allow for testing.

Overrides:
isMyTurn in class Game

isPresent

isPresent()

//Test if input param exists


isStringPresent

isStringPresent()

//Test if input param exists and is a string.


itsYourTurnHtml

String itsYourTurnHtml(/*String*/ resourceName)

Called when needing the it-is-your-turn game prompt HTML (typically a short sentence about the move). Override and set mouse events here. Internally uses the "itIsYourTurnToMove" resource.

Overrides:
itsYourTurnHtml in class Game
Parameters:
resourceName - 
(Optional) A resource name to override the default resource to use.
Returns:
HTML for the game prompts.

logMouseDown

logMouseDown(screenPoint)
Parameters:
screenPoint - 


logMouseMove

logMouseMove(screenPoint)
Parameters:
screenPoint - 


logMouseOut

logMouseOut(screenPoint)
Parameters:
screenPoint - 


maybeEndTempHide

maybeEndTempHide()

//This event is called whenever a key is released


maybeStartTempHide

maybeStartTempHide()

//re-using Scott's name. It's semantically ideal. Some slight differences //in implementation (of course I borrowed and hacked his code. :P ) //This event is called whenever a key is pressed


monumentMouseDown

monumentMouseDown(screenPoint)
Parameters:
screenPoint - 


monumentMouseMove

monumentMouseMove(screenPoint)
Parameters:
screenPoint - 


monumentMouseOut

monumentMouseOut(screenPoint)
Parameters:
screenPoint - 


mouseDown

mouseDown(screenPoint)
Parameters:
screenPoint - 


mouseDownGameOver

mouseDownGameOver(screenPoint)
Parameters:
screenPoint - 


mouseDownPickTerritoryToAttackFrom

mouseDownPickTerritoryToAttackFrom(screenPoint)
Parameters:
screenPoint - 


mouseDownSpectator

mouseDownSpectator(screenPoint)
Parameters:
screenPoint - 


mouseMove

mouseMove()

///////////////////////////////////////////// ///////////////////////////////////////////// /////////////////////////////////////////////


mouseMoveHidePrevious

mouseMoveHidePrevious(territory)
Parameters:
territory - 


mouseMovePickTerritoryToAttackFrom

mouseMovePickTerritoryToAttackFrom(screenPoint)
Parameters:
screenPoint - 


mouseMoveSpectator

mouseMoveSpectator(screenPoint)
Parameters:
screenPoint - 


mouseOut

mouseOut(screenPoint)
Parameters:
screenPoint - 


mousedownBarbarians

mousedownBarbarians(empire,
                    territory)
Parameters:
empire - 

territory - 


notYourTurnHtml

String notYourTurnHtml(/*String*/ resourceName)

Called when needing the it-is-not-your-turn game prompt HTML (typically a short sentence with Send Reminder, Refresh Game and Close Window buttons Start Another Game button). Override to set. Internally uses the "notYourTurn" resource.

Overrides:
notYourTurnHtml in class Game
Parameters:
resourceName - 
(Optional) A resource name to override the default resource to use.
Returns:
HTML for the game prompts.

onBattleDialogClosed

onBattleDialogClosed()

//called by battleDialog.


openLog

openLog()

//Overridden API method. Sets window height and gives it scroll bars.

Overrides:
openLog in class Game

placeEmpireOnBoard

placeEmpireOnBoard(empire)
Parameters:
empire - 


playEmpire

playEmpire(empireId)
Parameters:
empireId - 


playEmpireModCards

playEmpireModCards()

playMajorEmpire

playMajorEmpire()

//playEmpire Wrapper to account for Incas/Aztecs custom logic.


playPreEmpireCards

playPreEmpireCards()

/////////////// Pre-Empire Phase////////////////////////////


playSomeCards

playSomeCards()

processLogMove

processLogMove()

//Overridden method - called by API while creating a list of log moves

Overrides:
processLogMove in class Game

refreshContinentPresence

refreshContinentPresence()

refreshScreen

refreshScreen()

resign

resign()

//override the parent class to ensure game state is // set for next player.

Overrides:
resign in class Game

restoreDefaultFloatStyle

restoreDefaultFloatStyle()

restoreMouseHandlers

restoreMouseHandlers()

//Used with saveAndClearMouseHandlers()


restoreMouseMoveOnly

restoreMouseMoveOnly()

resumeCivilWar

resumeCivilWar()

resumeEmpireExpansion

resumeEmpireExpansion()

//Preconditions: Called from both game and EmpiresLog. //Called from game to intercept empireExpansion after sync when some special //scenario has happened. //Called from Log to re-use the dialogs of those scenarios.


saveAndClearMouseHandlers

saveAndClearMouseHandlers()

//Used to compensate for floatHtml allowing mouse clicks to board below // in IE. Instead, pull the handlers altogether, show dialog, restore // handlers later.


scramblePlayersWhoHaventGoneYet

scramblePlayersWhoHaventGoneYet(aTeams)
Parameters:
aTeams - 


sendMove

Boolean sendMove(/*Boolean*/ sendNow,
                 /*Player*/ player)

Gets called when the Send Move button is pushed. Override and set the game state, then call Super.sendMove.

Overrides:
sendMove in class Game
Parameters:
sendNow - 
(Optional) Send the moves to the server now. Else, save the move for sending later. Defaults to true.
player - 
(Optional) The player responsible for the move. Defaults to the current player (game.player).
Returns:
true.

setFloatHtml

void setFloatHtml(/*String*/ html,
                  /*Number*/ width,
                  /*Number*/ height)

Shows HTML in a simple box centered over the board. Board mouse messages are suspended while box is shown.

Overrides:
setFloatHtml in class Game
Parameters:
html - 
The html to show in the box. Pass no parameters, null or empty string to hide the box.
width - 
The width the box. If width>1, is the width of the box in pixels. If 0
height - 
The height the box. If height>1, is the height of the box in pixels. If 0

setFloatHtmlWithBgImage

setFloatHtmlWithBgImage()

// Preconditions: set iLastDlgRegion to show dlg centered around one of the // pre-set dlgRegions. -1 to leave it centered. // BG Objects. have src, style & srcGif


setFloatHtmlWithCompositeBgImage

setFloatHtmlWithCompositeBgImage(sCompBgImageResourceName,
                                 sHtmlMsg)
Parameters:
sCompBgImageResourceName - 

sHtmlMsg - 


setFloatHtmlWithTransparentBG

setFloatHtmlWithTransparentBG()

//Discovered I can't set a float html with a transparent bg. //Use this method instead. //Original float style will be restored on the next call to //setFloatHtml. //Also, calling this method with no html will restore the //default style.


setGameStateForNextTurn

setGameStateForNextTurn()

setHasUsedAllArmies

setHasUsedAllArmies()

setNextPlayerForPickEmpirePhase

setNextPlayerForPickEmpirePhase()

// Preconditions: turnOrder array has already been set.


setNextPlayerForPlayEmpirePhase

setNextPlayerForPlayEmpirePhase()

//inputs: iNextEmpireIndex or 0 for the start of the game. // The index of the empire to start looking for. // During Empire Expansion, players play in the order of their empires. // This method takes an input Empire Index and checks if any of the // players are currently assigned to play it. // If no players are assigned, the EmpireIndex is incremented and another // search is made. // Once the team holding the "next empire" is found, the turn is set to // that player. // If no player is found, it is assumed to be the end of the Epoch.


setOptionalData

setOptionalData(sNameValuePair)
Parameters:
sNameValuePair - 


setStateString

setStateString(string)
Parameters:
string - 


setString

setString()

//Assigns string containing encoded "game state" to members like teams & territories.


setTeamByBase64String

setTeamByBase64String(team,
                      sB64Data)
Parameters:
team - 

sB64Data - 


setTeamByString

setTeamByString(team,
                string)
Parameters:
team - 

string - 


setTeamByStringV2

setTeamByStringV2()

// ** Backward Compatibility Method


setTeamToBitData

setTeamToBitData()

/* EMPIRES TEAM Encoding Scheme this.majorEmpireIndex ( -1 to 69 ) (7Bits) this.points ( 0 to 300+ ) (10 bits) max score of 1024. this.teamWhoDealtUsThisEmpire ( 0-5 ) (3 bits) this.cardsInHand[] ( array each can be ( 0 to 41 ) n * 6 bits )


setTeamsByString

setTeamsByString(teams,
                 string)
Parameters:
teams - 

string - 


setTurnOrder

setTurnOrder()

setupPlayersForNextEpoch

setupPlayersForNextEpoch()

setupPlayersForPlayEmpirePhase

setupPlayersForPlayEmpirePhase()

shallowCopy

shallowCopy(inArray)
Parameters:
inArray - 


showBigParchment

showBigParchment(sHtmlMsg)
Parameters:
sHtmlMsg - 


showBigParchmentDialog

showBigParchmentDialog()

// "Opt=optional"


showBuildFortDialog

showBuildFortDialog()

showChatWindow

showChatWindow(html)
Parameters:
html - 


showCompassPrompt

showCompassPrompt(sHtml)
Parameters:
sHtml - 


showCompassPromptParchment

showCompassPromptParchment(sHtml,
                           sOnClick)
Parameters:
sHtml - 

sOnClick - 


showCompassPromptWithTransparentBG

showCompassPromptWithTransparentBG(sBgImageResourceName,
                                   sHtml)
Parameters:
sBgImageResourceName - 

sHtml - 


showEmpireDialog

showEmpireDialog()

//maybe move this to the empire class.


showEmpireDialogForBarbarians

showEmpireDialogForBarbarians()

showEmpireDialogForCrusaders

showEmpireDialogForCrusaders()

showEndBarbarianDialog

showEndBarbarianDialog()

showEndCrusaderDialog

showEndCrusaderDialog()

showEndEmpireDialog

showEndEmpireDialog(sParams)
Parameters:
sParams - 


showExpandEmpireCompassPrompt

showExpandEmpireCompassPrompt()

showGameOverCompassPrompt

showGameOverCompassPrompt()

showItsYourTurnCompassPrompt

showItsYourTurnCompassPrompt()

showItsYourTurnDialog

showItsYourTurnDialog()

// PLAY_EMPIRE Logic Flow // Show ItsYourTurnDialog for Active Empire //Show Play A Card Dialog //Play Pre-Empire Cards //If card played is Minor Empire //Show Empire Dialog for Minor Empire //Play minor empire //Play Cards which apply to major empire //Show Empire Dialog for major Empire //Play major Empire //Place Monuments & Score


showLastEmpireInTitleAndMakeItThrob

showLastEmpireInTitleAndMakeItThrob()

showMonumentDialog

showMonumentDialog()

showNotesWindow

showNotesWindow(html)
Parameters:
html - 


showScoreSummaryInMessageWindow

showScoreSummaryInMessageWindow()

showSendMoveDialog

showSendMoveDialog()

showSmallParchment

showSmallParchment(sHtmlMsg)
Parameters:
sHtmlMsg - 


showSmallParchmentDialog

showSmallParchmentDialog(sHtml,
                         sOptEvent,
                         sOptOkBtnName,
                         sOptPadding)
Parameters:
sHtml - 

sOptEvent - 

sOptOkBtnName - 

sOptPadding - 


showSpectatorOrNotYourTurnCompassPrompt

showSpectatorOrNotYourTurnCompassPrompt()

//false for spectator mode. true for notYourTurn mode.


shuffle

shuffle()

//shuffles items in input array and //returns result. //input array can contain anything


spectatingHtml

String spectatingHtml()

Called when needing the you-are-spectating game prompts HTML. Override to set. Internally returns the following combined: refreshGameButtonHtml and closeWindowButtonHtml.

Overrides:
spectatingHtml in class Game
Returns:
HTML for the game prompts.

startEmpireExpansion

startEmpireExpansion(empire)
Parameters:
empire - 


startTurnForThisPlayer

startTurnForThisPlayer()

substitute

substitute()

// eg: .substitute("Hi %n %greeting%", '%n', 'Jim', %greeting%, "what's new"); // gives: Hi Jim, what's new //inputs: token1,value1, token2, value2


synch

synch()

//synchronize the game to it's current state.

Overrides:
synch in class Game

tellUserNoArmiesLeft

tellUserNoArmiesLeft()

testerMouseDown

testerMouseDown(screenPoint)
Parameters:
screenPoint - 


testerMouseMove

testerMouseMove()

///////////////////////////////////////////////////////////////////////// /////////////// mouse Handler delegators for EmpiresTester //////////////


testerMouseOut

testerMouseOut(screenPoint)
Parameters:
screenPoint - 


undo

undo()

//Overridden to try testing if this.info["board"] is getting //corrupted somewhere (it is)

Overrides:
undo in class Game

updateEmpireDataRow

updateEmpireDataRow()

//empire: could be integer or empire object


updateMouseHtml

updateMouseHtml()

//Called to update the markup displayed in the mouse prompt. //Called whenever mouse is supposed to be on and territory changes. //Also called during "itsYourTurnHtml()" //territory: Optional. If not passed in, current x,y under mouse is used //to get territory. If still no territory no territory data will be //added to the mousePrompt.


updateOneTeamScore

updateOneTeamScore()

/* // REVISIT: add some logic to scramble remaining players who haven't // played their empires during empire expansion. tempTeams = this.scramblePlayersWhoHaventGoneYet(tempTeams);


updateScore

updateScore()

viewCards

viewCards()

viewEmpires

viewEmpires()