Games\Empires\Game.jsGamesByEmailObject
GamesByEmail.Game
All Implemented Interfaces:
GamesByEmail.EmpiresGame
extendsGame
| Constructor Summary |
// 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 | |
|
|
|
///////////////////////////////////////////////////////////////////////
//I'm overriding this to remove everything but the boardSpace
// eg: topTeamTitles & bottomTeamTitles
|
|
///////////////////////////////////////////////////////////////////////
|
|
/////////////// mouse Handler stubs for EmpiresTester ///////////////////
/////////////////////////////////////////////////////////////////////////
//Override the parent html bulder.
|
|
///////////////////////////////////////////////////////////////////////
//I'm overriding this such that the board appears above
//the control space.
|
|
//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"
|
|
|
|
|
|
//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
|
|
|
|
|
|
|
|
//Called from the monument Dialog
|
|
|
|
|
|
|
|
//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.
|
|
|
|
/////////////// End Pre-Empire Phase/////////////////////////
|
|
|
|
|
|
|
|
|
|
//r: array of integers defining rectange. x,y,width,height
|
|
|
|
|
|
//Call to reset game state: eg: when setting state for next turn, or
//during initialize.
|
|
|
|
|
|
|
|
//sometimes it's easier to discard once the card has been played
//instead of at the end of the turn.
|
|
//Removes played cards from the player's hand
|
|
//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!
|
|
|
|
//false for spectator mode. true for notYourTurn mode.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
//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**");
|
|
|
|
//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.
|
|
//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.
|
|
|
|
//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.
|
|
|
|
//getDiceHtml( num, ColorZeroForWhiteOneForRed )
//iNum= 1-6. iColor 0 for white, 1 for Red
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Called when needing the game prompts HTML. Override to set. Internally clears the mouse events, then returns either
spectatingHtml, gameOverHtml, notYourTurnHtml or getTurnHtml. |
|
|
|
//Ensures player's names aren't overly long. Long names cause
//the display to distort in places.
|
|
/*
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 );
, |
|
|
|
//Returns a teams position within the current turnOrder array
|
|
//empire object is optional. empire could be either instance of empire
//class, or static data EmpiresData entry.
|
|
|
|
//returns html text containing team titles + scores.
//called from both getTeamTitlesHtml to build the initial page,
//and from updateTeamTitles to update to "teamTitles" div.
|
|
// Preconditions: Meant to be placed inside a relatively
// positioned div
|
|
|
|
|
|
//Convert class state to string and return it
//Current Format:
//~GameState~CardWizardState~CurrentEmpire~BattleDialogState~TeamsState~Territories
|
|
|
|
Gets the HTML for the team titles on the board.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//iBuildOrCancel: -1 = cancel. 0 = spend army to build 1 = spend coin.
|
|
|
|
//Invoked when user clicks ok.
|
|
// Preconditions:
// Could be hiding barbarians, Crusaders, a minor Empire, or
// the major empire
|
|
|
|
//overridden so logIndex can get set.
|
|
// Methods and Properties.
|
|
//preconditions: Called once game board has been loaded.
|
|
//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
|
|
|
|
//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.
|
|
//Test if input param exists
|
|
//Test if input param exists and is a string.
|
|
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.
|
|
|
|
|
|
|
|
//This event is called whenever a key is released
|
|
//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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
//called by battleDialog.
|
|
//Overridden API method. Sets window height and gives it scroll bars.
|
|
|
|
|
|
|
|
//playEmpire Wrapper to account for Incas/Aztecs custom logic.
|
|
/////////////// Pre-Empire Phase////////////////////////////
|
|
|
|
//Overridden method - called by API while creating a list of log moves
|
|
|
|
|
|
//override the parent class to ensure game state is
// set for next player.
|
|
|
|
//Used with saveAndClearMouseHandlers()
|
|
|
|
|
|
//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.
|
|
//Used to compensate for floatHtml allowing mouse clicks to board below
// in IE. Instead, pull the handlers altogether, show dialog, restore
// handlers later.
|
|
|
|
Gets called when the Send Move button is pushed. Override and set the game state, then call Super.sendMove.
|
|
Shows HTML in a simple box centered over the board. Board mouse messages are suspended while box is shown.
|
|
// 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
|
|
|
|
//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.
|
|
|
|
|
|
// Preconditions: turnOrder array has already been set.
|
|
//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.
|
|
|
|
|
|
//Assigns string containing encoded "game state" to members like teams & territories.
|
|
|
|
|
|
// ** Backward Compatibility Method
|
|
/*
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 )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// "Opt=optional"
|
|
|
|
|
|
|
|
|
|
|
|
//maybe move this to the empire class.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//false for spectator mode. true for notYourTurn mode.
|
|
//shuffles items in input array and
//returns result.
//input array can contain anything
|
|
Called when needing the you-are-spectating game prompts HTML. Override to set. Internally returns the following combined:
refreshGameButtonHtml and closeWindowButtonHtml. |
|
|
|
|
|
// eg: .substitute("Hi %n %greeting%", '%n', 'Jim', %greeting%, "what's new");
// gives: Hi Jim, what's new
//inputs: token1,value1, token2, value2
|
|
//synchronize the game to it's current state.
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
/////////////// mouse Handler delegators for EmpiresTester //////////////
|
|
|
|
//Overridden to try testing if this.info["board"] is getting
//corrupted somewhere (it is)
|
|
//empire: could be integer or empire object
|
|
//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.
|
|
/*
// REVISIT: add some logic to scramble remaining players who haven't
// played their empires during empire expansion.
tempTeams = this.scramblePlayersWhoHaventGoneYet(tempTeams);
|
|
|
|
|
|
|
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 |
GamesByEmail.EmpiresGame()
// This is the base class being extended
| Field Detail |
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.
Overrides:resourcePack in class Game| Method Detail |
allPlayersHavePickedEmpires()
appendBoardSpaceHtml()
/////////////////////////////////////////////////////////////////////// //I'm overriding this to remove everything but the boardSpace // eg: topTeamTitles & bottomTeamTitles
Overrides:appendBoardSpaceHtml in class Game
appendControlsHtml()
///////////////////////////////////////////////////////////////////////
Overrides:appendControlsHtml in class Game
appendHtml()
/////////////// mouse Handler stubs for EmpiresTester /////////////////// ///////////////////////////////////////////////////////////////////////// //Override the parent html bulder.
Overrides:appendHtml in class Game
appendInnerHtml()
/////////////////////////////////////////////////////////////////////// //I'm overriding this such that the board appears above //the control space.
Overrides:appendInnerHtml in class Game
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)
blinkCount -
blinkMapEvent()
calculateScore()
//Called from the monument Dialog
cardWizMouseDown(screenPoint)
screenPoint -
cardWizMouseMove(screenPoint)
screenPoint -
cardWizMouseOut(screenPoint)
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)
a -
convertArrayOfStringsToNumbers(inArray)
inArray -
convertArrayToRectangle()
//r: array of integers defining rectange. x,y,width,height
createStylesheet(sCssRules)
sCssRules -
dealCards()
deleteAllHelperObjects()
//Call to reset game state: eg: when setting state for next turn, or //during initialize.
determineNextPlayer()
determineWinnerAndEndGame()
discardCard(iCardIndex)
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!
Overrides:displayStartGameForm in class Game
dispose()
doSpectatorOrNotYourTurn()
//false for spectator mode. true for notYourTurn mode.
enableUndoButton(bEnabled)
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**");
getActionLinksHtml in class Game
getBoardImageSrc(sName)
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.
Overrides:getButtonHtml in class Game
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)
oTeam -
getFirstEmpireForThisEpoch()
getFloatHtml()
getGameFormSetting(sSettingName,
bDefaultVal)
sSettingName -
bDefaultVal -
getGameOverMessage(bWithBreaks)
bWithBreaks -
getGameOverlayStubHtml(htmlBuilder)
htmlBuilder -
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.
getGamePromptsHtml in class Game
getMysteryNameOrPrivateEmpireLink(oTeam)
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)
htmlBuilder -
t -/*territory
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)
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)
team -
String getTeamTitlesHtml(/*Boolean*/ top)
Gets the HTML for the team titles on the board.
Overrides:getTeamTitlesHtml in class Gametop -Whether this teams' titles will be displayed above the board or below.
getTeamsString()
getWaitingForNextPlayerMsgHtml()
getWinner()
getYellowButtonHtml(title,
id,
eventCode)
title -
id -
eventCode -
goIntoExpansionMode()
hasTeamPlayedThisEpochYet(oTeam)
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.
Overrides:importLog in class Game
initialize()
// Methods and Properties.
Overrides:initialize in class Game
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)
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.
Overrides:
isPresent()
//Test if input param exists
isStringPresent()
//Test if input param exists and is a string.
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 GameresourceName -(Optional) A resource name to override the default resource to use.
logMouseDown(screenPoint)
screenPoint -
logMouseMove(screenPoint)
screenPoint -
logMouseOut(screenPoint)
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)
screenPoint -
monumentMouseMove(screenPoint)
screenPoint -
monumentMouseOut(screenPoint)
screenPoint -
mouseDown(screenPoint)
screenPoint -
mouseDownGameOver(screenPoint)
screenPoint -
mouseDownPickTerritoryToAttackFrom(screenPoint)
screenPoint -
mouseDownSpectator(screenPoint)
screenPoint -
mouseMove()
///////////////////////////////////////////// ///////////////////////////////////////////// /////////////////////////////////////////////
mouseMoveHidePrevious(territory)
territory -
mouseMovePickTerritoryToAttackFrom(screenPoint)
screenPoint -
mouseMoveSpectator(screenPoint)
screenPoint -
mouseOut(screenPoint)
screenPoint -
mousedownBarbarians(empire,
territory)
empire -
territory -
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 GameresourceName -(Optional) A resource name to override the default resource to use.
onBattleDialogClosed()
//called by battleDialog.
openLog()
//Overridden API method. Sets window height and gives it scroll bars.
Overrides:openLog in class Game
placeEmpireOnBoard(empire)
empire -
playEmpire(empireId)
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
Overrides:processLogMove in class Game
refreshContinentPresence()
refreshScreen()
resign()
//override the parent class to ensure game state is // set for next player.
Overrides:
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)
aTeams -
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: 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).
true.
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 Gamehtml -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()
// 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)
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)
sNameValuePair -
setStateString(string)
string -
setString()
//Assigns string containing encoded "game state" to members like teams & territories.
setTeamByBase64String(team,
sB64Data)
team -
sB64Data -
setTeamByString(team,
string)
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)
teams -
string -
setTurnOrder()
setupPlayersForNextEpoch()
setupPlayersForPlayEmpirePhase()
shallowCopy(inArray)
inArray -
showBigParchment(sHtmlMsg)
sHtmlMsg -
showBigParchmentDialog()
// "Opt=optional"
showBuildFortDialog()
showChatWindow(html)
html -
showCompassPrompt(sHtml)
sHtml -
showCompassPromptParchment(sHtml,
sOnClick)
sHtml -
sOnClick -
showCompassPromptWithTransparentBG(sBgImageResourceName,
sHtml)
sBgImageResourceName -
sHtml -
showEmpireDialog()
//maybe move this to the empire class.
showEmpireDialogForBarbarians()
showEmpireDialogForCrusaders()
showEndBarbarianDialog()
showEndCrusaderDialog()
showEndEmpireDialog(sParams)
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)
html -
showScoreSummaryInMessageWindow()
showSendMoveDialog()
showSmallParchment(sHtmlMsg)
sHtmlMsg -
showSmallParchmentDialog(sHtml,
sOptEvent,
sOptOkBtnName,
sOptPadding)
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
String spectatingHtml()
Called when needing the you-are-spectating game prompts HTML. Override to set. Internally returns the following combined: refreshGameButtonHtml and closeWindowButtonHtml.
spectatingHtml in class Game
startEmpireExpansion(empire)
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()
tellUserNoArmiesLeft()
testerMouseDown(screenPoint)
screenPoint -
testerMouseMove()
///////////////////////////////////////////////////////////////////////// /////////////// mouse Handler delegators for EmpiresTester //////////////
testerMouseOut(screenPoint)
screenPoint -
undo()
//Overridden to try testing if this.info["board"] is getting //corrupted somewhere (it is)
Overrides:
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()