Games\Empires\Game.js
GamesByEmail
Object
All Implemented Interfaces:
GamesByEmail.EmpiresCardWizard
implementsFoundation.Class
,Foundation.Elemental
Constructor Summary |
|
Field Summary |
Fields inherited from Foundation.Elemental |
$Foundation_$registry_index |
Method Summary | |
|
// Inputs: StringBuilder html, card: a cardData entry.
|
|
|
|
|
|
///////////////// ASTRONOMY CARD /////////////////////////////
// Let user toggle a boat on and off in empty sea zones.
// Show Astronomy prompt
// Show Done button.
|
|
//The game class has 3 methods in it which just call methods in this class
//for mouseMove etc. Use this to delegate mouse handling to the cardWizard class.
|
|
///////////////// REALLOCATION CARD /////////////////////////////
// During the EmpireMod phase, go into a state where:
// MouseMove: Only highlight territories that the empire has fleets in.
// MouseDown:
// If a ship is there
// remove it.
// Add a coin.
// If no ship is there
// add a ship.
// Remove a coin.
|
|
///////////////////////////////////////////////////////////////
// Plague
|
|
|
|
|
|
|
|
|
|
|
|
//preconditions: this.iCurrentTerritory and this.iSecondTerritory hold areas
|
|
//Creates a new class member, aDeathCardResults. This is an array of
//arrays. 1st element has iCurrentTerritory + 3 dice.
//remaining elements have arrays with territory id followed by 2 dice.
|
|
// invoked when user clicks "Ok" button from mouseDownPlague
|
|
// Migrants and Disaster cards are similar.
|
|
// Migrants and Disaster cards are similar.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Pestilence State:
// T=Territory ID, absent, get from array for iCurrentTerritory
// d=dice. 3 for first territory, 2 for following territories.
// d|d|d|d:T2|d|d:T3|d|d ...
|
|
// Appears below the "Blah blahs appear in "
|
|
|
|
// for Treachery, Astronomy & Reallocation cards
|
|
|
|
|
|
|
|
//helper function cuz so many cards only deal w/1 land.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//returns true for any cards which "modify" the current empire
|
|
//Only some EmpireMod cards are played during the "EmpireMod" phase.
//The rest (battleModifiers) simply exist.
|
|
|
|
|
|
|
|
//With these handlers in place, now assign any custom mouse handlers to
//the local stubs here eg: this.mouseMove=this.mouseMoveMusterTest;
////////////// EmpiresCardWizard Mouse Handling ///////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// Stub. Specific isSelectable implementations are assigned here.
|
|
///////////////////////////////////////////////////////////////
// The Barbarian Card
// if card is the barbarian card,
// set mouseprompt to tell user to pick a territory.
// after picking a territory & clicking "Done"
// show card results dialog stating that barbarians are
// invading from blah blah territory.
// let logic resume in the game class
|
|
|
|
|
|
//Hack the old mouseDown into doCard();
//The idea of do card is to play the card.
//Some cards, like Treachery, will just show feedback. "You played blah blah" Ok.
//Other cards should be able to just short-circuit directly to the card ya?
//Well... you could confirm with the user. If confirming were done coming
//back from a sendMove, it could probably be incorporated into sendMove.
//Ya, skip redundant confirmation dialogs... user clicks "Done" gets
//the results.
|
|
///////////////////////////////////////////////////////////////
// Disaster
|
|
|
|
//CONSIDER MAKING THIS A STATIC METHOD
|
|
|
|
///////////////////////////////////////////////////////////////
// Migrants
|
|
|
|
///////////////////////////////////////////////////////////////
// Pestilence
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
////////////// EmpiresCardWizard Mouse Handling ///////////////////////////////////
//Hack borrowed from Tester to make mouse handlers work from this class
//for the game.
//Create 3 placeholders for mouseHandlers in this class. These get registered
//with the framework as class members.
|
|
// Set member function: this.mouseMove.isSelectable(territory);
// to a function which returns true if this territory can be
// be selected
|
|
|
|
|
|
//CardIds are sorted in order in which they can be played.
//If 2 cards are in play, ensure the lower CardId is played first.
|
|
|
|
|
|
//if card is a Kingdom,
//set down a city in that territory,
//assign it's empire id
//add an army
//set it's color.
//if there was a fort there, remove it.
// set mouse Html to "The Kingdom of Canaan has appeared. (Click)"
// iCardId: must be a kindgom card.
|
|
//Used for Famine and Black Death
|
|
|
|
///////////////////////////////////////////////////////////////
// Empire Mod Cards
//Allow the user to play cards which will affect the activeEmpire.
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////
// Pre Empire Cards
|
|
//called from game.logUpdate()
|
|
///////////////////////////////////////////////////////////////
// playPreEmpirePickATerritoryCard
//1st attempt at a generalized "interactive" function.
//still uses some branching
|
|
|
|
|
|
|
|
//extra logic handles Jewish Revolt scenario as well
|
|
//preconditions: this.aDeathCardResults was set in setString
//Death cards: Pestilence/BlackDeath/Famine
|
|
|
|
//should resume here after calling sendMove in doPlague
|
|
//cards like Plague will call sendMove.
//resumePreEmpireCards is called to resume logic
|
|
//preconditions: aDeathCardResults has been declared.
|
|
|
|
//deathcards are famine & pestilence & black death
|
|
|
|
//Adds Members: aDice and aPickedLands to this class.
|
|
|
|
//Displays all the cards in a player's hand.
|
|
// html is a string builder
|
|
|
|
|
|
|
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 |
Constructor Detail |
GamesByEmail.EmpiresCardWizard(game)
game -
Method Detail |
appendCardHtml()
// Inputs: StringBuilder html, card: a cardData entry.
appendHtmlToShowCard(cardInHandIndex,
html)
cardInHandIndex -
html -
areSameTypeOfCards(iCard1,
iCard2)
iCard1 -
iCard2 -
assignAstronomyHandlers()
///////////////// ASTRONOMY CARD ///////////////////////////// // Let user toggle a boat on and off in empty sea zones. // Show Astronomy prompt // Show Done button.
assignCardWizMouseHandlersToGame()
//The game class has 3 methods in it which just call methods in this class //for mouseMove etc. Use this to delegate mouse handling to the cardWizard class.
assignReallocationHandlers()
///////////////// REALLOCATION CARD ///////////////////////////// // During the EmpireMod phase, go into a state where: // MouseMove: Only highlight territories that the empire has fleets in. // MouseDown: // If a ship is there // remove it. // Add a coin. // If no ship is there // add a ship. // Remove a coin.
canPlagueBePlayed()
/////////////////////////////////////////////////////////////// // Plague
cardPicked(checkbox)
checkbox -
cardPicked2(checkbox)
checkbox -
checkForAtLeastOneSelectableTerritory()
dispose()
dispose
in class Class
doCard()
doFamineOrBlackDeath()
//preconditions: this.iCurrentTerritory and this.iSecondTerritory hold areas
doPestilence()
//Creates a new class member, aDeathCardResults. This is an array of //arrays. 1st element has iCurrentTerritory + 3 dice. //remaining elements have arrays with territory id followed by 2 dice.
doPlague()
// invoked when user clicks "Ok" button from mouseDownPlague
doTwoTerritoryCard()
// Migrants and Disaster cards are similar.
doTwoTerritoryCard4Log()
// Migrants and Disaster cards are similar.
endAstronomy()
endPickAstronomy()
endPickingReallocation()
endPlayEmpireModCards()
endPlayPreEmpireCards()
endReallocation()
getCardInHand(player,
index)
player -
index -
getDeathCardString()
//Pestilence State: // T=Territory ID, absent, get from array for iCurrentTerritory // d=dice. 3 for first territory, 2 for following territories. // d|d|d|d:T2|d|d:T3|d|d ...
getEmpireModCardDescription4Log()
// Appears below the "Blah blahs appear in "
getIndexInPickedLands(territoryId)
territoryId -
getInteractiveEmpireModCardDescriptions()
// for Treachery, Astronomy & Reallocation cards
getLastPickedLand()
getOneEmpireModCardDescription(iCardId)
iCardId -
getOneInteractiveEmpireModCardDescription(iCardId)
iCardId -
getPickedLand()
//helper function cuz so many cards only deal w/1 land.
getPickedLandsString()
getPlagueString()
getReallocationMsg()
getString()
hasAnyEmpireModCardsInPlay()
hasInteractiveEmpireModCard()
hideCardResults()
hideCards()
isEmpireModCard()
//returns true for any cards which "modify" the current empire
isEmpireModPhaseCard()
//Only some EmpireMod cards are played during the "EmpireMod" phase. //The rest (battleModifiers) simply exist.
isInteractiveEmpireModCard(iCard)
iCard -
isKingdom(cardId)
cardId -
isMigrantsCard(cardId)
cardId -
isMinorEmpireCard()
//With these handlers in place, now assign any custom mouse handlers to //the local stubs here eg: this.mouseMove=this.mouseMoveMusterTest; ////////////// EmpiresCardWizard Mouse Handling /////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
isNotAlreadyPicked(land)
land -
isPreEmpireCard(iCardId)
iCardId -
isSelectable()
// Stub. Specific isSelectable implementations are assigned here.
isSelectableBarrenTerritory()
/////////////////////////////////////////////////////////////// // The Barbarian Card // if card is the barbarian card, // set mouseprompt to tell user to pick a territory. // after picking a territory & clicking "Done" // show card results dialog stating that barbarians are // invading from blah blah territory. // let logic resume in the game class
isSelectableForAstronomy(territory)
territory -
isSelectableForBlackDeath(territory)
territory -
isSelectableForCivilWar()
//Hack the old mouseDown into doCard(); //The idea of do card is to play the card. //Some cards, like Treachery, will just show feedback. "You played blah blah" Ok. //Other cards should be able to just short-circuit directly to the card ya? //Well... you could confirm with the user. If confirming were done coming //back from a sendMove, it could probably be incorporated into sendMove. //Ya, skip redundant confirmation dialogs... user clicks "Done" gets //the results.
isSelectableForDisaster()
/////////////////////////////////////////////////////////////// // Disaster
isSelectableForFamine(territory)
territory -
isSelectableForMigrants()
//CONSIDER MAKING THIS A STATIC METHOD
isSelectableForMigrantsAfrica(territory)
territory -
isSelectableForMigrantsAustralia()
/////////////////////////////////////////////////////////////// // Migrants
isSelectableForMigrantsNorthAmerica(territory)
territory -
isSelectableForPestilence()
/////////////////////////////////////////////////////////////// // Pestilence
isSelectableForPlague(territory)
territory -
isSelectableForReallocation(territory)
territory -
isSelectableForTreachery(territory)
territory -
isValidCard(iCardId)
iCardId -
isValidCardForThisEpoch(iCardId)
iCardId -
isVisible()
mouseDown(screenPoint)
screenPoint -
mouseDownAstronomy(screenPoint)
screenPoint -
mouseDownReallocation(screenPoint)
screenPoint -
mouseDownSelectTerritoryForPreEmpireCard(screenPoint)
screenPoint -
mouseMove()
/////////////////////////////////////////////////////////////////////////////////// ////////////// EmpiresCardWizard Mouse Handling /////////////////////////////////// //Hack borrowed from Tester to make mouse handlers work from this class //for the game. //Create 3 placeholders for mouseHandlers in this class. These get registered //with the framework as class members.
mouseMoveGeneric()
// Set member function: this.mouseMove.isSelectable(territory); // to a function which returns true if this territory can be // be selected
mouseMovePickContinent(screenPoint)
screenPoint -
mouseOut(screenPoint)
screenPoint -
orderCardsInHand()
//CardIds are sorted in order in which they can be played. //If 2 cards are in play, ensure the lower CardId is played first.
pickTerritories()
plagueCanStillSpread()
playAKingdomCard()
//if card is a Kingdom, //set down a city in that territory, //assign it's empire id //add an army //set it's color. //if there was a fort there, remove it. // set mouse Html to "The Kingdom of Canaan has appeared. (Click)" // iCardId: must be a kindgom card.
playDeathCardOnArea()
//Used for Famine and Black Death
playEmpireModCard(iCard)
iCard -
playEmpireModCards()
/////////////////////////////////////////////////////////////// // Empire Mod Cards //Allow the user to play cards which will affect the activeEmpire.
playEmpireModCards4Log()
playJewishRevoltCard()
playPreEmpireCard(iCardId)
iCardId -
playPreEmpireCards()
/////////////////////////////////////////////////////////////// // Pre Empire Cards
playPreEmpireCards4Log()
//called from game.logUpdate()
playPreEmpirePickTerritoryCard()
/////////////////////////////////////////////////////////////// // playPreEmpirePickATerritoryCard //1st attempt at a generalized "interactive" function. //still uses some branching
prefixEmpireNameWithRebel()
resetPickedLands()
resume2TerritoryCard()
resumeCivilWar()
//extra logic handles Jewish Revolt scenario as well
resumeDeathCard()
//preconditions: this.aDeathCardResults was set in setString //Death cards: Pestilence/BlackDeath/Famine
resumeJewishRevolt()
resumePlague()
//should resume here after calling sendMove in doPlague
resumePreEmpirePhase()
//cards like Plague will call sendMove. //resumePreEmpireCards is called to resume logic
rollDiceForTerritory()
//preconditions: aDeathCardResults has been declared.
rolledAOne(aDice)
aDice -
setDeathCardString()
//deathcards are famine & pestilence & black death
setPickedLandsString(aStrings)
aStrings -
setPlagueString()
//Adds Members: aDice and aPickedLands to this class.
setString(string)
string -
show()
//Displays all the cards in a player's hand.
showDeathCardResultRow()
// html is a string builder
showDoneButton(sEventHandler,
sMsg)
sEventHandler -
sMsg -
showRowOfCards(numColumns,
rowNum,
html,
mode)
numColumns -
rowNum -
html -
mode -
showRowOfCheckboxes(numColumns,
rowNum,
html)
numColumns -
rowNum -
html -