File: Games\Empires\Game.js

GamesByEmail
Class EmpiresCardWizard

Object
  
 
 
GamesByEmail.EmpiresCardWizard

All Implemented Interfaces:

Class, Elemental


GamesByEmail.EmpiresCardWizard

implements Foundation.Class, Foundation.Elemental

Constructor Summary
GamesByEmail.EmpiresCardWizard(game)

Field Summary

Fields inherited from Foundation.Elemental
$Foundation_$registry_index

Method Summary
 appendCardHtml()
// Inputs: StringBuilder html, card: a cardData entry.
 appendHtmlToShowCard(cardInHandIndex, html)
 areSameTypeOfCards(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)
 cardPicked2(checkbox)
 checkForAtLeastOneSelectableTerritory()
 dispose()
 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)
 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)
 getInteractiveEmpireModCardDescriptions()
// for Treachery, Astronomy & Reallocation cards
 getLastPickedLand()
 getOneEmpireModCardDescription(iCardId)
 getOneInteractiveEmpireModCardDescription(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)
 isKingdom(cardId)
 isMigrantsCard(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)
 isPreEmpireCard(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)
 isSelectableForBlackDeath(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)
 isSelectableForMigrants()
//CONSIDER MAKING THIS A STATIC METHOD
 isSelectableForMigrantsAfrica(territory)
 isSelectableForMigrantsAustralia()
/////////////////////////////////////////////////////////////// // Migrants
 isSelectableForMigrantsNorthAmerica(territory)
 isSelectableForPestilence()
/////////////////////////////////////////////////////////////// // Pestilence
 isSelectableForPlague(territory)
 isSelectableForReallocation(territory)
 isSelectableForTreachery(territory)
 isValidCard(iCardId)
 isValidCardForThisEpoch(iCardId)
 isVisible()
 mouseDown(screenPoint)
 mouseDownAstronomy(screenPoint)
 mouseDownReallocation(screenPoint)
 mouseDownSelectTerritoryForPreEmpireCard(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)
 mouseOut(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)
 playEmpireModCards()
/////////////////////////////////////////////////////////////// // Empire Mod Cards //Allow the user to play cards which will affect the activeEmpire.
 playEmpireModCards4Log()
 playJewishRevoltCard()
 playPreEmpireCard(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)
 setDeathCardString()
//deathcards are famine & pestilence & black death
 setPickedLandsString(aStrings)
 setPlagueString()
//Adds Members: aDice and aPickedLands to this class.
 setString(string)
 show()
//Displays all the cards in a player's hand.
 showDeathCardResultRow()
// html is a string builder
 showDoneButton(sEventHandler, sMsg)
 showRowOfCards(numColumns, rowNum, html, mode)
 showRowOfCheckboxes(numColumns, rowNum, html)

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

EmpiresCardWizard

GamesByEmail.EmpiresCardWizard(game)
Parameters:
game - 

Method Detail

appendCardHtml

appendCardHtml()

// Inputs: StringBuilder html, card: a cardData entry.


appendHtmlToShowCard

appendHtmlToShowCard(cardInHandIndex,
                     html)
Parameters:
cardInHandIndex - 

html - 


areSameTypeOfCards

areSameTypeOfCards(iCard1,
                   iCard2)
Parameters:
iCard1 - 

iCard2 - 


assignAstronomyHandlers

assignAstronomyHandlers()

///////////////// ASTRONOMY CARD ///////////////////////////// // Let user toggle a boat on and off in empty sea zones. // Show Astronomy prompt // Show Done button.


assignCardWizMouseHandlersToGame

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

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

canPlagueBePlayed()

/////////////////////////////////////////////////////////////// // Plague


cardPicked

cardPicked(checkbox)
Parameters:
checkbox - 


cardPicked2

cardPicked2(checkbox)
Parameters:
checkbox - 


checkForAtLeastOneSelectableTerritory

checkForAtLeastOneSelectableTerritory()

dispose

dispose()
Overrides:
dispose in class Class

doCard

doCard()

doFamineOrBlackDeath

doFamineOrBlackDeath()

