Differential D1052 Diff 4414 ps/trunk/binaries/data/mods/public/simulation/components/StatisticsTracker.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/StatisticsTracker.js
Show All 10 Lines | this.unitsClasses = [ | ||||
"Infantry", | "Infantry", | ||||
"Worker", | "Worker", | ||||
"FemaleCitizen", | "FemaleCitizen", | ||||
"Cavalry", | "Cavalry", | ||||
"Champion", | "Champion", | ||||
"Hero", | "Hero", | ||||
"Siege", | "Siege", | ||||
"Ship", | "Ship", | ||||
"Domestic", | |||||
"Trader" | "Trader" | ||||
]; | ]; | ||||
this.unitsTrained = { | this.unitsTrained = { | ||||
"Infantry": 0, | "Infantry": 0, | ||||
"Worker": 0, | "Worker": 0, | ||||
"FemaleCitizen": 0, | "FemaleCitizen": 0, | ||||
"Cavalry": 0, | "Cavalry": 0, | ||||
"Champion": 0, | "Champion": 0, | ||||
"Hero": 0, | "Hero": 0, | ||||
"Siege": 0, | "Siege": 0, | ||||
"Ship": 0, | "Ship": 0, | ||||
"Trader": 0, | "Trader": 0, | ||||
"Domestic": 0, | |||||
"total": 0 | "total": 0 | ||||
}; | }; | ||||
this.domesticUnitsTrainedValue = 0; | |||||
this.unitsLost = { | this.unitsLost = { | ||||
"Infantry": 0, | "Infantry": 0, | ||||
"Worker": 0, | "Worker": 0, | ||||
"FemaleCitizen": 0, | "FemaleCitizen": 0, | ||||
"Cavalry": 0, | "Cavalry": 0, | ||||
"Champion": 0, | "Champion": 0, | ||||
"Hero": 0, | "Hero": 0, | ||||
"Siege": 0, | "Siege": 0, | ||||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | return { | ||||
"percentMapExplored": this.GetPercentMapExplored() | "percentMapExplored": this.GetPercentMapExplored() | ||||
}; | }; | ||||
}; | }; | ||||
StatisticsTracker.prototype.GetStatistics = function() | StatisticsTracker.prototype.GetStatistics = function() | ||||
{ | { | ||||
return { | return { | ||||
"unitsTrained": this.unitsTrained, | "unitsTrained": this.unitsTrained, | ||||
"domesticUnitsTrainedValue": this.domesticUnitsTrainedValue, | |||||
"unitsLost": this.unitsLost, | "unitsLost": this.unitsLost, | ||||
"unitsLostValue": this.unitsLostValue, | "unitsLostValue": this.unitsLostValue, | ||||
"enemyUnitsKilled": this.enemyUnitsKilled, | "enemyUnitsKilled": this.enemyUnitsKilled, | ||||
"enemyUnitsKilledValue": this.enemyUnitsKilledValue, | "enemyUnitsKilledValue": this.enemyUnitsKilledValue, | ||||
"unitsCaptured": this.unitsCaptured, | "unitsCaptured": this.unitsCaptured, | ||||
"unitsCapturedValue": this.unitsCapturedValue, | "unitsCapturedValue": this.unitsCapturedValue, | ||||
"buildingsConstructed": this.buildingsConstructed, | "buildingsConstructed": this.buildingsConstructed, | ||||
"buildingsLost": this.buildingsLost, | "buildingsLost": this.buildingsLost, | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | if (!cmpUnitEntityIdentity) | ||||
return; | return; | ||||
let cmpCost = Engine.QueryInterface(trainedUnit, IID_Cost); | let cmpCost = Engine.QueryInterface(trainedUnit, IID_Cost); | ||||
let costs = cmpCost && cmpCost.GetResourceCosts(); | let costs = cmpCost && cmpCost.GetResourceCosts(); | ||||
for (let type of this.unitsClasses) | for (let type of this.unitsClasses) | ||||
this.CounterIncrement(cmpUnitEntityIdentity, "unitsTrained", type); | this.CounterIncrement(cmpUnitEntityIdentity, "unitsTrained", type); | ||||
if (!cmpUnitEntityIdentity.HasClass("Domestic")) | |||||
++this.unitsTrained.total; | ++this.unitsTrained.total; | ||||
if (cmpUnitEntityIdentity.HasClass("Domestic") && costs) | if (cmpUnitEntityIdentity.HasClass("Domestic") && costs) | ||||
for (let type in costs) | { | ||||
this.domesticUnitsTrainedValue += costs[type]; | // Subtract costs for sheep/goats/pigs to get the net food gain/use for corralling | ||||
this.resourcesUsed.food -= costs.food; | |||||
this.resourcesGathered.food -= costs.food; | |||||
} | |||||
}; | }; | ||||
/** | /** | ||||
* Counts the total number of buildings constructed as well as an individual count for | * Counts the total number of buildings constructed as well as an individual count for | ||||
* each building type. Based on templates. | * each building type. Based on templates. | ||||
*/ | */ | ||||
StatisticsTracker.prototype.IncreaseConstructedBuildingsCounter = function(constructedBuilding) | StatisticsTracker.prototype.IncreaseConstructedBuildingsCounter = function(constructedBuilding) | ||||
▲ Show 20 Lines • Show All 299 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator