mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-18 06:13:55 -07:00
Fix economy and military score
Reviewed by: causative Differential Revision: https://code.wildfiregames.com/D494 This was SVN commit r19584.
This commit is contained in:
parent
1eae8d0a95
commit
202e567492
2 changed files with 17 additions and 2 deletions
|
|
@ -100,15 +100,20 @@ function calculateTeamCounters(playerState)
|
|||
function calculateEconomyScore(playerState, index)
|
||||
{
|
||||
let total = 0;
|
||||
for (let type in playerState.sequences.resourcesGathered)
|
||||
for (let type of g_ResourceData.GetCodes())
|
||||
total += playerState.sequences.resourcesGathered[type][index];
|
||||
|
||||
// Subtract costs for sheep/goats/pigs to get the net food gain for corralling
|
||||
total -= playerState.sequences.domesticUnitsTrainedValue[index];
|
||||
|
||||
total += playerState.sequences.tradeIncome[index];
|
||||
return Math.round(total / 10);
|
||||
}
|
||||
|
||||
function calculateMilitaryScore(playerState, index)
|
||||
{
|
||||
return Math.round((playerState.sequences.enemyUnitsKilledValue[index] +
|
||||
playerState.sequences.unitsCapturedValue[index] +
|
||||
playerState.sequences.enemyBuildingsDestroyedValue[index] +
|
||||
playerState.sequences.buildingsCapturedValue[index]) / 10);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ StatisticsTracker.prototype.Init = function()
|
|||
"Trader": 0,
|
||||
"total": 0
|
||||
};
|
||||
this.domesticUnitsTrainedValue = 0;
|
||||
this.unitsLost = {
|
||||
"Infantry": 0,
|
||||
"Worker": 0,
|
||||
|
|
@ -170,6 +171,7 @@ StatisticsTracker.prototype.GetStatistics = function()
|
|||
{
|
||||
return {
|
||||
"unitsTrained": this.unitsTrained,
|
||||
"domesticUnitsTrainedValue": this.domesticUnitsTrainedValue,
|
||||
"unitsLost": this.unitsLost,
|
||||
"unitsLostValue": this.unitsLostValue,
|
||||
"enemyUnitsKilled": this.enemyUnitsKilled,
|
||||
|
|
@ -236,15 +238,23 @@ StatisticsTracker.prototype.CounterIncrement = function(cmpIdentity, counter, ty
|
|||
*/
|
||||
StatisticsTracker.prototype.IncreaseTrainedUnitsCounter = function(trainedUnit)
|
||||
{
|
||||
var cmpUnitEntityIdentity = Engine.QueryInterface(trainedUnit, IID_Identity);
|
||||
let cmpUnitEntityIdentity = Engine.QueryInterface(trainedUnit, IID_Identity);
|
||||
|
||||
if (!cmpUnitEntityIdentity)
|
||||
return;
|
||||
|
||||
let cmpCost = Engine.QueryInterface(trainedUnit, IID_Cost);
|
||||
let costs = cmpCost && cmpCost.GetResourceCosts();
|
||||
|
||||
for (let type of this.unitsClasses)
|
||||
this.CounterIncrement(cmpUnitEntityIdentity, "unitsTrained", type);
|
||||
|
||||
++this.unitsTrained.total;
|
||||
|
||||
if (cmpUnitEntityIdentity.HasClass("Domestic") && costs)
|
||||
for (let type in costs)
|
||||
this.domesticUnitsTrainedValue += costs[type];
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue