Games\Viktory2\Game.js
GamesByEmail
Object
GamesByEmail.Game
All Implemented Interfaces:
GamesByEmail.Viktory2Game
extendsGame
implementsGamesByEmail.Hex
Constructor Summary |
|
Enum Summary | |
static | HEX_TYPE
|
static | MOVE_PHASE
|
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 |
Methods inherited from GamesByEmail.Hex |
boardPointFromScreenXY , boardPointFromValueIndex , forEachBoardPoint , numInPath , screenRectFromBoardXY , valueIndexFromBoardXY |
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.Viktory2Game()
Enum Detail |
static HEX_TYPE
PLAIN -
GRASSLAND -
FOREST -
MOUNTAIN -
WATER -
CONVERT_TO_LAND -
static MOVE_PHASE
RESET -
DOOMSDAY_CLOCK -
CAPITAL -
RELOCATE -
PENNANTS -
MOVE -
RETREAT -
NEW_VASSAL -
VASSAL_RESERVES -
VASSAL_RESERVE_BATTLES -
NEW_VASSAL_COMPLETE -
RESERVES -
RESERVE_BATTLES -
OVER -
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 |
addAdditionalLogEntry(logEntry)
logEntry -
addMapCustomizationData(data,
playOptions)
data -
playOptions -
alignElementWithPiece(element,
piece)
element -
piece -
anyBattlesPending()
anyMovesOrBattlesLeft()
StringBuilder
appendAdditionalPreferencesHtml(/*StringBuilder
*/ htmlBuilder)
Override to add additional player preferences.
Overrides:appendAdditionalPreferencesHtml
in class Game
htmlBuilder -The string builder to add the extra player preference HTML to.
appendBuildingBudgetToReserves()
balanceExplorationOnMouseDown(screenPoint)
screenPoint -
battlesPendingAlert(alertType)
alertType -
boardEditorMouseDown(screenPoint)
screenPoint -
boardEditorRequest(editType,
editValue)
editType -
editValue -
String
boardValueFromValueColor(/*String
*/ value,
/*Number
*/ color)
Gets the board value from a value and color. By default, the value is returned if color is zero, else the upper case of the value is returned.
Overrides:boardValueFromValueColor
in class Game
value -The value.
color -The color.
bombardUnitsMouseDown(screenPoint)
screenPoint -
bombardUnitsMouseMove(screenPoint)
screenPoint -
bombardUnitsMouseUp(screenPoint)
screenPoint -
canBalanceExploration(overideUndoLength)
overideUndoLength -
canBuildOrReserve()
canBuildOrUpgrade()
canDoSomethingWithReserves(notTown,
notMilitary)
notTown -
notMilitary -
centerElementOverPiece(element,
piece)
element -
piece -
chatImageHtml(chatId)
chatId -
chatVibration()
checkForWin(committing)
committing -
clearMapCustomizationData(playOptions)
playOptions -
Number
colorFromBoardValue(/*String
*/ boardValue)
Gets the color from a board value. By default, lower case characters return 0, uppercase 1, and everything else -1.
Overrides:colorFromBoardValue
in class Game
boardValue -The value to check, by default a single character.
compileStatistics(moves)
moves -
String
completeYourTurnHtml(/*String
*/ resourceName)
Called when needing the complete-your-turn game prompt HTML (typically a short sentence about the move and a Send This Move button). Override and set mouse events here. Internally uses the "completeYourTurn" resource.
Overrides:completeYourTurnHtml
in class Game
resourceName -(Optional) A resource name to override the default resource to use.
confirmEndReservePlacement(confirmType)
confirmType -
String
continueYourTurnHtml(/*String
*/ resourceName)
Called when needing the continue-your-turn game prompt HTML (typically a short sentence about the move, no send move button yet). Override and set mouse events here. Internally uses the "continueYourTurn" resource.
Overrides:continueYourTurnHtml
in class Game
resourceName -(Optional) A resource name to override the default resource to use.
couldPlaceReserveUnit(unitType,
color,
controlsCapital)
unitType -
color -
controlsCapital -
countHitsForLog(rolls,
hitThreshold,
otherHits)
rolls -
hitThreshold -
otherHits -
countNewVisible(v1,
v2)
v1 -
v2 -
countWaterInMapCustomizationData(playOptions)
playOptions -
createUnitCounts()
customizeMapDoAll(doUpdate)
doUpdate -
customizeMapOnMouseDown(value)
value -
customizeMapOnMouseMove(screenPoint)
screenPoint -
customizeMapOnMouseUp(screenPoint)
screenPoint -
debugScreenPoint(screenPoint)
screenPoint -
defensiveLuckAveragingOnClick(checked)
checked -
disbandObligitories(color)
color -
dispose()
distanceBewteenPoints(p1,
p2)
p1 -
p2 -
doesColorControlTheirCapital(color)
color -
doneWithPhase()
doomsdayClockHtml()
eliminateExtraUnitsHtml()
eliminateExtraUnitsMouseDown(screenPoint)
screenPoint -
eliminateExtraUnitsMouseMove(screenPoint)
screenPoint -
eliminateExtraUnitsMouseOut(screenPoint)
screenPoint -
endMyMovement()
endMyTurn()
everyOtherTeamHasDoomsdayClock(color)
color -
findTargetPoint(point)
point -
forfeitMapCustomization()
forfeitPendingBattles()
getActionLinksHtml()
//stats
Overrides:getActionLinksHtml
in class Game
getArtilleryDifference(unitCounts)
unitCounts -
getBattleData()
getBoardEditorAnchorHtml()
getBuildables(color,
rulerColor)
color -
rulerColor -
getCapitalPoints(board,
color,
playOptions,
landOnly)
board -
color -
playOptions -
landOnly -
getCavalryDifference(unitCounts)
unitCounts -
getCombatSupplyIconHtml()
getCommonOverlayHtml(activePiece)
activePiece -
getCurrentBuildSpending(color)
color -
getCurrentRemovingType()
getDataString(movePhase,
board,
visibility,
units,
battle,
playOptions)
movePhase -
board -
visibility -
units -
battle -
playOptions -
getDefensiveLuckAveragingControlsHtml()
getDoomsdayClockResultsHtml()
getEnabledPlayOptionsHtml(color)
color -
getFrigateDifference(unitCounts)
unitCounts -
getGameDescriptionHtml()
getHitThreshold(color)
color -
getInfantryDifference(unitCounts)
unitCounts -
getLastActivityPiece()
getMapCustomizationData(playOptions)
playOptions -
getMapCustomizationHtml()
getMemoryUnits(index)
index -
getMoveLogFromUndoStack()
getNewVassal()
getNewVassalCompleteHtml()
getNewVassalHtml()
getNumMapCustomizations(playOptions)
playOptions -
getOptionsDataString(playOptions)
playOptions -
getPointPerimeterValue(point)
point -
getRandomAvailableLandHexValue(playOptions)
playOptions -
getRemainingBuildingBudget(color)
color -
getReserveHtml(team)
team -
getReserveOnMouseDown(team)
team -
getReserveUnitImageHtml(unitType,
color,
couldPlace,
onMouseDown)
unitType -
color -
couldPlace -
onMouseDown -
getReserveUnitTypes(color)
color -
getRetreatingPiece()
getStatisticsHtml(stats)
stats -
getStatisticsPopupHtml(popupWin)
popupWin -
getTargetPlaceHolderPoint(point)
point -
getTargetPoint(point)
point -
getTeamOptionsData(playOptions)
playOptions -
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.
getUnitImageHtml(unitType,
color,
attributes)
unitType -
color -
attributes -
getUnitImageSrc()
getUnitSheetAnchorHtml()
getVassalReorganizationWarningHtml()
hasDoomsdayResults()
hiliteVisibilityDifference(vis1,
vis2)
vis1 -
vis2 -
hitPhrase(num)
num -
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.
Point
isBoardPointHidden(/*Point
*/ boardPoint)
Returns whether the board point is hidden from the current player, for games like Dark Chess.
Overrides:isBoardPointHidden
in class Game
boardPoint -The board point.
isLandAtPointBoard(point,
board)
point -
board -
isPointOnPerimeter(point)
point -
isTargetPoint(point)
point -
isTeamInOurAlliance(team)
team -
isUnexploredByAnyTeam(index)
index -
isWaterAtPointBoard(point,
board)
point -
board -
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.
mapCustomizationDataCanSwapWater(playOptions)
playOptions -
mapDataOption(data,
encoding)
data -
encoding -
matchBoardToNumPlayersAndColor(numPlayers,
color)
numPlayers -
color -
maybeCenterOverlay(piece)
piece -
maybeFinishRetreat(retreatingPiece)
retreatingPiece -
maybeFinishRetreat2(retreatingPiece)
retreatingPiece -
maybeHideOverlay()
maybeMemorizeCivilizations()
maybeMouseOut()
maybeReleaseFromVassalage(piece)
piece -
maybeRequestStatistics()
maybeResetReservesByMouseUp()
maybeTempHideOverlay(event)
event -
maybeTempUnhideOverlay(event)
event -
maybeUndarkAdjacent(point,
radius)
point -
radius -
maybeUndarkPiece(piece)
piece -
militaryUnitFromScreenPoint(screenPoint,
unitType,
color,
rulerColor,
movers,
bombarders,
loadables,
retreatables,
cargoType,
redeployables)
screenPoint -
unitType -
color -
rulerColor -
movers -
bombarders -
loadables -
retreatables -
cargoType -
redeployables -
moveBombardUnitsMouseMove(screenPoint)
screenPoint -
moveBombardUnitsMouseOut(screenPoint)
screenPoint -
moveToNextPlayer()
moveUnitsHtml()
moveUnitsMouseDown(screenPoint)
screenPoint -
moveUnitsMouseMove(screenPoint)
screenPoint -
moveUnitsMouseUp(screenPoint)
screenPoint -
mustCommitBattleResults()
mustHandleMapCustomization()
needsCapitalPlaced()
needsExtrasRemoved()
needsPennantsPlaced()
needsPiecesReset()
newVassalCompleteHtml()
newVassalHtml()
nothingLeftToDo(checkMapCustomization)
checkMapCustomization -
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.
openBoardEditor(event)
event -
openBoardEditorHtml()
openStatistics(event)
event -
openStatisticsAnchorHtml()
openUnitSheet(event)
event -
openUnitSheetHtml()
overlayCommitOnClick()
parseDataString(data)
data -
parseOptionsDataString(data)
data -
parseTeamOptionsData(data)
data -
pieceIndexAlreadyVisible(index)
index -
placeCapitalHtml()
placeCapitalMouseDown(screenPoint)
screenPoint -
placeCapitalMouseMove(screenPoint)
screenPoint -
placeCapitalMouseOut(screenPoint)
screenPoint -
placeReserveOnMouseMove(screenPoint)
screenPoint -
placeReserveOnMouseUp(screenPoint)
screenPoint -
populateStatisticsWindow(popupWin)
popupWin -
processBalanceExplorationMove(piece)
piece -
processBattleCompleteMove(piece)
piece -
processBeginRetreatUnitMove(piece)
piece -
processBombardUnitMove(piece)
piece -
processContinueBattleMove(piece,
retreatIndices,
startingBattle)
piece -
retreatIndices -
startingBattle -
processDoomsdayClockResults()
processFinishCivilizationRelocationMove()
processForNewTurn()
processMapCustomizationMove(piece)
piece -
processMapModificationMove(piece)
piece -
processMovePhase()
processMovePhaseForTeam(team)
team -
processMoveUnitMove()
processNewVassalCompleteResults()
processNewVassalResults()
processPlaceCapitalMove(piece)
piece -
processPlaceReserveUnitMove()
processPreBattleMove(piece)
piece -
processRelocateCivilizationMove()
processRemoveCivilizationMove()
processRetreatUnitMove()
processSendMove()
processStartBattleMove(piece)
piece -
processStartReserveBattleMove(piece)
piece -
processVassalReorganizationResults()
pushMapCustomizationMove(piece,
logData,
origNum)
piece -
logData -
origNum -
pushMove(title,
logEntry,
piece,
process,
forceReady,
commitTitle,
undoTitle)
title -
logEntry -
piece -
process -
forceReady -
commitTitle -
undoTitle -
pushUndoState(unitData,
battleData,
moveData)
unitData -
battleData -
moveData -
pushUniquePoint(points,
point)
points -
point -
qualifiesForCombatSupply(color)
color -
receiveStatistics(gameLog)
gameLog -
redeployUnitsMouseMove(screenPoint)
screenPoint -
redeployUnitsMouseUp(screenPoint)
screenPoint -
releaseAllVassals(exRulerColor)
exRulerColor -
relocateCivilizationMouseDown(screenPoint)
screenPoint -
relocateCivilizationMouseMove(screenPoint)
screenPoint -
relocateCivilizationMouseUp(screenPoint)
screenPoint -
removeExcessPieces(color,
update)
color -
update -
removeMapCustomizationDataValue(value)
value -
reserveOnMouseDown(element,
event,
index)
element -
event -
index -
reserveOnMouseUp(element)
element -
reservePhaseOnMouseDown(screenPoint)
screenPoint -
reservePlacementHtml(unitType)
unitType -
reserveRetreatOnMouseOver(event)
event -
reserveRetreatOnMouseUp(event)
event -
reserveUnitsHtml()
resumeRetreating()
resumeRulersTurn()
retreatFromBattle(piece,
hitLog)
piece -
hitLog -
retreatUnitsHtml()
retreatUnitsMouseDown(screenPoint)
screenPoint -
retreatUnitsMouseMove(screenPoint)
screenPoint -
retreatUnitsMouseUp(screenPoint)
screenPoint -
retreatUnitsSelectMouseMove(screenPoint)
screenPoint -
retreatUnitsSelectMouseOut(screenPoint)
screenPoint -
revealAroundPoint(point,
visibility,
distance)
point -
visibility -
distance -
revealXY(x,
y,
visibility)
x -
y -
visibility -
rotateAttackIndex(index)
index -
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
.
String
sendMoveHtml(/*String
*/ resourceName)
Called when needing the send-this-move prompts HTML (typically a short sentence and a Send This Move button). Override to set. Internally uses the "youMaySendYourMove" resource.
Overrides:sendMoveHtml
in class Game
resourceName -(Optional) A resource name to override the default resource to use.
setBalanceExploration()
setBattleData(piece,
round,
attackerRolls,
defenderRolls,
retreats)
piece -
round -
attackerRolls -
defenderRolls -
retreats -
setEconomicVictors(loserColor)
loserColor -
setPendingBattle()
setPerimeterValues(point,
data,
value)
point -
data -
value -
void
setPerspective(/*Team
*/ team)
Called when synchronizing, sets the perspective of the board based on the player. By default sets the rotation
property to 0.
setPerspective
in class Game
team -The team to synchronize.
void
setPlayerPrefs()
Extract the player's preferences from the player.info collection, and sets properties accordingly. By default, the font
and verbose
properties are extracted.
setPlayerPrefs
in class Game
setRetreatingPiece(piece)
piece -
setSubjugation(color,
rulerColor)
color -
rulerColor -
setTargetPoints(points)
points -
showOverlay()
showReserveMessage(screenPoint,
messageHtml)
screenPoint -
messageHtml -
skipMoveUnits()
skipMoveUnitsButtonHtml()
sssreceiveLog(gameLog)
gameLog -
swapOneWaterInMapCustomizationData(logIt,
playOptions)
logIt -
playOptions -
swapWaterForLand()
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.
theHitPhrase(num)
num -
townPlacementHtml()
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.
turnPhaseHtml()
void
undo(/*Boolean
*/ skipUpdate)
Undos all moves since the last synch
method call. The synch
and update
methods will be called again.
skipUpdate -(Optional) Skips the update call if true. Defaults to false.
unitPhrase(num)
num -
unrelocatableMouseUp(screenPoint)
screenPoint -
void
update()
Updates the team titles, the game header, the game title, all prompts and action links.
Overrides:
String
valueFromBoardValue(/*String
*/ boardValue)
Gets the value from a board value. By default, the lower case of the board value is returned.
Overrides:valueFromBoardValue
in class Game
boardValue -The value to check, by default a single character.
vassalReorganizationHtml()