new Headquarters()
- Source:
Classes
Members
Config
- Source:
[undefined]
- Source:
attackManager
- Source:
attackManager
- Source:
basesManager
- Source:
basesManager
- Source:
borderMap
- Source:
buildManager
- Source:
buildManager
- Source:
canBarter
- Source:
capturableTargets
- Source:
capturableTargetsTime
- Source:
capturableTargetsTime
- Source:
currentPhase
- Source:
currentPhase
- Source:
decayingStructures
- Source:
defenseManager
- Source:
defenseManager
- Source:
diplomacyManager
- Source:
diplomacyManager
- Source:
emergencyManager
- Source:
emergencyManager
- Source:
extraFortresses
- Source:
extraTowers
- Source:
firstBaseConfig
- Source:
fortStartTime
- Source:
fortStartTime
- Source:
fortressLapseTime
- Source:
fortressStartTime
- Source:
fortressStartTime
- Source:
garrisonManager
- Source:
garrisonManager
- Source:
landRegions
- Source:
lastFailedGather
- Source:
maxFields
- Source:
maxFields
- Source:
navalManager
- Source:
navalManager
- Source:
navalMap
- Source:
navalRegions
- Source:
phasing
- Source:
phasing
- Source:
requireHouses
- Source:
requireHouses
- Source:
researchManager
- Source:
researchManager
- Source:
saveResources
- Source:
saveSpace
- Source:
supportRatio
- Source:
targetNumWorkers
- Source:
territoryMap
- Source:
territoryMap
- Source:
towerLapseTime
- Source:
towerStartTime
- Source:
towerStartTime
- Source:
tradeManager
- Source:
tradeManager
- Source:
treasures
- Source:
turnCache
- Source:
turnCache
- Source:
victoryManager
- Source:
victoryManager
- Source:
Methods
Deserialize()
- Source:
GetCurrentGatherRates()
Returns the current gather rate
This is not per-se exact, it performs a few adjustments ad-hoc to account for travel distance, stuffs like that.
- Source:
GetWantedGatherRates()
Returns the wanted gather rate.
- Source:
OnPhaseUp()
Called by any "phase" research plan once it's started
- Source:
Serialize()
- Source:
baseAtIndex(territoryIndex) → {number}
Parameters:
| Name | Type | Description |
|---|---|---|
territoryIndex |
number | The index to get the map for. |
- Source:
Returns:
- The ID of the base at the given territory index.
- Type
- number
baseManagers()
- Source:
buildDefenses()
Deals with building fortresses and towers along our border with enemies.
- Source:
buildFarmstead()
Build a farmstead
- Source:
buildForge()
- Source:
buildMarket()
- Source:
buildMoreHouses()
build more houses if needed.
kinda ugly, lots of special cases to both build enough houses but not tooo many…
- Source:
buildNewBase()
- Source:
buildTemple()
- Source:
buildWonder()
Try to build a wonder when required
force = true when called from the victoryManager in case of Wonder victory condition.
- Source:
bulkPickWorkers()
returns an entity collection of workers through BaseManager.pickBuilders
TODO: when same accessIndex, sort by distance
- Source:
canBuild()
- Source:
checkBaseExpansion()
Checks the status of the territory expansion. If no new economic bases created, build some strategic ones.
- Source:
checkEvents()
- Source:
checkPhaseRequirements()
Ensure that all requirements are met when phasing up
- Source:
constructTrainingBuildings()
Deals with constructing military buildings (e.g. barracks, stable).
They are mostly defined by Config.js. This is unreliable since changes could be done easily.
- Source:
findBestBaseForMilitary()
Find base nearest to ennemies for military buildings.
- Source:
findBestTrainableUnit()
picks the best template based on parameters and classes
- Source:
findDefensiveLocation()
Returns the best position to build defensive buildings (fortress and towers)
Whose primary function is to defend our borders
- Source:
findEconomicCCLocation()
Returns the best position to build a new Civil Center
Whose primary function would be to reach new resources of type "resource".
- Source:
findMarketLocation()
Returns the best position to build a new market: if the allies already have a market, build it as far as possible
from it, although not in our border to be able to defend it easily. If no allied market, our second market will
follow the same logic.
To do so, we suppose that the gain/distance is an increasing function of distance and look for the max distance
for performance reasons.
- Source:
findStrategicCCLocation()
Returns the best position to build a new Civil Center
Whose primary function would be to assure territorial continuity with our allies
- Source:
getAccountedPopulation()
Get the number of population already accounted for
- Source:
getAccountedWorkers()
Get the number of workers already accounted for
- Source:
getBaseByID()
returns the base corresponding to baseID
- Source:
getSeaBetweenIndices()
returns the sea index linking regions 1 and region 2 (supposed to be different land region)
otherwise return undefined
for the moment, only the case land-sea-land is supported
- Source:
getTotalResourceLevel()
- Source:
handleNewBase()
- Source:
hasActiveBase()
- Source:
hasPotentialBase()
- Source:
init()
More initialisation for stuff that needs the gameState
- Source:
isDangerousLocation()
- Source:
isDefendable()
Check if a structure in blinking territory should/can be defended (currently if it has some attacking armies around)
- Source:
isNearInvadingArmy()
Check that the chosen position is not too near from an invading army
- Source:
isUnderEnemyFire()
- Source:
manageCorral()
Build a corral, and train animals there
- Source:
numActiveBases()
returns the number of bases with a cc
ActiveBases includes only those with a built cc
PotentialBases includes also those with a cc in construction
- Source:
numPotentialBases()
- Source:
pickMostNeededResources()
Pick the resource which most needs another worker
How this works:
We get the rates we would want to have to be able to deal with our plans
We get our current rates
We compare; we pick the one where the discrepancy is highest.
Need to balance long-term needs and possible short-term needs.
- Source:
postinit()
initialization needed after deserialization (only called when deserialization)
- Source:
trainEmergencyUnits()
train with highest priority ranged infantry in the nearest civil center from a given set of positions
and garrison them there for defense
- Source:
trainMoreWorkers()
This code trains citizen workers, trying to keep close to a ratio of worker/soldiers
- Source:
update()
Some functions are run every turn
Others once in a while
- Source:
updateCaptureStrength()
Compute the capture strength of all units attacking a capturable target
- Source:
updateTerritories()
- Source: