Differential D3395 Diff 15560 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 First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | return { | ||||
"unitsCapturedValue": this.unitsCapturedValue, | "unitsCapturedValue": this.unitsCapturedValue, | ||||
"buildingsConstructed": this.buildingsConstructed, | "buildingsConstructed": this.buildingsConstructed, | ||||
"buildingsLost": this.buildingsLost, | "buildingsLost": this.buildingsLost, | ||||
"buildingsLostValue": this.buildingsLostValue, | "buildingsLostValue": this.buildingsLostValue, | ||||
"enemyBuildingsDestroyed": this.enemyBuildingsDestroyed, | "enemyBuildingsDestroyed": this.enemyBuildingsDestroyed, | ||||
"enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue, | "enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue, | ||||
"buildingsCaptured": this.buildingsCaptured, | "buildingsCaptured": this.buildingsCaptured, | ||||
"buildingsCapturedValue": this.buildingsCapturedValue, | "buildingsCapturedValue": this.buildingsCapturedValue, | ||||
"resourcesCount": this.GetResourceCounts(), | |||||
"resourcesGathered": this.resourcesGathered, | "resourcesGathered": this.resourcesGathered, | ||||
"resourcesUsed": this.resourcesUsed, | "resourcesUsed": this.resourcesUsed, | ||||
"resourcesSold": this.resourcesSold, | "resourcesSold": this.resourcesSold, | ||||
"resourcesBought": this.resourcesBought, | "resourcesBought": this.resourcesBought, | ||||
"tributesSent": this.tributesSent, | "tributesSent": this.tributesSent, | ||||
"tributesReceived": this.tributesReceived, | "tributesReceived": this.tributesReceived, | ||||
"tradeIncome": this.tradeIncome, | "tradeIncome": this.tradeIncome, | ||||
"treasuresCollected": this.treasuresCollected, | "treasuresCollected": this.treasuresCollected, | ||||
"lootCollected": this.lootCollected, | "lootCollected": this.lootCollected, | ||||
"populationCount": this.GetPopulationCount(), | |||||
"percentMapExplored": this.GetPercentMapExplored(), | "percentMapExplored": this.GetPercentMapExplored(), | ||||
"teamPercentMapExplored": this.GetTeamPercentMapExplored(), | "teamPercentMapExplored": this.GetTeamPercentMapExplored(), | ||||
"percentMapControlled": this.GetPercentMapControlled(), | "percentMapControlled": this.GetPercentMapControlled(), | ||||
"teamPercentMapControlled": this.GetTeamPercentMapControlled(), | "teamPercentMapControlled": this.GetTeamPercentMapControlled(), | ||||
"peakPercentMapControlled": this.peakPercentMapControlled, | "peakPercentMapControlled": this.peakPercentMapControlled, | ||||
"teamPeakPercentMapControlled": this.teamPeakPercentMapControlled, | "teamPeakPercentMapControlled": this.teamPeakPercentMapControlled, | ||||
"successfulBribes": this.successfulBribes, | "successfulBribes": this.successfulBribes, | ||||
"failedBribes": this.failedBribes | "failedBribes": this.failedBribes | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | if (cmpCapturedEntityIdentity.HasClass("Structure")) | ||||
if (costs) | if (costs) | ||||
for (let type in costs) | for (let type in costs) | ||||
this.buildingsCapturedValue += costs[type]; | this.buildingsCapturedValue += costs[type]; | ||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
* @return {Object} - The amount of available resources. | |||||
*/ | |||||
StatisticsTracker.prototype.GetResourceCounts = function() | |||||
{ | |||||
let cmpPlayer = Engine.QueryInterface(this.entity, IID_Player); | |||||
return cmpPlayer ? | |||||
cmpPlayer.GetResourceCounts() : | |||||
Object.fromEntries(Resources.GetCodes().map(res => [res, 0])); | |||||
}; | |||||
/** | |||||
* @param {string} type - generic type of resource. | * @param {string} type - generic type of resource. | ||||
* @param {number} amount - amount of resource, whick should be added. | * @param {number} amount - amount of resource, whick should be added. | ||||
* @param {string} specificType - specific type of resource. | * @param {string} specificType - specific type of resource. | ||||
*/ | */ | ||||
StatisticsTracker.prototype.IncreaseResourceGatheredCounter = function(type, amount, specificType) | StatisticsTracker.prototype.IncreaseResourceGatheredCounter = function(type, amount, specificType) | ||||
{ | { | ||||
this.resourcesGathered[type] += amount; | this.resourcesGathered[type] += amount; | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | StatisticsTracker.prototype.IncreaseTributesReceivedCounter = function(amount) | ||||
this.tributesReceived += amount; | this.tributesReceived += amount; | ||||
}; | }; | ||||
StatisticsTracker.prototype.IncreaseTradeIncomeCounter = function(amount) | StatisticsTracker.prototype.IncreaseTradeIncomeCounter = function(amount) | ||||
{ | { | ||||
this.tradeIncome += amount; | this.tradeIncome += amount; | ||||
}; | }; | ||||
StatisticsTracker.prototype.GetPopulationCount = function() | |||||
{ | |||||
let cmpPlayer = Engine.QueryInterface(this.entity, IID_Player); | |||||
return cmpPlayer ? cmpPlayer.GetPopulationCount() : 0; | |||||
}; | |||||
StatisticsTracker.prototype.IncreaseSuccessfulBribesCounter = function() | StatisticsTracker.prototype.IncreaseSuccessfulBribesCounter = function() | ||||
{ | { | ||||
++this.successfulBribes; | ++this.successfulBribes; | ||||
}; | }; | ||||
StatisticsTracker.prototype.IncreaseFailedBribesCounter = function() | StatisticsTracker.prototype.IncreaseFailedBribesCounter = function() | ||||
{ | { | ||||
++this.failedBribes; | ++this.failedBribes; | ||||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator