Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/headquarters.js
/** | /** | ||||
* Headquarters | * Headquarters | ||||
* Deal with high level logic for the AI. Most of the interesting stuff gets done here. | * Deal with high level logic for the AI. Most of the interesting stuff gets done here. | ||||
* Some tasks: | * Some tasks: | ||||
* -defining RESS needs | * -defining RESS needs | ||||
* -BO decisions. | * -BO decisions. | ||||
* > training workers | * > training workers | ||||
* > building stuff (though we'll send that to bases) | * > building stuff (though we'll send that to bases) | ||||
* -picking strategy (specific manager?) | * -picking strategy (specific manager?) | ||||
* -diplomacy -> diplomacyManager | * -diplomacy -> diplomacyManager | ||||
* -planning attacks -> attackManager | * -planning attacks -> attackManager | ||||
* -picking new CC locations. | * -picking new CC locations. | ||||
*/ | */ | ||||
PETRA.HQ = function(Config) | PETRA.HQ = function(Config, deserialized) | ||||
{ | { | ||||
this.Config = Config; | this.Config = Config; | ||||
this.phasing = 0; // existing values: 0 means no, i > 0 means phasing towards phase i | this.phasing = 0; // existing values: 0 means no, i > 0 means phasing towards phase i | ||||
// Cache various quantities. | // Cache various quantities. | ||||
this.turnCache = {}; | this.turnCache = {}; | ||||
this.lastFailedGather = {}; | this.lastFailedGather = {}; | ||||
Show All 14 Lines | PETRA.HQ = function(Config, deserialized) | ||||
this.baseManagers = []; | this.baseManagers = []; | ||||
this.attackManager = new PETRA.AttackManager(this.Config); | this.attackManager = new PETRA.AttackManager(this.Config); | ||||
this.buildManager = new PETRA.BuildManager(); | this.buildManager = new PETRA.BuildManager(); | ||||
this.defenseManager = new PETRA.DefenseManager(this.Config); | this.defenseManager = new PETRA.DefenseManager(this.Config); | ||||
this.tradeManager = new PETRA.TradeManager(this.Config); | this.tradeManager = new PETRA.TradeManager(this.Config); | ||||
this.navalManager = new PETRA.NavalManager(this.Config); | this.navalManager = new PETRA.NavalManager(this.Config); | ||||
this.researchManager = new PETRA.ResearchManager(this.Config); | this.researchManager = new PETRA.ResearchManager(this.Config); | ||||
this.diplomacyManager = new PETRA.DiplomacyManager(this.Config); | this.diplomacyManager = new PETRA.DiplomacyManager(this.Config, deserialized); | ||||
this.garrisonManager = new PETRA.GarrisonManager(this.Config); | this.garrisonManager = new PETRA.GarrisonManager(this.Config); | ||||
this.victoryManager = new PETRA.VictoryManager(this.Config); | this.victoryManager = new PETRA.VictoryManager(this.Config); | ||||
this.capturableTargets = new Map(); | this.capturableTargets = new Map(); | ||||
this.capturableTargetsTime = 0; | this.capturableTargetsTime = 0; | ||||
}; | }; | ||||
/** More initialisation for stuff that needs the gameState */ | /** More initialisation for stuff that needs the gameState */ | ||||
▲ Show 20 Lines • Show All 2,826 Lines • ▼ Show 20 Lines | PETRA.HQ.prototype.Deserialize = function(gameState, data) | ||||
this.tradeManager = new PETRA.TradeManager(this.Config); | this.tradeManager = new PETRA.TradeManager(this.Config); | ||||
this.tradeManager.init(gameState); | this.tradeManager.init(gameState); | ||||
this.tradeManager.Deserialize(gameState, data.tradeManager); | this.tradeManager.Deserialize(gameState, data.tradeManager); | ||||
this.researchManager = new PETRA.ResearchManager(this.Config); | this.researchManager = new PETRA.ResearchManager(this.Config); | ||||
this.researchManager.Deserialize(data.researchManager); | this.researchManager.Deserialize(data.researchManager); | ||||
this.diplomacyManager = new PETRA.DiplomacyManager(this.Config); | this.diplomacyManager = new PETRA.DiplomacyManager(this.Config, true); | ||||
this.diplomacyManager.Deserialize(data.diplomacyManager); | this.diplomacyManager.Deserialize(data.diplomacyManager); | ||||
this.garrisonManager = new PETRA.GarrisonManager(this.Config); | this.garrisonManager = new PETRA.GarrisonManager(this.Config); | ||||
this.garrisonManager.Deserialize(data.garrisonManager); | this.garrisonManager.Deserialize(data.garrisonManager); | ||||
this.victoryManager = new PETRA.VictoryManager(this.Config); | this.victoryManager = new PETRA.VictoryManager(this.Config); | ||||
this.victoryManager.Deserialize(data.victoryManager); | this.victoryManager.Deserialize(data.victoryManager); | ||||
}; | }; |
Wildfire Games · Phabricator