Ticket #3311: ticket3311.patch

File ticket3311.patch, 26.2 KB (added by bb, 9 years ago)

complete patch for this ticket

  • binaries/data/mods/public/gui/session/session.js

     
    912912        "Cavalry",
    913913        "Champion",
    914914        "Hero",
    915         "Ship"
     915        "Ship",
     916        "Trader"
    916917    ];
    917918    var unitsCountersTypes = [
    918919        "unitsTrained",
     
    993994    playerStatistics.totalScore = "";
    994995    // Various
    995996    playerStatistics.treasuresCollected = "";
     997    playerStatistics.lootCollected = "";
    996998    playerStatistics.feminisation = "";
    997999    playerStatistics.percentMapExplored = "";
    9981000    var mapName = Engine.GetMapSettings().Name;
     
    10361038        playerStatistics.tributesReceived += player.statistics.tributesReceived + ",";
    10371039        playerStatistics.percentMapExplored += player.statistics.percentMapExplored + ",";
    10381040        playerStatistics.treasuresCollected += player.statistics.treasuresCollected + ",";
     1041        playerStatistics.lootCollected += player.statistics.lootCollected + ",";
    10391042    }
    10401043
    10411044    // Send the report with serialized data
     
    10771080    reportObject.tributesReceived = playerStatistics.tributesReceived;
    10781081    reportObject.percentMapExplored = playerStatistics.percentMapExplored;
    10791082    reportObject.treasuresCollected = playerStatistics.treasuresCollected;
     1083    reportObject.lootCollected = playerStatistics.lootCollected;
    10801084    reportObject.tradeIncome = playerStatistics.tradeIncome;
    10811085
    10821086    Engine.SendGameReport(reportObject);
  • binaries/data/mods/public/gui/summary/counters.js

     
    136136    return playerState.statistics.treasuresCollected;
    137137}
    138138
     139function calculateLootCollected(playerState, position)
     140{
     141    return playerState.statistics.lootCollected;
     142}
     143
    139144function calculateTributeSent(playerState, position)
    140145{
    141146    return INCOME_COLOR + playerState.statistics.tributesSent + "[/color] / " + OUTCOME_COLOR + playerState.statistics.tributesReceived + "[/color]";
  • binaries/data/mods/public/gui/summary/layout.js

     
    2929            { "caption": translate("Wonders"), "yStart": 34, "width": 85 }
    3030        ],
    3131        "titleHeadings": [
    32             { "caption": translate("Buildings Statistics (Constructed / Lost / Destroyed)"), "yStart": 16, "width": (85 * 7 + 105) },   // width = 735
     32            { "caption": translate("Buildings Statistics (Constructed / Lost / Destroyed)"), "yStart": 16, "width": (85 * 7 + 105) },   // width = 700
    3333        ],
    3434        "counters": [   // counters on buildings panel
    3535            {"width": 105, "fn": calculateBuildings},
     
    5252            { "caption": translate("Cavalry"), "yStart": 34, "width": 100 },
    5353            { "caption": translate("Champion"), "yStart": 34, "width": 100 },
    5454            { "caption": translate("Heroes"), "yStart": 34, "width": 100 },
    55             { "caption": translate("Navy"), "yStart": 34, "width": 100 }
     55            { "caption": translate("Navy"), "yStart": 34, "width": 100 },
     56            { "caption": translate("Traders"), "yStart": 34, "width": 100 }
    5657        ],
    5758        "titleHeadings": [
    58             { "caption": translate("Units Statistics (Trained / Lost / Killed)"), "yStart": 16, "width": (100 * 6 + 120) }, // width = 720
     59            { "caption": translate("Units Statistics (Trained / Lost / Killed)"), "yStart": 16, "width": (100 * 7 + 120) }, // width = 820
    5960        ],
    6061        "counters": [   // counters on units panel
    6162            {"width": 120, "fn": calculateUnits},
     
    6465            {"width": 100, "fn": calculateUnits},
    6566            {"width": 100, "fn": calculateUnits},
    6667            {"width": 100, "fn": calculateUnits},
     68            {"width": 100, "fn": calculateUnits},
    6769            {"width": 100, "fn": calculateUnits}
    6870        ],
    6971        "teamCounterFn": calculateColorsTeam
     
    7779            { "caption": translate("Metal"), "yStart": 34, "width": 100 },
    7880            { "caption": translate("Total"), "yStart": 34, "width": 110 },
    7981            { "caption": translate("Treasures collected"), "yStart": 16, "width": 100 },
     82            { "caption": translate("Looted"), "yStart": 16, "width": 100 },
    8083            { "caption": translate("Tributes (Sent / Received)"), "yStart": 16, "width": 121 }
    8184        ],
    8285        "titleHeadings": [
     
    8891            {"width": 100, "fn": calculateResources},
    8992            {"width": 100, "fn": calculateResources},
    9093            {"width": 110, "fn": calculateTotalResources},
    91             {"width": 100, "fn": calculateTreasureCollected},
     94            {"width": 100, "fn": calculateTreasureCollected},
     95            {"width": 100, "fn": calculateLootCollected},
    9296            {"width": 121, "fn": calculateTributeSent}
    9397        ],
    9498        "teamCounterFn": calculateResourcesTeam
  • binaries/data/mods/public/gui/summary/summary.js

     
    2121const KILLED_COLOR = '[color="196 198 255"]';
    2222
    2323const BUILDINGS_TYPES = [ "total", "House", "Economic", "Outpost", "Military", "Fortress", "CivCentre", "Wonder" ];
    24 const UNITS_TYPES = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship" ];
     24const UNITS_TYPES = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship", "Trader" ];
    2525const RESOURCES_TYPES = [ "food", "wood", "stone", "metal" ];
    2626
    2727// Colors used for gathered and traded resources
  • binaries/data/mods/public/simulation/components/Looter.js

     
    2727    }
    2828    cmpPlayer.AddResources(resources);
    2929
     30    let cmpStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker);
     31    if (cmpStatisticsTracker)
     32        cmpStatisticsTracker.IncreaseLootCollectedCounter(resources);
     33
    3034    // If target entity has trader component, add carried goods to loot too
    3135    var cmpTrader = Engine.QueryInterface(targetEntity, IID_Trader);
    3236    if (cmpTrader)
     
    4246            if (carriedGoods.amount.market2Gain)
    4347                resourcesToAdd[carriedGoods.type] += carriedGoods.amount.market2Gain;
    4448            cmpPlayer.AddResources(resourcesToAdd);
     49           
     50            let cmpStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker);
     51            if (cmpStatisticsTracker)
     52                cmpStatisticsTracker.IncreaseLootCollectedCounter(resourcesToAdd);
    4553        }
    4654    }
    4755}
  • binaries/data/mods/public/simulation/components/StatisticsTracker.js

     
    33StatisticsTracker.prototype.Schema =
    44    "<a:component type='system'/><empty/>";
    55
    6 StatisticsTracker.prototype.Init = function()
    7 {
    8     // units
    9     this.unitsClasses = [
    10         "Infantry",
    11         "Worker",
    12         "Female",
    13         "Cavalry",
    14         "Champion",
    15         "Hero",
    16         "Ship"
    17     ]; 
    18     this.unitsTrained = {
    19         "Infantry": 0,
    20         "Worker": 0,
    21         "Female": 0,
    22         "Cavalry": 0,
    23         "Champion": 0,
    24         "Hero": 0,
    25         "Ship": 0,
    26         "total": 0
    27     };
    28     this.unitsLost = {
    29         "Infantry": 0,
    30         "Worker": 0,
    31         "Female": 0,
    32         "Cavalry": 0,
    33         "Champion": 0,
    34         "Hero": 0,
    35         "Ship": 0,
    36         "total": 0
    37     };
    38     this.unitsLostValue = 0;
    39     this.enemyUnitsKilled = {
    40         "Infantry": 0,
    41         "Worker": 0,
    42         "Female": 0,
    43         "Cavalry": 0,
    44         "Champion": 0,
    45         "Hero": 0,
    46         "Ship": 0,
    47         "total": 0
    48     };
    49     this.enemyUnitsKilledValue = 0;
    50     // buildings
    51     this.buildingsClasses = [
    52         "House",
    53         "Economic",
    54         "Outpost",
    55         "Military",
    56         "Fortress",
    57         "CivCentre",
    58         "Wonder"
    59     ];
    60     this.buildingsConstructed = {
    61         "House": 0,
    62         "Economic": 0,
    63         "Outpost": 0,
    64         "Military": 0,
    65         "Fortress": 0,
    66         "CivCentre": 0,
    67         "Wonder": 0,
    68         "total": 0 
    69     };
    70     this.buildingsLost = {
    71         "House": 0,
    72         "Economic": 0,
    73         "Outpost": 0,
    74         "Military": 0,
    75         "Fortress": 0,
    76         "CivCentre": 0,
    77         "Wonder": 0,
    78         "total": 0
    79         };
    80     this.buildingsLostValue = 0;
    81     this.enemyBuildingsDestroyed = {
    82         "House": 0,
    83         "Economic": 0,
    84         "Outpost": 0,
    85         "Military": 0,
    86         "Fortress": 0,
    87         "CivCentre": 0,
    88         "Wonder": 0,
    89         "total": 0
    90         };
    91     this.enemyBuildingsDestroyedValue = 0;
    92     // resources
    93     this.resourcesGathered = {
    94         "food": 0,
    95         "wood": 0,
    96         "metal": 0,
    97         "stone": 0,
    98         "vegetarianFood": 0
    99     };
    100     this.resourcesUsed = {
    101         "food": 0,
    102         "wood": 0,
    103         "metal": 0,
    104         "stone": 0
    105     };
    106     this.resourcesSold = {
    107         "food": 0,
    108         "wood": 0,
    109         "metal": 0,
    110         "stone": 0
    111     };
    112     this.resourcesBought = {
    113         "food": 0,
    114         "wood": 0,
    115         "metal": 0,
    116         "stone": 0
    117     };
    118     this.tributesSent = 0;
    119     this.tributesReceived = 0;
     6StatisticsTracker.prototype.Init = function()
     7{
     8    // units
     9    this.unitsClasses = [
     10        "Infantry",
     11        "Worker",
     12        "Female",
     13        "Cavalry",
     14        "Champion",
     15        "Hero",
     16        "Ship",
     17        "Trader"
     18    ]; 
     19    this.unitsTrained = {
     20        "Infantry": 0,
     21        "Worker": 0,
     22        "Female": 0,
     23        "Cavalry": 0,
     24        "Champion": 0,
     25        "Hero": 0,
     26        "Ship": 0,
     27        "Trader": 0,
     28        "total": 0
     29    };
     30    this.unitsLost = {
     31        "Infantry": 0,
     32        "Worker": 0,
     33        "Female": 0,
     34        "Cavalry": 0,
     35        "Champion": 0,
     36        "Hero": 0,
     37        "Ship": 0,
     38        "Trader": 0,
     39        "total": 0
     40    };
     41    this.unitsLostValue = 0;
     42    this.enemyUnitsKilled = {
     43        "Infantry": 0,
     44        "Worker": 0,
     45        "Female": 0,
     46        "Cavalry": 0,
     47        "Champion": 0,
     48        "Hero": 0,
     49        "Ship": 0,
     50        "Trader": 0,
     51        "total": 0
     52    };
     53    this.enemyUnitsKilledValue = 0;
     54    // buildings
     55    this.buildingsClasses = [
     56        "House",
     57        "Economic",
     58        "Outpost",
     59        "Military",
     60        "Fortress",
     61        "CivCentre",
     62        "Wonder"
     63    ];
     64    this.buildingsConstructed = {
     65        "House": 0,
     66        "Economic": 0,
     67        "Outpost": 0,
     68        "Military": 0,
     69        "Fortress": 0,
     70        "CivCentre": 0,
     71        "Wonder": 0,
     72        "total": 0 
     73    };
     74    this.buildingsLost = {
     75        "House": 0,
     76        "Economic": 0,
     77        "Outpost": 0,
     78        "Military": 0,
     79        "Fortress": 0,
     80        "CivCentre": 0,
     81        "Wonder": 0,
     82        "total": 0
     83        };
     84    this.buildingsLostValue = 0;
     85    this.enemyBuildingsDestroyed = {
     86        "House": 0,
     87        "Economic": 0,
     88        "Outpost": 0,
     89        "Military": 0,
     90        "Fortress": 0,
     91        "CivCentre": 0,
     92        "Wonder": 0,
     93        "total": 0
     94        };
     95    this.enemyBuildingsDestroyedValue = 0;
     96    // resources
     97    this.resourcesGathered = {
     98        "food": 0,
     99        "wood": 0,
     100        "metal": 0,
     101        "stone": 0,
     102        "vegetarianFood": 0
     103    };
     104    this.resourcesUsed = {
     105        "food": 0,
     106        "wood": 0,
     107        "metal": 0,
     108        "stone": 0
     109    };
     110    this.resourcesSold = {
     111        "food": 0,
     112        "wood": 0,
     113        "metal": 0,
     114        "stone": 0
     115    };
     116    this.resourcesBought = {
     117        "food": 0,
     118        "wood": 0,
     119        "metal": 0,
     120        "stone": 0
     121    };
     122    this.tributesSent = 0;
     123    this.tributesReceived = 0;
    120124    this.tradeIncome = 0;
    121125    this.treasuresCollected = 0;
     126    this.lootCollected = 0;
    122127};
    123128
    124129/**
     
    147152        "enemyUnitsKilledValue": this.enemyUnitsKilledValue,
    148153        "buildingsConstructed": this.buildingsConstructed,
    149154        "buildingsLost": this.buildingsLost,
    150         "buildingsLostValue": this.buildingsLostValue,
    151         "enemyBuildingsDestroyed": this.enemyBuildingsDestroyed,
    152         "enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue,
    153         "resourcesGathered": this.resourcesGathered,
    154         "resourcesUsed": this.resourcesUsed,
    155         "resourcesSold": this.resourcesSold,
     155        "buildingsLostValue": this.buildingsLostValue,
     156        "enemyBuildingsDestroyed": this.enemyBuildingsDestroyed,
     157        "enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue,
     158        "resourcesGathered": this.resourcesGathered,
     159        "resourcesUsed": this.resourcesUsed,
     160        "resourcesSold": this.resourcesSold,
    156161        "resourcesBought": this.resourcesBought,
    157162        "tributesSent": this.tributesSent,
    158163        "tributesReceived": this.tributesReceived,
    159164        "tradeIncome": this.tradeIncome,
    160165        "treasuresCollected": this.treasuresCollected,
     166        "lootCollected": this.lootCollected,
    161167        "percentMapExplored": this.GetPercentMapExplored(),
    162168        "teamPercentMapExplored": this.GetTeamPercentMapExplored()
    163     };
    164 };
    165 
    166 /**
    167  * Increments counter associated with certain entity/counter and type of given entity.
    168  * @param cmpIdentity The entity identity component
    169  * @param counter The name of the counter to increment (e.g. "unitsTrained")
    170  * @param type The type of the counter (e.g. "workers")
    171  */
    172 StatisticsTracker.prototype.CounterIncrement = function(cmpIdentity, counter, type)
    173 {
    174     var classes = cmpIdentity.GetClassesList();
    175     if (!classes)
    176         return;
    177     if (classes.indexOf(type) != -1)
    178         this[counter][type]++;
    179 };
    180 
    181 /**
    182  * Counts the total number of units trained as well as an individual count for
    183  * each unit type. Based on templates.
    184  * @param trainedUnit The unit that has been trained
    185  */
    186 StatisticsTracker.prototype.IncreaseTrainedUnitsCounter = function(trainedUnit)
    187 {
    188     var cmpUnitEntityIdentity = Engine.QueryInterface(trainedUnit, IID_Identity);
    189 
    190     if (!cmpUnitEntityIdentity)
    191         return;
    192 
    193     for each (var type in this.unitsClasses)
    194         this.CounterIncrement(cmpUnitEntityIdentity, "unitsTrained", type);
    195 
    196     this.unitsTrained.total++;
    197 };
    198 
    199 /**
    200  * Counts the total number of buildings constructed as well as an individual count for
    201  * each building type. Based on templates.
    202  * @param constructedBuilding The building that has been constructed
    203  */
    204 StatisticsTracker.prototype.IncreaseConstructedBuildingsCounter = function(constructedBuilding)
    205 {
    206     var cmpBuildingEntityIdentity = Engine.QueryInterface(constructedBuilding, IID_Identity);
    207        
    208     if (!cmpBuildingEntityIdentity)
    209         return;
    210 
    211     for each(var type in this.buildingsClasses)
    212         this.CounterIncrement(cmpBuildingEntityIdentity, "buildingsConstructed", type);
    213 
    214     this.buildingsConstructed.total++;
    215 };
    216 
    217 StatisticsTracker.prototype.KilledEntity = function(targetEntity)
     169    };
     170};
     171
     172/**
     173 * Increments counter associated with certain entity/counter and type of given entity.
     174 * @param cmpIdentity The entity identity component
     175 * @param counter The name of the counter to increment (e.g. "unitsTrained")
     176 * @param type The type of the counter (e.g. "workers")
     177 */
     178StatisticsTracker.prototype.CounterIncrement = function(cmpIdentity, counter, type)
    218179{
    219     var cmpTargetEntityIdentity = Engine.QueryInterface(targetEntity, IID_Identity);
    220     var cmpCost = Engine.QueryInterface(targetEntity, IID_Cost);
    221     var costs = cmpCost.GetResourceCosts();
    222     if (!cmpTargetEntityIdentity)
    223         return;
    224 
    225     var cmpFoundation = Engine.QueryInterface(targetEntity, IID_Foundation);
    226     // We want to deal only with real structures, not foundations
    227     var targetIsStructure = cmpTargetEntityIdentity.HasClass("Structure") && cmpFoundation == null;
    228     var targetIsDomesticAnimal = cmpTargetEntityIdentity.HasClass("Animal") && cmpTargetEntityIdentity.HasClass("Domestic");
    229     // Don't count domestic animals as units
    230     var targetIsUnit = cmpTargetEntityIdentity.HasClass("Unit") && !targetIsDomesticAnimal;
    231 
    232     var cmpTargetOwnership = Engine.QueryInterface(targetEntity, IID_Ownership);
    233    
    234     // Don't increase counters if target player is gaia (player 0)
    235     if (cmpTargetOwnership.GetOwner() == 0)
    236         return;
    237 
    238     if (targetIsUnit)
    239     {
    240         for each (var type in this.unitsClasses)
    241             this.CounterIncrement(cmpTargetEntityIdentity, "enemyUnitsKilled", type);
    242 
    243         this.enemyUnitsKilled.total++;
    244        
    245         for each (var cost in costs)
    246             this.enemyUnitsKilledValue += cost;
    247     }   
    248     if (targetIsStructure)
    249     {
    250         for each (var type in this.buildingsClasses)
    251             this.CounterIncrement(cmpTargetEntityIdentity, "enemyBuildingsDestroyed", type);
    252 
    253         this.enemyBuildingsDestroyed.total++;
    254        
    255         for each (var cost in costs)
    256             this.enemyBuildingsDestroyedValue += cost;
    257     }
    258 };
    259 
     180    var classes = cmpIdentity.GetClassesList();
     181    if (!classes)
     182        return;
     183    if (classes.indexOf(type) != -1)
     184        this[counter][type]++;
     185};
     186
     187/**
     188 * Counts the total number of units trained as well as an individual count for
     189 * each unit type. Based on templates.
     190 * @param trainedUnit The unit that has been trained
     191 */
     192StatisticsTracker.prototype.IncreaseTrainedUnitsCounter = function(trainedUnit)
     193{
     194    var cmpUnitEntityIdentity = Engine.QueryInterface(trainedUnit, IID_Identity);
     195
     196    if (!cmpUnitEntityIdentity)
     197        return;
     198
     199    for each (var type in this.unitsClasses)
     200        this.CounterIncrement(cmpUnitEntityIdentity, "unitsTrained", type);
     201
     202    this.unitsTrained.total++;
     203};
     204
     205/**
     206 * Counts the total number of buildings constructed as well as an individual count for
     207 * each building type. Based on templates.
     208 * @param constructedBuilding The building that has been constructed
     209 */
     210StatisticsTracker.prototype.IncreaseConstructedBuildingsCounter = function(constructedBuilding)
     211{
     212    var cmpBuildingEntityIdentity = Engine.QueryInterface(constructedBuilding, IID_Identity);
     213       
     214    if (!cmpBuildingEntityIdentity)
     215        return;
     216
     217    for each(var type in this.buildingsClasses)
     218        this.CounterIncrement(cmpBuildingEntityIdentity, "buildingsConstructed", type);
     219
     220    this.buildingsConstructed.total++;
     221};
     222
     223StatisticsTracker.prototype.KilledEntity = function(targetEntity)
     224{
     225    var cmpTargetEntityIdentity = Engine.QueryInterface(targetEntity, IID_Identity);
     226    var cmpCost = Engine.QueryInterface(targetEntity, IID_Cost);
     227    var costs = cmpCost.GetResourceCosts();
     228    if (!cmpTargetEntityIdentity)
     229        return;
     230
     231    var cmpFoundation = Engine.QueryInterface(targetEntity, IID_Foundation);
     232    // We want to deal only with real structures, not foundations
     233    var targetIsStructure = cmpTargetEntityIdentity.HasClass("Structure") && cmpFoundation == null;
     234    var targetIsDomesticAnimal = cmpTargetEntityIdentity.HasClass("Animal") && cmpTargetEntityIdentity.HasClass("Domestic");
     235    // Don't count domestic animals as units
     236    var targetIsUnit = cmpTargetEntityIdentity.HasClass("Unit") && !targetIsDomesticAnimal;
     237
     238    var cmpTargetOwnership = Engine.QueryInterface(targetEntity, IID_Ownership);
     239   
     240    // Don't increase counters if target player is gaia (player 0)
     241    if (cmpTargetOwnership.GetOwner() == 0)
     242        return;
     243
     244    if (targetIsUnit)
     245    {
     246        for each (var type in this.unitsClasses)
     247            this.CounterIncrement(cmpTargetEntityIdentity, "enemyUnitsKilled", type);
     248
     249        this.enemyUnitsKilled.total++;
     250       
     251        for each (var cost in costs)
     252            this.enemyUnitsKilledValue += cost;
     253    }   
     254    if (targetIsStructure)
     255    {
     256        for each (var type in this.buildingsClasses)
     257            this.CounterIncrement(cmpTargetEntityIdentity, "enemyBuildingsDestroyed", type);
     258
     259        this.enemyBuildingsDestroyed.total++;
     260       
     261        for each (var cost in costs)
     262            this.enemyBuildingsDestroyedValue += cost;
     263    }
     264};
     265
    260266StatisticsTracker.prototype.LostEntity = function(lostEntity)
    261267{
    262     var cmpLostEntityIdentity = Engine.QueryInterface(lostEntity, IID_Identity);
    263     var cmpCost = Engine.QueryInterface(lostEntity, IID_Cost);
    264     var costs = cmpCost.GetResourceCosts();
    265     if (!cmpLostEntityIdentity)
    266         return;
    267    
    268     var cmpFoundation = Engine.QueryInterface(lostEntity, IID_Foundation);
    269     // We want to deal only with real structures, not foundations
    270     var lostEntityIsStructure = cmpLostEntityIdentity.HasClass("Structure") && cmpFoundation == null;
    271     var lostEntityIsDomesticAnimal = cmpLostEntityIdentity.HasClass("Animal") && cmpLostEntityIdentity.HasClass("Domestic");
    272     // Don't count domestic animals as units
    273     var lostEntityIsUnit = cmpLostEntityIdentity.HasClass("Unit") && !lostEntityIsDomesticAnimal;
    274 
    275     if (lostEntityIsUnit)
    276     {
    277         for each (var type in this.unitsClasses)
    278             this.CounterIncrement(cmpLostEntityIdentity, "unitsLost", type);
    279 
    280         this.unitsLost.total++;
    281        
    282         for each (var cost in costs)
    283             this.unitsLostValue += cost;   
    284     }   
    285     if (lostEntityIsStructure)
    286     {
    287         for each (var type in this.buildingsClasses)
    288             this.CounterIncrement(cmpLostEntityIdentity, "buildingsLost", type);
    289 
    290         this.buildingsLost.total++;
    291        
    292         for each (var cost in costs)
    293             this.buildingsLostValue += cost;
    294     }
    295 };
    296 
     268    var cmpLostEntityIdentity = Engine.QueryInterface(lostEntity, IID_Identity);
     269    var cmpCost = Engine.QueryInterface(lostEntity, IID_Cost);
     270    var costs = cmpCost.GetResourceCosts();
     271    if (!cmpLostEntityIdentity)
     272        return;
     273   
     274    var cmpFoundation = Engine.QueryInterface(lostEntity, IID_Foundation);
     275    // We want to deal only with real structures, not foundations
     276    var lostEntityIsStructure = cmpLostEntityIdentity.HasClass("Structure") && cmpFoundation == null;
     277    var lostEntityIsDomesticAnimal = cmpLostEntityIdentity.HasClass("Animal") && cmpLostEntityIdentity.HasClass("Domestic");
     278    // Don't count domestic animals as units
     279    var lostEntityIsUnit = cmpLostEntityIdentity.HasClass("Unit") && !lostEntityIsDomesticAnimal;
     280
     281    if (lostEntityIsUnit)
     282    {
     283        for each (var type in this.unitsClasses)
     284            this.CounterIncrement(cmpLostEntityIdentity, "unitsLost", type);
     285
     286        this.unitsLost.total++;
     287       
     288        for each (var cost in costs)
     289            this.unitsLostValue += cost;   
     290    }   
     291    if (lostEntityIsStructure)
     292    {
     293        for each (var type in this.buildingsClasses)
     294            this.CounterIncrement(cmpLostEntityIdentity, "buildingsLost", type);
     295
     296        this.buildingsLost.total++;
     297       
     298        for each (var cost in costs)
     299            this.buildingsLostValue += cost;
     300    }
     301};
     302
    297303/**
    298304 * @param type Generic type of resource (string)
    299305 * @param amount Amount of resource, whick should be added (integer)
     
    301307 */
    302308StatisticsTracker.prototype.IncreaseResourceGatheredCounter = function(type, amount, specificType)
    303309{
    304     this.resourcesGathered[type] += amount;
    305    
    306     if (type == "food" && (specificType == "fruit" || specificType == "grain"))
    307         this.resourcesGathered.vegetarianFood += amount;
    308 };
    309 
    310 /**
     310    this.resourcesGathered[type] += amount;
     311   
     312    if (type == "food" && (specificType == "fruit" || specificType == "grain"))
     313        this.resourcesGathered.vegetarianFood += amount;
     314};
     315
     316/**
    311317 * @param type Generic type of resource (string)
    312  * @param amount Amount of resource, whick should be added (integer)
     318 * @param amount Amount of resource, which should be added (integer)
    313319 */
    314320StatisticsTracker.prototype.IncreaseResourceUsedCounter = function(type, amount)
    315321{
    316322    this.resourcesUsed[type] += amount;
    317323};
    318 
    319 StatisticsTracker.prototype.IncreaseTreasuresCollectedCounter = function()
    320 {
    321     this.treasuresCollected++;
    322 };
    323 
    324 StatisticsTracker.prototype.IncreaseResourcesSoldCounter = function(type, amount)
    325 {
    326     this.resourcesSold[type] += amount;
    327 };
    328 
    329 StatisticsTracker.prototype.IncreaseResourcesBoughtCounter = function(type, amount)
    330 {
    331     this.resourcesBought[type] += amount;
    332 };
    333 
    334 StatisticsTracker.prototype.IncreaseTributesSentCounter = function(amount)
    335 {
    336     this.tributesSent += amount;
    337 };
    338 
    339 StatisticsTracker.prototype.IncreaseTributesReceivedCounter = function(amount)
    340 {
    341     this.tributesReceived += amount;
    342 };
    343 
    344 StatisticsTracker.prototype.IncreaseTradeIncomeCounter = function(amount)
    345 {
    346     this.tradeIncome += amount;
    347 };
    348 
    349 StatisticsTracker.prototype.GetPercentMapExplored = function()
    350 {
     324
     325StatisticsTracker.prototype.IncreaseTreasuresCollectedCounter = function()
     326{
     327    this.treasuresCollected++;
     328};
     329
     330StatisticsTracker.prototype.IncreaseLootCollectedCounter = function(amount)
     331{
     332    for (var type in amount)
     333    {
     334        this.lootCollected += (+amount[type]);
     335    }
     336};
     337StatisticsTracker.prototype.IncreaseResourcesSoldCounter = function(type, amount)
     338{
     339    this.resourcesSold[type] += amount;
     340};
     341
     342StatisticsTracker.prototype.IncreaseResourcesBoughtCounter = function(type, amount)
     343{
     344    this.resourcesBought[type] += amount;
     345};
     346
     347StatisticsTracker.prototype.IncreaseTributesSentCounter = function(amount)
     348{
     349    this.tributesSent += amount;
     350};
     351
     352StatisticsTracker.prototype.IncreaseTributesReceivedCounter = function(amount)
     353{
     354    this.tributesReceived += amount;
     355};
     356
     357StatisticsTracker.prototype.IncreaseTradeIncomeCounter = function(amount)
     358{
     359    this.tradeIncome += amount;
     360};
     361
     362StatisticsTracker.prototype.GetPercentMapExplored = function()
     363{
    351364    var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
    352365    var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player);
    353366    return cmpRangeManager.GetPercentMapExplored(cmpPlayer.GetPlayerID());
  • source/tools/XpartaMuPP/LobbyRanking.py

     
    6161    metalUsed = Column(Integer)
    6262    vegetarianFoodGathered = Column(Integer)
    6363    treasuresCollected = Column(Integer)
     64    lootCollected = Column(Integer)
    6465    tributesSent = Column(Integer)
    6566    tributesReceived = Column(Integer)
    6667    totalUnitsTrained = Column(Integer)
     
    8788    shipUnitsTrained = Column(Integer)
    8889    shipUnitsLost = Column(Integer)
    8990    enemyShipUnitsKilled = Column(Integer)
     91    traderUnitsTrained = Column(Integer)
     92    traderUnitsLost = Column(Integer)
     93    enemyTraderUnitsKilled = Column(Integer)
    9094    totalBuildingsConstructed = Column(Integer)
    9195    totalBuildingsLost = Column(Integer)
    9296    enemytotalBuildingsDestroyed = Column(Integer)
  • source/tools/XpartaMuPP/XpartaMuPP.py

     
    122122    totalScoreStats = {'economyScore', 'militaryScore', 'totalScore'}
    123123    resourceStats = {'foodGathered', 'foodUsed', 'woodGathered', 'woodUsed',
    124124            'stoneGathered', 'stoneUsed', 'metalGathered', 'metalUsed', 'vegetarianFoodGathered',
    125             'treasuresCollected', 'tributesSent', 'tributesReceived'}
     125            'treasuresCollected', 'lootCollected', 'tributesSent', 'tributesReceived'}
    126126    unitsStats = {'totalUnitsTrained', 'totalUnitsLost', 'enemytotalUnitsKilled', 'infantryUnitsTrained',
    127127            'infantryUnitsLost', 'enemyInfantryUnitsKilled', 'workerUnitsTrained', 'workerUnitsLost',
    128128            'enemyWorkerUnitsKilled', 'femaleUnitsTrained', 'femaleUnitsLost', 'enemyFemaleUnitsKilled',
    129129            'cavalryUnitsTrained', 'cavalryUnitsLost', 'enemyCavalryUnitsKilled', 'championUnitsTrained',
    130130            'championUnitsLost', 'enemyChampionUnitsKilled', 'heroUnitsTrained', 'heroUnitsLost',
    131             'enemyHeroUnitsKilled', 'shipUnitsTrained', 'shipUnitsLost', 'enemyShipUnitsKilled'}
     131            'enemyHeroUnitsKilled', 'shipUnitsTrained', 'shipUnitsLost', 'enemyShipUnitsKilled', 'traderUnitsTrained',
     132            'traderUnitsLost', 'enemyTraderUnitsKilled'}
    132133    buildingsStats = {'totalBuildingsConstructed', 'totalBuildingsLost', 'enemytotalBuildingsDestroyed',
    133134            'civCentreBuildingsConstructed', 'civCentreBuildingsLost', 'enemyCivCentreBuildingsDestroyed',
    134135            'houseBuildingsConstructed', 'houseBuildingsLost', 'enemyHouseBuildingsDestroyed',