//preconditions: this.iCurrentTerritory and this.iSecondTerritory hold areas


doPestilence

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

doPlague()

// invoked when user clicks "Ok" button from mouseDownPlague


doTwoTerritoryCard

doTwoTerritoryCard()

// Migrants and Disaster cards are similar.


doTwoTerritoryCard4Log

doTwoTerritoryCard4Log()

// Migrants and Disaster cards are similar.


endAstronomy

endAstronomy()

endPickAstronomy

endPickAstronomy()

endPickingReallocation

endPickingReallocation()

endPlayEmpireModCards

endPlayEmpireModCards()

endPlayPreEmpireCards

endPlayPreEmpireCards()

endReallocation

endReallocation()

getCardInHand

getCardInHand(player,
              index)
Parameters:
player - 

index - 


getDeathCardString

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

getEmpireModCardDescription4Log()

// Appears below the "Blah blahs appear in "


getIndexInPickedLands

getIndexInPickedLands(territoryId)
Parameters:
territoryId - 


getInteractiveEmpireModCardDescriptions

getInteractiveEmpireModCardDescriptions()

// for Treachery, Astronomy & Reallocation cards


getLastPickedLand

getLastPickedLand()

getOneEmpireModCardDescription

getOneEmpireModCardDescription(iCardId)
Parameters:
iCardId - 


getOneInteractiveEmpireModCardDescription

getOneInteractiveEmpireModCardDescription(iCardId)
Parameters:
iCardId - 


getPickedLand

getPickedLand()

//helper function cuz so many cards only deal w/1 land.


getPickedLandsString

getPickedLandsString()

getPlagueString

getPlagueString()

getReallocationMsg

getReallocationMsg()

getString

getString()

hasAnyEmpireModCardsInPlay

hasAnyEmpireModCardsInPlay()

hasInteractiveEmpireModCard

hasInteractiveEmpireModCard()

hideCardResults

hideCardResults()

hideCards

hideCards()

isEmpireModCard

isEmpireModCard()

//returns true for any cards which "modify" the current empire


isEmpireModPhaseCard

isEmpireModPhaseCard()

//Only some EmpireMod cards are played during the "EmpireMod" phase. //The rest (battleModifiers) simply exist.


isInteractiveEmpireModCard

isInteractiveEmpireModCard(iCard)
Parameters:
iCard - 


isKingdom

isKingdom(cardId)
Parameters:
cardId - 


isMigrantsCard

isMigrantsCard(cardId)
Parameters:
cardId - 


isMinorEmpireCard

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

isNotAlreadyPicked(land)
Parameters:
land - 


isPreEmpireCard

isPreEmpireCard(iCardId)
Parameters:
iCardId - 


isSelectable

isSelectable()

// Stub. Specific isSelectable implementations are assigned here.


isSelectableBarrenTerritory

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

isSelectableForAstronomy(territory)
Parameters:
territory - 


isSelectableForBlackDeath

isSelectableForBlackDeath(territory)
Parameters:
territory - 


isSelectableForCivilWar

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

isSelectableForDisaster()

/////////////////////////////////////////////////////////////// // Disaster


isSelectableForFamine

isSelectableForFamine(territory)
Parameters:
territory - 


isSelectableForMigrants

isSelectableForMigrants()

//CONSIDER MAKING THIS A STATIC METHOD


isSelectableForMigrantsAfrica

isSelectableForMigrantsAfrica(territory)
Parameters:
territory - 


isSelectableForMigrantsAustralia

isSelectableForMigrantsAustralia()

/////////////////////////////////////////////////////////////// // Migrants


isSelectableForMigrantsNorthAmerica

isSelectableForMigrantsNorthAmerica(territory)
Parameters:
territory - 


isSelectableForPestilence

isSelectableForPestilence()

/////////////////////////////////////////////////////////////// // Pestilence


isSelectableForPlague

isSelectableForPlague(territory)
Parameters:
territory - 


isSelectableForReallocation

isSelectableForReallocation(territory)
Parameters:
territory - 


isSelectableForTreachery

