Ticket #3818: costroundinthesim.diff
File costroundinthesim.diff, 4.7 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/globalscripts/Templates.js
function GetTemplateDataHelper(template, 188 188 }; 189 189 190 190 if (template.Cost) 191 191 { 192 192 ret.cost = {}; 193 if (template.Cost.Resources.food) 194 ret.cost.food = getEntityValue("Cost/Resources/food"); 195 196 if (template.Cost.Resources.wood) 197 ret.cost.wood = getEntityValue("Cost/Resources/wood"); 198 199 if (template.Cost.Resources.stone) 200 ret.cost.stone = getEntityValue("Cost/Resources/stone"); 201 202 if (template.Cost.Resources.metal) 203 ret.cost.metal = getEntityValue("Cost/Resources/metal"); 193 for (let r in template.Cost.Resources) 194 ret.cost[r] = Math.round(getEntityValue("Cost/Resources/"+r)); 204 195 205 196 if (template.Cost.Population) 206 197 ret.cost.population = getEntityValue("Cost/Population"); 207 198 208 199 if (template.Cost.PopulationBonus) -
binaries/data/mods/public/gui/common/tooltips.js
function getBuildRateTooltip(template) 312 312 */ 313 313 function multiplyEntityCosts(template, trainNum) 314 314 { 315 315 let totalCosts = {}; 316 316 for (let r in template.cost) 317 totalCosts[r] = Math.floor(template.cost[r] * trainNum);317 totalCosts[r] = template.cost[r] * trainNum; 318 318 319 319 return totalCosts; 320 320 } 321 321 322 322 /** -
binaries/data/mods/public/simulation/ai/common-api/entity.js
m.Template = m.Class({ 107 107 if (!this.get("Cost")) 108 108 return undefined; 109 109 110 110 let ret = {}; 111 111 for (let type in this.get("Cost/Resources")) 112 ret[type] = +this.get("Cost/Resources/" + type);112 ret[type] = Math.round(+this.get("Cost/Resources/" + type)); 113 113 return ret; 114 114 }, 115 115 116 116 "costSum": function(productionQueue) { 117 117 let cost = this.cost(productionQueue); -
binaries/data/mods/public/simulation/components/Cost.js
Cost.prototype.GetResourceCosts = functi 58 58 { 59 59 if (!owner) 60 60 { 61 61 let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 62 62 if (!cmpOwnership) 63 error("GetResourceCost called without valid ownership");63 error("GetResourceCosts called without valid ownership"); 64 64 else 65 65 owner = cmpOwnership.GetOwner(); 66 66 } 67 67 68 68 let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); 69 69 let entityTemplateName = cmpTemplateManager.GetCurrentTemplateName(this.entity); 70 70 let entityTemplate = cmpTemplateManager.GetTemplate(entityTemplateName); 71 71 72 72 let costs = {}; 73 73 for (let r in this.template.Resources) 74 costs[r] = ApplyValueModificationsToTemplate("Cost/Resources/"+r, +this.template.Resources[r], owner, entityTemplate);74 costs[r] = Math.round(ApplyValueModificationsToTemplate("Cost/Resources/"+r, +this.template.Resources[r], owner, entityTemplate)); 75 75 return costs; 76 76 }; 77 77 78 78 Cost.prototype.OnOwnershipChanged = function(msg) 79 79 { -
binaries/data/mods/public/simulation/components/ProductionQueue.js
ProductionQueue.prototype.AddBatch = fun 293 293 var buildTime = ApplyValueModificationsToTemplate("Cost/BuildTime", +template.Cost.BuildTime, cmpPlayer.GetPlayerID(), template); 294 294 var time = timeMult * buildTime; 295 295 296 296 for (var r in template.Cost.Resources) 297 297 { 298 costs[r] = ApplyValueModificationsToTemplate("Cost/Resources/"+r, +template.Cost.Resources[r], cmpPlayer.GetPlayerID(), template);299 totalCosts[r] = Math.floor(count * costs[r]);298 costs[r] = Math.round(ApplyValueModificationsToTemplate("Cost/Resources/"+r, +template.Cost.Resources[r], cmpPlayer.GetPlayerID(), template)); 299 totalCosts[r] = count * costs[r]; 300 300 } 301 302 301 var population = ApplyValueModificationsToTemplate("Cost/Population", +template.Cost.Population, cmpPlayer.GetPlayerID(), template); 303 302 304 303 // TrySubtractResources should report error to player (they ran out of resources) 305 304 if (!cmpPlayer.TrySubtractResources(totalCosts)) 306 305 return;