1
0
forked from 0ad/0ad

Count Trained Cattle as resource and not as unit. Also only count the net amount of gathered/used food for cattle.

Reviewed by: temple
Fixes: #3948
Differential Revision: https://code.wildfiregames.com/D1052
This was SVN commit r20543.
This commit is contained in:
Imarok 2017-11-27 19:47:45 +00:00
parent aec1ff5493
commit 215a102c27
3 changed files with 20 additions and 12 deletions

View File

@ -126,9 +126,6 @@ function calculateEconomyScore(playerState, index)
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);
}
@ -244,6 +241,11 @@ function calculateTributeSent(playerState, index)
};
}
function calculateLivestockTrained(playerState, index)
{
return playerState.sequences.unitsTrained.Domestic[index];
}
function calculateResourcesTeam(team, index, type, counters, headings)
{
return summaryArraySum(getPlayerValuesPerTeam(team, index, type, counters, headings));

View File

@ -116,8 +116,9 @@ var getScorePanelsData = () => ({
"yStart": 16,
"width": 121
},
{ "identifier": "treasuresCollected", "caption": translate("Treasures collected"), "yStart": 16, "width": 100 },
{ "identifier": "loot", "caption": translate("Loot"), "yStart": 16, "width": 100 }
{ "identifier": "treasuresCollected", "caption": translate("Treasures collected"), "yStart": 16, "width": 85 },
{ "identifier": "loot", "caption": translate("Loot"), "yStart": 16, "width": 85 },
{ "identifier": "livestock", "caption": translate("Livestock bred"), "yStart": 16, "width": 85 }
],
"titleHeadings": [
{
@ -138,8 +139,9 @@ var getScorePanelsData = () => ({
"width": 100
})),
{ "width": 121, "fn": calculateTributeSent, "verticalOffset": 12 },
{ "width": 100, "fn": calculateTreasureCollected, "verticalOffset": 12 },
{ "width": 100, "fn": calculateLootCollected, "verticalOffset": 12 }
{ "width": 85, "fn": calculateTreasureCollected, "verticalOffset": 12 },
{ "width": 85, "fn": calculateLootCollected, "verticalOffset": 12 },
{ "width": 85, "fn": calculateLivestockTrained, "verticalOffset": 12 }
],
"teamCounterFn": calculateResourcesTeam
},

View File

@ -16,6 +16,7 @@ StatisticsTracker.prototype.Init = function()
"Hero",
"Siege",
"Ship",
"Domestic",
"Trader"
];
this.unitsTrained = {
@ -28,9 +29,9 @@ StatisticsTracker.prototype.Init = function()
"Siege": 0,
"Ship": 0,
"Trader": 0,
"Domestic": 0,
"total": 0
};
this.domesticUnitsTrainedValue = 0;
this.unitsLost = {
"Infantry": 0,
"Worker": 0,
@ -179,7 +180,6 @@ StatisticsTracker.prototype.GetStatistics = function()
{
return {
"unitsTrained": this.unitsTrained,
"domesticUnitsTrainedValue": this.domesticUnitsTrainedValue,
"unitsLost": this.unitsLost,
"unitsLostValue": this.unitsLostValue,
"enemyUnitsKilled": this.enemyUnitsKilled,
@ -273,11 +273,15 @@ StatisticsTracker.prototype.IncreaseTrainedUnitsCounter = function(trainedUnit)
for (let type of this.unitsClasses)
this.CounterIncrement(cmpUnitEntityIdentity, "unitsTrained", type);
if (!cmpUnitEntityIdentity.HasClass("Domestic"))
++this.unitsTrained.total;
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;
}
};