Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/baseManager.js
/** | /** | ||||
* Base Manager | * Base Manager | ||||
* Handles lower level economic stuffs. | * Handles lower level economic stuffs. | ||||
* Some tasks: | * Some tasks: | ||||
* -tasking workers: gathering/hunting/building/repairing?/scouting/plans. | * -tasking workers: gathering/hunting/building/repairing?/scouting/plans. | ||||
* -giving feedback/estimates on GR | * -giving feedback/estimates on GR | ||||
* -achieving building stuff plans (scouting/getting ressource/building) or other long-staying plans. | * -achieving building stuff plans (scouting/getting ressource/building) or other long-staying plans. | ||||
* -getting good spots for dropsites | * -getting good spots for dropsites | ||||
* -managing dropsite use in the base | * -managing dropsite use in the base | ||||
* -updating whatever needs updating, keeping track of stuffs (rebuilding needs…) | * -updating whatever needs updating, keeping track of stuffs (rebuilding needs…) | ||||
*/ | */ | ||||
Silier: bring back the line | |||||
PETRA.BaseManager = function(gameState, basesManager) | PETRA.BaseManager = function(gameState, basesManager) | ||||
{ | { | ||||
this.Config = basesManager.Config; | this.Config = basesManager.Config; | ||||
this.ID = gameState.ai.uniqueIDs.bases++; | this.ID = gameState.ai.uniqueIDs.bases++; | ||||
this.basesManager = basesManager; | this.basesManager = basesManager; | ||||
// anchor building: seen as the main building of the base. Needs to have territorial influence | // anchor building: seen as the main building of the base. Needs to have territorial influence | ||||
this.anchor = undefined; | this.anchor = undefined; | ||||
Show All 9 Lines | PETRA.BaseManager = function(gameState, basesManager) | ||||
this.neededDefenders = this.Config.difficulty > 2 ? 3 + 2*(this.Config.difficulty - 3) : 0; | this.neededDefenders = this.Config.difficulty > 2 ? 3 + 2*(this.Config.difficulty - 3) : 0; | ||||
// vector for iterating, to check one use the HQ map. | // vector for iterating, to check one use the HQ map. | ||||
this.territoryIndices = []; | this.territoryIndices = []; | ||||
this.timeNextIdleCheck = 0; | this.timeNextIdleCheck = 0; | ||||
}; | }; | ||||
/** | |||||
* New base with an anchor | |||||
*/ | |||||
PETRA.BaseManager.STATE_WITH_ANCHOR = "anchored"; | |||||
Done Inline ActionsYes, I know no aliasing for undefined. But I think here is an exception nice. While in the other instances where I previously added a constant for undefined, it just said: "No value here/This is empty", while here is really a real meaning JCWasmx86: Yes, I know no aliasing for undefined. But I think here is an exception nice. While in the… | |||||
Done Inline ActionsYou could set some string here then? ;) Freagarach: You could set some string here then? ;) | |||||
Not Done Inline ActionsYeah, but need to make sure it is always the default value no matter situation Silier: Yeah, but need to make sure it is always the default value no matter situation | |||||
/** | |||||
* New base with a foundation anchor | |||||
*/ | |||||
PETRA.BaseManager.STATE_UNCONSTRUCTED = "unconstructed"; | |||||
/** | |||||
* Captured base with an anchor | |||||
*/ | |||||
PETRA.BaseManager.STATE_CAPTURED = "captured"; | |||||
/** | |||||
* Anchorless base, currently with dock | |||||
*/ | |||||
PETRA.BaseManager.STATE_ANCHORLESS = "anchorless"; | |||||
PETRA.BaseManager.prototype.init = function(gameState, state) | PETRA.BaseManager.prototype.init = function(gameState, state) | ||||
{ | { | ||||
if (state == "unconstructed") | if (state == PETRA.BaseManager.STATE_UNCONSTRUCTED) | ||||
this.constructing = true; | this.constructing = true; | ||||
else if (state != "captured") | else if (state != PETRA.BaseManager.STATE_CAPTURED) | ||||
this.neededDefenders = 0; | this.neededDefenders = 0; | ||||
this.workerObject = new PETRA.Worker(this); | this.workerObject = new PETRA.Worker(this); | ||||
// entitycollections | // entitycollections | ||||
this.units = gameState.getOwnUnits().filter(API3.Filters.byMetadata(PlayerID, "base", this.ID)); | this.units = gameState.getOwnUnits().filter(API3.Filters.byMetadata(PlayerID, "base", this.ID)); | ||||
this.workers = this.units.filter(API3.Filters.byMetadata(PlayerID, "role", "worker")); | this.workers = this.units.filter(API3.Filters.byMetadata(PlayerID, "role", "worker")); | ||||
this.buildings = gameState.getOwnStructures().filter(API3.Filters.byMetadata(PlayerID, "base", this.ID)); | this.buildings = gameState.getOwnStructures().filter(API3.Filters.byMetadata(PlayerID, "base", this.ID)); | ||||
this.mobileDropsites = this.units.filter(API3.Filters.isDropsite()); | this.mobileDropsites = this.units.filter(API3.Filters.isDropsite()); | ||||
Show All 10 Lines | PETRA.BaseManager.prototype.init = function(gameState, state) | ||||
{ | { | ||||
this.dropsiteSupplies[res] = { "nearby": [], "medium": [], "faraway": [] }; | this.dropsiteSupplies[res] = { "nearby": [], "medium": [], "faraway": [] }; | ||||
this.gatherers[res] = { "nextCheck": 0, "used": 0, "lost": 0 }; | this.gatherers[res] = { "nextCheck": 0, "used": 0, "lost": 0 }; | ||||
} | } | ||||
}; | }; | ||||
PETRA.BaseManager.prototype.reset = function(gameState, state) | PETRA.BaseManager.prototype.reset = function(gameState, state) | ||||
{ | { | ||||
if (state == "unconstructed") | if (state == PETRA.BaseManager.STATE_UNCONSTRUCTED) | ||||
this.constructing = true; | this.constructing = true; | ||||
else | else | ||||
this.constructing = false; | this.constructing = false; | ||||
if (state != "captured" || this.Config.difficulty < 3) | if (state != PETRA.BaseManager.STATE_CAPTURED || this.Config.difficulty < 3) | ||||
this.neededDefenders = 0; | this.neededDefenders = 0; | ||||
else | else | ||||
this.neededDefenders = 3 + 2 * (this.Config.difficulty - 3); | this.neededDefenders = 3 + 2 * (this.Config.difficulty - 3); | ||||
}; | }; | ||||
PETRA.BaseManager.prototype.assignEntity = function(gameState, ent) | PETRA.BaseManager.prototype.assignEntity = function(gameState, ent) | ||||
{ | { | ||||
ent.setMetadata(PlayerID, "base", this.ID); | ent.setMetadata(PlayerID, "base", this.ID); | ||||
▲ Show 20 Lines • Show All 1,031 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
bring back the line