Ticket #2757: 2757.5.patch

File 2757.5.patch, 3.3 KB (added by maveric, 9 years ago)
  • binaries/data/mods/public/simulation/ai/petra/chatHelper.js

     
    106106    Engine.PostCommand(PlayerID, chat);
    107107};
    108108
     109m.chatNewPhase = function(gameState, phase, started)
     110{
     111    if (started)
     112        var message = "/allies " + markForTranslation("I am advancing to the %(phase)s.");
     113    else
     114        var message = "/allies " + markForTranslation("I have reached the %(phase)s.");
     115   
     116    var chat = {
     117        "type": "aichat",
     118        "message": message,
     119        "translateMessage": true,
     120        "translateParameters": ["phase"],
     121        "parameters": { "phase": phase }
     122    };
     123    Engine.PostCommand(PlayerID, chat);
     124};
     125
     126
    109127return m;
    110128}(PETRA);
  • binaries/data/mods/public/simulation/ai/petra/headquarters.js

     
    1919    this.Config = Config;
    2020   
    2121    this.econState = "growth";  // existing values: growth, townPhasing.
    22     this.phaseStarted = undefined;
     22    this.currentPhase = undefined;
    2323
    2424    // cache the rates.
    2525    this.wantedRates = { "food": 0, "wood": 0, "stone":0, "metal": 0 };
     
    7171        return false;
    7272    });
    7373    this.treasures.registerUpdates();
     74    this.currentPhase = gameState.currentPhase();
    7475};
    7576
    7677/**
     
    279280{
    280281    if (this.Config.difficulty > 2 && this.femaleRatio > 0.4)
    281282        this.femaleRatio = 0.4;
    282 
    283     this.phaseStarted = 2;
     283       
     284    var phaseName = gameState.getTemplate(gameState.townPhase()).name();
     285    m.chatNewPhase(gameState, phaseName, true);
    284286};
    285287
    286288// Called by the "city phase" research plan once it's started
     
    291293
    292294    // increase the priority of defense buildings to free this queue for our first fortress
    293295    gameState.ai.queueManager.changePriority("defenseBuilding", 2*this.Config.priorities.defenseBuilding);
    294 
    295     this.phaseStarted = 3;
     296   
     297    var phaseName = gameState.getTemplate(gameState.cityPhase()).name();   
     298    m.chatNewPhase(gameState, phaseName, true);
    296299};
    297300
    298301// This code trains females and citizen workers, trying to keep close to a ratio of females/CS
     
    17391742    this.researchManager.checkPhase(gameState, queues);
    17401743
    17411744    // TODO find a better way to update
    1742     if (this.phaseStarted && gameState.currentPhase() == this.phaseStarted)
     1745    if (this.currentPhase != gameState.currentPhase())
    17431746    {
    1744         this.phaseStarted = undefined;
     1747        this.currentPhase = gameState.currentPhase();
     1748        if (this.currentPhase == 2)
     1749            var phaseName = gameState.getTemplate(gameState.townPhase()).name();
     1750        else if (this.currentPhase == 3)
     1751            var phaseName = gameState.getTemplate(gameState.cityPhase()).name();
     1752           
     1753        m.chatNewPhase(gameState, phaseName, false);
    17451754        this.updateTerritories(gameState);
    17461755    }
    17471756    else if (gameState.ai.playedTurn - this.lastTerritoryUpdate > 100)
     
    18121821{
    18131822    let properties = {
    18141823        "econState": this.econState,
    1815         "phaseStarted": this.phaseStarted,
     1824        "currentPhase": this.currentPhase,
    18161825        "wantedRates": this.wantedRates,
    18171826        "currentRates": this.currentRates,
    18181827        "lastFailedGather": this.lastFailedGather,