add a gatherer to the turn cache for this supply.
The next two are to register that we assigned a gatherer to a resource this turn.
Count gatherers returning resources in the number of gatherers of resourceSupplies to prevent the AI always reassigning idle workers to these resourceSupplies (specially in naval maps).
Assign the starting entities to the different bases
Deals with building fortresses and towers along our border with enemies.
Build a farmstead
build our first base if not enough resource, try first to do a dock
build more houses if needed. kinda ugly, lots of special cases to both build enough houses but not tooo many…
Try to build a wonder when required force = true when called from the victoryManager in case of Wonder victory condition.
returns an entity collection of workers through BaseManager.pickBuilders TODO: when same accessIndex, sort by distance
Checks the status of the territory expansion. If no new economic bases created, build some strategic ones.
TODO check if the new anchorless bases should be added to addBase
Ensure that all requirements are met when phasing up
configure our first base expansion - if on a small island, favor fishing - count the available wood resource, and allow rushes only if enough (we should otherwise favor expansion)
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.
Create a new base in the baseManager: If an existing one without anchor already exist, use it. Otherwise create a new one. TODO when buildings, criteria should depend on distance allowedType: undefined => new base with an anchor "unconstructed" => new base with a foundation anchor "captured" => captured base with an anchor "anchorless" => anchorless base, currently with dock
set strategy if game without construction: - if one of our allies has a cc, affect a small fraction of our army for his defense, the rest will attack - otherwise all units will attack
Find base nearest to ennemies for military buildings.
picks the best template based on parameters and classes
Returns the best position to build defensive buildings (fortress and towers) Whose primary function is to defend our borders
Returns the best position to build a new Civil Center Whose primary function would be to reach new resources of type "resource".
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.
Returns the best position to build a new Civil Center Whose primary function would be to assure territorial continuity with our allies
Get the number of population already accounted for
Get the number of workers already accounted for
returns the base corresponding to baseID
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.
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
Returns the wanted gather rate.
More initialisation for stuff that needs the gameState
Check if a structure in blinking territory should/can be defended (currently if it has some attacking armies around)
Check that the chosen position is not too near from an invading army
flag a resource as exhausted
Build a corral, and train animals there
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
Called by any "phase" research plan once it's started
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.
initialization needed after deserialization (only called when deserialization)
Reassign territories when a base is going to be deleted
determine the main land Index (or water index if none) as well as the list of allowed (land andf water) regions
remove a gatherer to the turn cache for this supply.
load units and buildings from the config files TODO: change that to something dynamic
train with highest priority ranged infantry in the nearest civil center from a given set of positions and garrison them there for defense
This code trains citizen workers, trying to keep close to a ratio of worker/soldiers
Some functions are run every turn Others once in a while
Compute the capture strength of all units attacking a capturable target