isSelectableForTreachery(territory)
Parameters:
territory - 


isValidCard

isValidCard(iCardId)
Parameters:
iCardId - 


isValidCardForThisEpoch

isValidCardForThisEpoch(iCardId)
Parameters:
iCardId - 


isVisible

isVisible()

mouseDown

mouseDown(screenPoint)
Parameters:
screenPoint - 


mouseDownAstronomy

mouseDownAstronomy(screenPoint)
Parameters:
screenPoint - 


mouseDownReallocation

mouseDownReallocation(screenPoint)
Parameters:
screenPoint - 


mouseDownSelectTerritoryForPreEmpireCard

mouseDownSelectTerritoryForPreEmpireCard(screenPoint)
Parameters:
screenPoint - 


mouseMove

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

mouseMoveGeneric()

// Set member function: this.mouseMove.isSelectable(territory); // to a function which returns true if this territory can be // be selected


mouseMovePickContinent

mouseMovePickContinent(screenPoint)
Parameters:
screenPoint - 


mouseOut

mouseOut(screenPoint)
Parameters:
screenPoint - 


orderCardsInHand

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

pickTerritories()

plagueCanStillSpread

plagueCanStillSpread()

playAKingdomCard

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

playDeathCardOnArea()

//Used for Famine and Black Death


playEmpireModCard

playEmpireModCard(iCard)
Parameters:
iCard - 


playEmpireModCards

playEmpireModCards()

/////////////////////////////////////////////////////////////// // Empire Mod Cards //Allow the user to play cards which will affect the activeEmpire.


playEmpireModCards4Log

playEmpireModCards4Log()

playJewishRevoltCard

playJewishRevoltCard()

playPreEmpireCard

playPreEmpireCard(iCardId)
Parameters:
iCardId - 


playPreEmpireCards

playPreEmpireCards()

/////////////////////////////////////////////////////////////// // Pre Empire Cards


playPreEmpireCards4Log

playPreEmpireCards4Log()

//called from game.logUpdate()


playPreEmpirePickTerritoryCard

playPreEmpirePickTerritoryCard()

/////////////////////////////////////////////////////////////// // playPreEmpirePickATerritoryCard //1st attempt at a generalized "interactive" function. //still uses some branching


prefixEmpireNameWithRebel

prefixEmpireNameWithRebel()

resetPickedLands

resetPickedLands()

resume2TerritoryCard

resume2TerritoryCard()

resumeCivilWar

resumeCivilWar()

//extra logic handles Jewish Revolt scenario as well


resumeDeathCard

resumeDeathCard()

//preconditions: this.aDeathCardResults was set in setString //Death cards: Pestilence/BlackDeath/Famine


resumeJewishRevolt

resumeJewishRevolt()

resumePlague

resumePlague()

//should resume here after calling sendMove in doPlague


resumePreEmpirePhase

resumePreEmpirePhase()

//cards like Plague will call sendMove. //resumePreEmpireCards is called to resume logic


rollDiceForTerritory

rollDiceForTerritory()

//preconditions: aDeathCardResults has been declared.


rolledAOne

rolledAOne(aDice)
Parameters:
aDice - 


setDeathCardString

setDeathCardString()

//deathcards are famine & pestilence & black death


setPickedLandsString

setPickedLandsString(aStrings)
Parameters:
aStrings - 


setPlagueString

setPlagueString()

//Adds Members: aDice and aPickedLands to this class.


setString

setString(string)
Parameters:
string - 


show

show()

//Displays all the cards in a player's hand.


showDeathCardResultRow

showDeathCardResultRow()

// html is a string builder


showDoneButton

showDoneButton(sEventHandler,
               sMsg)
Parameters:
sEventHandler - 

sMsg - 


showRowOfCards

showRowOfCards(numColumns,
               rowNum,
               html,
               mode)
Parameters:
numColumns - 

rowNum - 

html - 

mode - 


showRowOfCheckboxes

showRowOfCheckboxes(numColumns,
                    rowNum,
                    html)
Parameters:
numColumns - 

rowNum - 

html -