Games\Gambit\Game.js
GamesByEmail
Object
GamesByEmail.Game
All Implemented Interfaces:
GamesByEmail.GambitGame
extendsGame
Constructor Summary |
|
Constant Summary | |
static | MAX_ARMY_SIZE
|
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 | |
|
Override to add additional player preferences.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Gets any HTML for an information row to be displayed below the bottom team titles.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Checks to see if a move is legal. By default calls
isMoveLegal . |
|
|
|
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.
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Creates HTML for a action links: Open log, open rules, open preferences, and report problem anchors.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Orders the players for the next game. By default the user information is reversed.
|
|
|
|
|
|
|
|
|
|
|
|
Gets the HTML for the team title on the board. By default uses resources 'turnTeamTitle' or 'teamTitle'.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Resignes the current player. Clears mouse events, sets the player as resigned, and sends the move.
|
|
|
|
|
|
|
|
|
|
Gets called when the Send Move button is pushed. Override and set the game state, then call Super.sendMove.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Called when the game should synchronize with
info properties from the server. |
|
|
|
|
|
|
|
|
|
|
|
|
|
Updates the team titles, the game header, the game title, all prompts and action links.
|
|
|
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.GambitGame()
Constant Detail |
static MAX_ARMY_SIZE
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 |
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.
attackButtonClick(attackers)
attackers -
attackClearTimer()
attackFromChange(index,
noOnBoard)
index -
noOnBoard -
attackHtml()
attackOrFortifyClick(point)
point -
attackToChange(index)
index -
battleOddsAnchorHtml()
String
belowTeamTitleRowHtml(/*Number
*/ numCols)
Gets any HTML for an information row to be displayed below the bottom team titles.
Overrides:belowTeamTitleRowHtml
in class Game
numCols -The number of columns of the table the row will belong in, set colspan accordingly.
buttonContrast(color)
color -
calcTradeInValue(cards)
cards -
canLogPeek(endStatus)
endStatus -
canMove(moveData,
color)
moveData -
color -
canPeek()
canTradeSet()
captureAllButtonClicked()
captureButtonClicked()
captureHtml()
captureIncrementButtonClick(reverse,
moveAll)
reverse -
moveAll -
captureMaxAnchorClicked()
cardLogTitle(index)
index -
cardTableHtml()
checkDirection(moveData,
point,
step,
color)
moveData -
point -
step -
color -
Boolean
checkMove(/*Point
*/ toPoint,
/*Point
*/ fromPoint)
Checks to see if a move is legal. By default calls isMoveLegal
.
toPoint -The board point moving to.
fromPoint -The board point moving from.
true
if the move is legal.
colorFromValueChars(cc1,
cc2)
cc1 -
cc2 -
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.
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.
deployMaxAnchorClicked()
deployRegularArmy(point)
point -
deploymentSizeHtml()
deploymentSummaryHtml()
diceHtml()
dispose()
done1ButtonClicked()
done1Html()
doneButtonClicked(force)
force -
doneHtml()
explainAirStrikesAnchorClicked()
fortifyButtonClick()
fortifyFromChange(index)
index -
fortifyHtml()
fortifyIncrementButtonClick(reverse,
moveAll)
reverse -
moveAll -
fortifyMaxAnchorClicked()
fortifyToChange(index)
index -
gambitColorResource(resourceName,
color)
resourceName -
color -
gameAndTradeInfoString()
gamePhaseFromSetup(setup)
setup -
String
getActionLinksHtml()
Creates HTML for a action links: Open log, open rules, open preferences, and report problem anchors.
Overrides:getActionLinksHtml
in class Game
getArmyDeploymentSize()
getArmyString(armies,
armyType,
capitol)
armies -
armyType -
capitol -
getAttackButtons(small)
small -
getCaptureButtons(small)
small -
getFortifyButtons(small)
small -
getImageSrcByColors(key)
key -
getNearestOnBoardPoint(point)
point -
Array
getNewGamePlayerOrder(/*Array
*/ userInfo)
Orders the players for the next game. By default the user information is reversed.
Overrides:getNewGamePlayerOrder
in class Game
userInfo -An array of user information as currently in this game.
getOnBoardAttackHtml(point)
point -
getOnBoardCaptureHtml(point)
point -
getOnBoardFortifyHtml(point)
point -
getRandomBoard(numPlayers,
setup)
numPlayers -
setup -
getShuffledDeck()
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.
getTerritoriesString(territories)
territories -
hideOnBoardControls()
highContrast(color)
color -
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.
isMoveLegal(point,
moveData,
color)
point -
moveData -
color -
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.
itsYourTurnNowPlaying()
itsYourTurnPickTerritories()
itsYourTurnPopulateTerritories()
maybeCardTableHtml(numCols)
numCols -
maybeShowArrow(fromIndex,
toIndex)
fromIndex -
toIndex -
mouseDown(screenPoint)
screenPoint -
mouseMove(screenPoint)
screenPoint -
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.
numberFromValueChars(cc1,
cc2)
cc1 -
cc2 -
occupyingArmiesButtonClicked(territoryIndex)
territoryIndex -
occupyingArmiesDeployerHtml()
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.
onBoardDoneButtonHtml()
openOddsAnchorClicked(screenX,
screenY)
screenX -
screenY -
openStatistics(event)
event -
openStatisticsAnchorHtml()
pieceColorBgName(color)
color -
pieceColorFgName(color)
color -
processOldLogMove(move,
moveIndex,
logIngredients)
move -
moveIndex -
logIngredients -
readyToAttack()
readyToFortify()
regularArmiesDeployerHtml()
void
resign()
Resignes the current player. Clears mouse events, sets the player as resigned, and sends the move.
Overrides:
roll(attackers,
defenders,
rollCacheSize)
attackers -
defenders -
rollCacheSize -
rollCacheSize(numAttackers,
numDefenders)
numAttackers -
numDefenders -
rollLog(entry,
startIndex,
diceSeperator)
entry -
startIndex -
diceSeperator -
selectCard(cardIndex)
cardIndex -
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
.
setArmyDeploymentSize(size)
size -
setHtml()
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
setTeamLog(team)
team -
showOnBoardAttack()
showOnBoardCapture()
showOnBoardFortify()
showOnBoardOccupyingDeployer()
spyButtonClick(defenderColor)
defenderColor -
spyHtml()
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.
titleArmyWorth(team)
team -
tournamentHtml()
tradeButtonClicked()
tradeInCards()
undisableTradeButtons()
void
update()
Updates the team titles, the game header, the game title, all prompts and action links.
Overrides:
valueCharsFromColorNumber(color,
num)
color -
num -