Ticket #2757: 2757.4.patch
File 2757.4.patch, 3.7 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/simulation/ai/petra/chatHelper.js
106 106 Engine.PostCommand(PlayerID, chat); 107 107 }; 108 108 109 m.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 109 127 return m; 110 128 }(PETRA); -
binaries/data/mods/public/simulation/ai/petra/headquarters.js
19 19 this.Config = Config; 20 20 21 21 this.econState = "growth"; // existing values: growth, townPhasing. 22 this. phaseStarted= undefined;22 this.currentPhase = undefined; 23 23 24 24 // cache the rates. 25 25 this.wantedRates = { "food": 0, "wood": 0, "stone":0, "metal": 0 }; … … 71 71 return false; 72 72 }); 73 73 this.treasures.registerUpdates(); 74 this.currentPhase = gameState.currentPhase(); 74 75 }; 75 76 76 77 /** … … 279 280 { 280 281 if (this.Config.difficulty > 2 && this.femaleRatio > 0.4) 281 282 this.femaleRatio = 0.4; 282 283 this.phaseStarted = 2; 283 284 var phaseName = gameState.getTemplate(gameState.townPhase()).name(); 285 m.chatNewPhase(gameState, phaseName, true); 284 286 }; 285 287 286 288 // Called by the "city phase" research plan once it's started … … 288 290 { 289 291 if (this.Config.difficulty > 2 && this.femaleRatio > 0.3) 290 292 this.femaleRatio = 0.3; 291 292 this.phaseStarted = 3; 293 294 var phaseName = gameState.getTemplate(gameState.cityPhase()).name(); 295 m.chatNewPhase(gameState, phaseName, true); 293 296 }; 294 297 295 298 // This code trains females and citizen workers, trying to keep close to a ratio of females/CS … … 1722 1725 m.HQ.prototype.update = function(gameState, queues, events) 1723 1726 { 1724 1727 Engine.ProfileStart("Headquarters update"); 1728 1729 if (this.currentPhase != gameState.currentPhase()) 1730 { 1731 this.currentPhase = gameState.currentPhase(); 1732 1733 if (this.currentPhase == 2) 1734 { 1735 var phaseName = gameState.getTemplate(gameState.townPhase()).name(); 1736 m.chatNewPhase(gameState, phaseName, false); 1737 } 1738 else if (this.currentPhase == 3) 1739 { 1740 var phaseName = gameState.getTemplate(gameState.cityPhase()).name(); 1741 m.chatNewPhase(gameState, phaseName, false); 1742 } 1743 this.updateTerritories(gameState); 1744 } 1745 else if (gameState.ai.playedTurn - this.lastTerritoryUpdate > 100) 1746 this.updateTerritories(gameState); 1725 1747 1726 1748 this.territoryMap = m.createTerritoryMap(gameState); 1727 1749 … … 1751 1773 1752 1774 this.researchManager.checkPhase(gameState, queues); 1753 1775 1754 // TODO find a better way to update1755 if (this.phaseStarted && gameState.currentPhase() == this.phaseStarted)1756 {1757 this.phaseStarted = undefined;1758 this.updateTerritories(gameState);1759 }1760 else if (gameState.ai.playedTurn - this.lastTerritoryUpdate > 100)1761 this.updateTerritories(gameState);1762 1763 1776 if (gameState.getGameType() === "wonder") 1764 1777 this.buildWonder(gameState, queues); 1765 1778 … … 1825 1838 { 1826 1839 let properties = { 1827 1840 "econState": this.econState, 1828 " phaseStarted": this.phaseStarted,1841 "currentPhase": this.currentPhase, 1829 1842 "wantedRates": this.wantedRates, 1830 1843 "currentRates": this.currentRates, 1831 1844 "lastFailedGather": this.lastFailedGather,