Games\Politics\Game.js
GamesByEmail
Object
GamesByEmail.Game
All Implemented Interfaces:
GamesByEmail.PoliticsGame
extendsGame
Constructor Summary |
|
Enum Summary | |
static | COLOR
|
Field Summary | |
static | resourcePack
Resources for most of the game. Override to add resources specific to game.
|
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 | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Creates HTML for a action links: Open log, open rules, open preferences, and report problem anchors.
|
|
|
|
|
static |
|
|
|
|
Called when needing the header HTML. Override to set. Internally returns either
gameInProgressHeaderHtml or gameOverHeaderHtml . |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Gets the HTML for the team title on the board. By default uses resources 'turnTeamTitle' or 'teamTitle'.
|
|
Gets the HTML for the team titles on the board.
|
static |
|
|
|
|
|
|
|
|
Called when needing the it-is-your-turn game prompts HTML. Override to set. Internally returns either
beginTurnHtml , continueTurnHtml or completeTurnHtml . |
|
|
|
Override to handle move collisions from concurrent turns.
|
|
|
|
The first method to be called when a game is created, override to set up teams, players and the game state.
|
|
Seeds the game form options with values from the current game.
|
|
|
|
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.
|
|
|
|
|
|
|
|
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 when needing the offer-a-draw-with-this-move prompts HTML (typically a short sentence and a Offer A Draw checkbox). Override to set. Internally uses the "youMayOfferDraw" and "offerDrawWithThisMove" resources.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Gets called when the sending moves, fir processing secure move data on the client. Override to process secure data.
|
|
|
|
|
|
|
|
Resignes the current player. Clears mouse events, sets the player as resigned, and sends the move.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Called when needing the you-are-spectating game prompts HTML. Override to set. Internally returns the following combined:
refreshGameButtonHtml and closeWindowButtonHtml . |
|
|
|
|
|
|
|
Called when the game should synchronize with
info properties from the server. |
|
|
|
Gets the team color.
|
|
|
|
|
|
Called when needing the it's-your-turn header HTML. Override to set. Internally uses the "turnHeader" resource.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.PoliticsGame()
Enum Detail |
static COLOR
AUSTRIA_HUNGARY -
ITALY -
FRANCE -
ENGLAND -
GERMANY -
RUSSIA -
TURKEY -
NEUTRAL -
WATER -
Field Detail |
static Object
resourcePack
Resources for most of the game. Override to add resources specific to game.
Overrides:resourcePack
in class Game
Method Detail |
addImpliedOrders(orders)
orders -
adjudicateOrders(alwaysUpdate)
alwaysUpdate -
adjudicateOrdersIfTesting(alwaysUpdate)
alwaysUpdate -
allOtherTeamsOnlyHaveDefaultOrders()
anyDisolvesOrBuilds()
applyOrders()
areAllPlayersAccountedFor()
attackOrdersMouseDown(point,
event)
point -
event -
attackOrdersMouseMove(point)
point -
attackOrdersMouseUp(point)
point -
canEveryPieceMove(list)
list -
changeOrdersAnchorHtml(territory,
lineThrough)
territory -
lineThrough -
changeOrdersByIndex(index)
index -
chatImageHtml(chatId)
chatId -
chatVibration()
checkForWinner()
checkHealth(teams)
teams -
checkIfLost(team)
team -
clearOrderPredictions()
closeAvailableOrdersBox()
closeMapEditor()
closeMapEditorAnchorHtml()
colorCountDisolves(color)
color -
colorHasDisolves(color)
color -
colorHasDisolvesOrBuilds(color)
color -
disolveBuildOrdersMouseDown(point,
event)
point -
event -
disolveBuildOrdersMouseUp(point)
point -
disolveOrBuildHtml()
dispose()
doWeWantToSupportThisAttack(attackT,
fromT,
toT,
midT)
attackT -
fromT -
toT -
midT -
editMapOnMouseDown(color,
unitType)
color -
unitType -
editMapOnMouseMove(point)
point -
editMapOnMouseUp(point)
point -
String
getActionLinksHtml()
Creates HTML for a action links: Open log, open rules, open preferences, and report problem anchors.
Overrides:getActionLinksHtml
in class Game
getAdjacentCoastForTrain(t1,
t2)
t1 -
t2 -
getAttackOrders(point)
point -
static getCoastIndexFromBoardIndex(index)
index -
getDaysPhrase(days)
days -
String
getHeaderHtml(/*String
*/ resourceName)
Called when needing the header HTML. Override to set. Internally returns either gameInProgressHeaderHtml
or gameOverHeaderHtml
.
getHeaderHtml
in class Game
resourceName -(Optional) A resource name to override the default resource to use when generating the final HTML.
getHoursPhrase(hours)
hours -
getMinutesPhrase(minutes)
minutes -
getRetreatOrders(point)
point -
getSecondsPhrase(seconds)
seconds -
getSecondsToExpire()
getShortTimeToExpireString(seconds)
seconds -
getSupplyCenterPhrase(num)
num -
String
getTeamTitleHtml(/*Team
*/ team,
/*Boolean
*/ top)
Gets the HTML for the team title on the board. By default uses resources 'turnTeamTitle' or 'teamTitle'.
Overrides:getTeamTitleHtml
in class Game
team -The team to get the color for.
top -Whether this team's title will be displayed above the board or below.
String
getTeamTitlesHtml(/*Boolean
*/ top)
Gets the HTML for the team titles on the board.
Overrides:getTeamTitlesHtml
in class Game
top -Whether this teams' titles will be displayed above the board or below.
static getTerritoryIndexFromBoardIndex(index)
index -
getTimeLimitHtml(needToTurnInOrders)
needToTurnInOrders -
getTimeToExpireHtml()
getTimeToExpireString(seconds)
seconds -
String
getTurnHtml()
Called when needing the it-is-your-turn game prompts HTML. Override to set. Internally returns either beginTurnHtml
, continueTurnHtml
or completeTurnHtml
.
getTurnHtml
in class Game
getUnitPhrase(num)
num -
void
handleMoveCollision(/*Object
*/ gameData,
/*Array
*/ collisionMoves)
Override to handle move collisions from concurrent turns.
Overrides:handleMoveCollision
in class Game
gameData -The most current gameData on the server. This is the state the collision moves must be merged into.
collisionMoves -The list of moves that generated the collision.
Example:
handleMoveCollision:function(gameData,collisionMoves) { var lastCollisionMove=collisionMoves[collisionMoves.length-1]; this.importRawGame(gameData); //make same moves as lastCollisionMove this.sendMove(); }
incrementPhase(commit)
commit -
void
initialize(/*Number
*/ numPlayers,
/*Number
*/ turnTeamIndex)
The first method to be called when a game is created, override to set up teams, players and the game state.
Overrides:initialize
in class Game
numPlayers -The number of players from the game form.
turnTeamIndex -The index of the team to set the initial turn. Call the Super with -1 to set all teams turn.
Example:
// Override initialize initialize:function(numPlayers,turnTeamIndex) { // Call the Super.initialize to add default teams. Super.initialize(numPlayers,turnTeamIndex); // Initialize the board state. this.info["board"]="rnbqkbnrpppppppp PPPPPPPPRNBQKBNR"; var team=this.teams[0]; team.info["i_ep"]=-1; team.info["b_cs"]=true; team.info["b_cl"]=true; team=this.teams[1]; team.info["i_ep"]=-1; team.info["b_cs"]=true; team.info["b_cl"]=true; // Log the start of game. this.move.log=this.logEntry(44); }
void
initializeNewGameForm(/*GameForm
*/ gameForm,
/*Array
*/ userInfo)
Seeds the game form options with values from the current game.
Overrides:initializeNewGameForm
in class Game
gameForm -The game form to seed.
userInfo -An array of user information.
isOrderCrazy(order)
order -
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
resourceName -(Optional) A resource name to override the default resource to use.
missingRetreatsInLog(s1,
mp1,
s2,
mp2)
s1 -
mp1 -
s2 -
mp2 -
mustTurnInOrdersHtml(needToTurnInOrders)
needToTurnInOrders -
needToTurnInOrders()
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
resourceName -(Optional) A resource name to override the default resource to use.
noteOrphanedOrders(orders)
orders -
String
offerDrawHtml(/*String
*/ resourceName)
Called when needing the offer-a-draw-with-this-move prompts HTML (typically a short sentence and a Offer A Draw checkbox). Override to set. Internally uses the "youMayOfferDraw" and "offerDrawWithThisMove" resources.
Overrides:offerDrawHtml
in class Game
resourceName -(Optional) A resource name to override the default resource to use.
openJudge()
openJudgeAnchorHtml()
openMapEditor()
openMapEditorAnchorHtml()
orderTableHtml(noteOrphaned)
noteOrphaned -
orderTerritoryDescriptionHtml(tIndex,
cIndex,
unitType)
tIndex -
cIndex -
unitType -
orderUnitImageHtml(order)
order -
packGameData(gamePhase,
movePhase,
orderPhase,
board,
orders,
lastTimeOrdersTurnedIn,
orderTimeLimit)
gamePhase -
movePhase -
orderPhase -
board -
orders -
lastTimeOrdersTurnedIn -
orderTimeLimit -
processOrders(commit)
commit -
processOrdersButtonHtml()
processOrdersHtml(justTheTable)
justTheTable -
Boolean
processSecureMove(/*GamesByEmail
*/ game)
Gets called when the sending moves, fir processing secure move data on the client. Override to process secure data.
Overrides:processSecureMove
in class Game
game -The game object to process.
false
.
replaceOverriddenOrders(orders,
oOrders)
orders -
oOrders -
reportOrderImageError(src)
src -
resetOrdersIfTesting()
void
resign()
Resignes the current player. Clears mouse events, sets the player as resigned, and sends the move.
Overrides:
retreatOrDisbandHtml()
retreatOrdersMouseDown(point,
event)
point -
event -
retreatOrdersMouseMove(point)
point -
retreatOrdersMouseUp(point)
point -
seasonFromGamePhase(gamePhase)
gamePhase -
sendOrderImageErrors()
sendOrderImageErrorsResponse(response)
response -
setMouseTerritoriesByPoint(point,
noRepeats)
point -
noRepeats -
setOrdersForNewPhase()
setTurnsForTeamsToGiveOrders()
shortOrderDescriptionHtml(order,
orders)
order -
orders -
showExample(notation)
notation -
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
standardExamplesHtml()
submitDefaultOrders()
submitDefaultOrdersButtonHtml()
void
synch()
Called when the game should synchronize with info
properties from the server.
void
synchTeam(/*Team
*/ team)
Called to synchronize the team properties with the raw team data. Just the color
and title
properties are set by default, override to set more.
team -The team to synchronize.
Number
teamColorFromTeam(/*Team
*/ team)
Gets the team color.
Overrides:teamColorFromTeam
in class Game
team -The team to get the color of.
testOrderImageFor404(e)
e -
testingOrdersHtml()
String
turnHeaderHtml(/*String
*/ resourceName)
Called when needing the it's-your-turn header HTML. Override to set. Internally uses the "turnHeader" resource.
Overrides:turnHeaderHtml
in class Game
resourceName -(Optional) A resource name to override the default resource to use.
turnInOrders(emptyOrders,
forced)
emptyOrders -
forced -
turnInOrdersButtonHtml(newOrdersToTurnIn)
newOrdersToTurnIn -
turnInOrdersOnClick()
undoAnchorHtml()
unitImageHtml(color,
unitType)
color -
unitType -
unpackGameData(data)
data -
updateExpirePhrase()
updateOrderImages(overrideOrders)
overrideOrders -
waitingForOrders()
weHaveDisolves()
weHaveDisolvesOrBuilds()
weHaveUnits(dislodged)
dislodged -
whoAreWeWaitingOnHtml()
writeOrdersHtml()
yearFromGamePhase(gamePhase)
gamePhase -