Ticket #3216: t3216_capture_statistics_v11.4.patch

File t3216_capture_statistics_v11.4.patch, 22.8 KB (added by Imarok, 8 years ago)

Put more code into the regex function

  • binaries/data/mods/public/gui/summary/counters.js

     
    1212        g_KilledColor + killed + '[/color]';
    1313}
    1414
     15function formatCaptured(trained, killed, captured, lost)
     16{
     17    return g_TrainedColor + trained + '[/color] / ' +
     18        g_KilledColor + killed + '[/color]\n' +
     19        g_CapturedColor + captured + '[/color] / ' +
     20        g_LostColor + lost + '[/color]\n'
     21}
     22
    1523function formatIncome(income, outcome)
    1624{
    1725    return g_IncomeColor + income + '[/color] / ' +
     
    3745    return Math.round(divident / divisor * 100) / 100;
    3846}
    3947
     48/**
     49 * Clean [Color=""], [/Color], white space, + and % for make the sum more easy
     50 * Remove \n only when removeLineFeed == true
     51 */
     52function cleanGUICaption(team, player, counter, removeLineFeed = true)
     53{
     54    let caption = Engine.GetGUIObjectByName("valueDataTeam[" + team + "][" + player + "][" + counter + "]").caption
     55    if(removeLineFeed)
     56        return caption.replace(/\[([\w\' \\\"\/\=]*)\]|\+|\%|\s/g, "");
     57    else
     58        return caption.replace(/\[([\w\' \\\"\/\=]*)\]|[\t\r \f]/g, "");
     59}
     60
    4061function updateCountersPlayer(playerState, counters, idGUI)
    4162{
    4263    for (let w in counters)
     
    97118function calculateMilitaryScore(playerState)
    98119{
    99120    return Math.round((playerState.statistics.enemyUnitsKilledValue +
    100         playerState.statistics.enemyBuildingsDestroyedValue) / 10);
     121        playerState.statistics.enemyBuildingsDestroyedValue +
     122        playerState.statistics.buildingsCapturedValue) / 10);
    101123}
    102124
    103125function calculateExplorationScore(playerState)
     
    144166function calculateBuildings(playerState, position)
    145167{
    146168    let type = g_BuildingsTypes[position];
    147 
    148     return formatTrained(
     169    return formatCaptured(
    149170        playerState.statistics.buildingsConstructed[type],
    150         playerState.statistics.buildingsLost[type],
    151         playerState.statistics.enemyBuildingsDestroyed[type]);
     171        playerState.statistics.enemyBuildingsDestroyed[type],
     172        playerState.statistics.buildingsCaptured[type],
     173        playerState.statistics.buildingsLost[type]);
    152174}
    153175
    154 function calculateColorsTeam(counters)
     176function calculateBuildingsTeam(counters)
    155177{
    156178    for (let t in g_Teams)
    157179    {
     
    161183        for (let w in counters)
    162184        {
    163185            let total = {
     186                "constructed" : 0,
     187                "destroyed" : 0,
     188                "captured" : 0,
     189                "lost" : 0
     190            };
     191            for (let p = 0; p < g_Teams[t]; ++p)
     192            {
     193                let splitCaption = cleanGUICaption(t, p, w, false).split("\n");
     194                let first = splitCaption[0].split("/");
     195                let second = splitCaption[1].split("/");
     196
     197                total.constructed += +first[0];
     198                total.destroyed += +first[1];
     199                total.captured += +second[0];
     200                total.lost += +second[1];
     201            }
     202            let teamTotal = formatCaptured(total.constructed,
     203                total.destroyed, total.captured, total.lost);
     204
     205            Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal;
     206        }
     207    }
     208}
     209
     210function calculateUnitsTeam(counters)
     211{
     212    for (let t in g_Teams)
     213    {
     214        if (t == -1)
     215            continue;
     216
     217        for (let w in counters)
     218        {
     219            let total = {
    164220                "constructed": 0,
    165221                "lost": 0,
    166222                "destroyed": 0
     
    168224
    169225            for (let p = 0; p < g_Teams[t]; ++p)
    170226            {
    171                 let caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption;
    172                 // clean [Color=""], [/Color] and white space for make the sum more easy
    173                 caption = caption.replace(/\[([\w\' \\\"\/\=]*)\]|\s/g, "");
     227                let splitCaption = cleanGUICaption(t, p, w).split("/");
    174228
    175                 let splitCaption = caption.split("/");
    176 
    177229                total.constructed += +splitCaption[0];
    178230                total.lost += +splitCaption[1];
    179231                total.destroyed += +splitCaption[2];
     
    251303
    252304            for (let p = 0; p < g_Teams[t]; ++p)
    253305            {
    254                 let caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption;
    255                 // clean [Color=""], [/Color] and white space for make the sum more easy
    256                 caption = caption.replace(/\[([\w\' \\\"\/\=]*)\]|\s/g, "");
     306                let caption = cleanGUICaption(t, p, w);
    257307
    258308                if (w >= 6)
    259309                    total.income += +caption;
     
    321371
    322372            for (let p = 0; p < g_Teams[t]; ++p)
    323373            {
    324                 let caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption;
    325                 // clean [Color=""], [/Color], white space, + and % for make the sum more easy
    326                 caption = caption.replace(/\[([\w\' \\\"\/\=]*)\]|\s|\+|\%/g, "");
     374                let caption = cleanGUICaption(t, p, w);
    327375
    328376                if (w >= 4)
    329377                    total.income += +caption;
    330378                else
    331379                {
    332                     let splitCaption = caption.split("-");
     380                    let splitCaption = caption.split("/");
    333381                    total.income += +splitCaption[0];
    334382                    total.outcome += +splitCaption[1];
    335383                }
  • binaries/data/mods/public/gui/summary/layout.js

     
    99        ],
    1010        "titleHeadings": [],
    1111        "counters": [
    12             { "width": 100, "fn": calculateEconomyScore },
    13             { "width": 100, "fn": calculateMilitaryScore },
    14             { "width": 100, "fn": calculateExplorationScore },
    15             { "width": 100, "fn": calculateScoreTotal}
     12            { "width": 100, "fn": calculateEconomyScore, "verticalOffset": 12 },
     13            { "width": 100, "fn": calculateMilitaryScore, "verticalOffset": 12 },
     14            { "width": 100, "fn": calculateExplorationScore, "verticalOffset": 12 },
     15            { "width": 100, "fn": calculateScoreTotal, "verticalOffset": 12 }
    1616        ],
    1717        "teamCounterFn": calculateScoreTeam
    1818    },
     
    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 = 700
     32            {
     33                "caption": sprintf(translate("Buildings Statistics (%(constructed)s / %(destroyed)s / %(captured)s / %(lost)s)"),
     34                    {
     35                        "constructed": g_TrainedColor + translate("Constructed") + '[/color]',
     36                        "destroyed": g_KilledColor + translate("Destroyed") + '[/color]',
     37                        "captured": g_CapturedColor + translate("Captured") + '[/color]',
     38                        "lost": g_LostColor + translate("Lost") + '[/color]'
     39                    }),
     40                "yStart": 16,
     41                "width": (85 * 7 + 105)
     42            },  // width = 700
    3343        ],
    3444        "counters": [
    35             { "width": 105, "fn": calculateBuildings },
    36             { "width": 85, "fn": calculateBuildings },
    37             { "width": 85, "fn": calculateBuildings },
    38             { "width": 85, "fn": calculateBuildings },
    39             { "width": 85, "fn": calculateBuildings },
    40             { "width": 85, "fn": calculateBuildings },
    41             { "width": 85, "fn": calculateBuildings },
    42             { "width": 85, "fn": calculateBuildings }
     45            { "width": 105, "fn": calculateBuildings, "verticalOffset": 3 },
     46            { "width": 85, "fn": calculateBuildings, "verticalOffset": 3 },
     47            { "width": 85, "fn": calculateBuildings, "verticalOffset": 3 },
     48            { "width": 85, "fn": calculateBuildings, "verticalOffset": 3 },
     49            { "width": 85, "fn": calculateBuildings, "verticalOffset": 3 },
     50            { "width": 85, "fn": calculateBuildings, "verticalOffset": 3 },
     51            { "width": 85, "fn": calculateBuildings, "verticalOffset": 3 },
     52            { "width": 85, "fn": calculateBuildings, "verticalOffset": 3 }
    4353        ],
    44         "teamCounterFn": calculateColorsTeam
     54        "teamCounterFn": calculateBuildingsTeam
    4555    },
    4656    "units": {
    4757        "headings": [
     
    5666            { "caption": translate("Traders"), "yStart": 34, "width": 100 }
    5767        ],
    5868        "titleHeadings": [
    59             { "caption": translate("Units Statistics (Trained / Lost / Killed)"), "yStart": 16, "width": (100 * 7 + 120) }, // width = 820
     69            {
     70                "caption": sprintf(translate("Units Statistics (%(trained)s / %(lost)s / %(killed)s)"),
     71                    {
     72                        "trained": g_TrainedColor + translate("Trained") + '[/color]',
     73                        "lost": g_LostColor + translate("Lost") + '[/color]',
     74                        "killed": g_KilledColor + translate("Killed") + '[/color]'
     75                    }),
     76                "yStart": 16,
     77                "width": (100 * 7 + 120)
     78            },  // width = 820
    6079        ],
    6180        "counters": [
    62             { "width": 120, "fn": calculateUnits },
    63             { "width": 100, "fn": calculateUnits },
    64             { "width": 100, "fn": calculateUnits },
    65             { "width": 100, "fn": calculateUnits },
    66             { "width": 100, "fn": calculateUnits },
    67             { "width": 100, "fn": calculateUnits },
    68             { "width": 100, "fn": calculateUnits },
    69             { "width": 100, "fn": calculateUnits }
     81            { "width": 120, "fn": calculateUnits, "verticalOffset": 12 },
     82            { "width": 100, "fn": calculateUnits, "verticalOffset": 12 },
     83            { "width": 100, "fn": calculateUnits, "verticalOffset": 12 },
     84            { "width": 100, "fn": calculateUnits, "verticalOffset": 12 },
     85            { "width": 100, "fn": calculateUnits, "verticalOffset": 12 },
     86            { "width": 100, "fn": calculateUnits, "verticalOffset": 12 },
     87            { "width": 100, "fn": calculateUnits, "verticalOffset": 12 },
     88            { "width": 100, "fn": calculateUnits, "verticalOffset": 12 }
    7089        ],
    71         "teamCounterFn": calculateColorsTeam
     90        "teamCounterFn": calculateUnitsTeam
    7291    },
    7392    "resources": {
    7493        "headings": [
     
    7897            { "caption": translate("Stone"), "yStart": 34, "width": 100 },
    7998            { "caption": translate("Metal"), "yStart": 34, "width": 100 },
    8099            { "caption": translate("Total"), "yStart": 34, "width": 110 },
    81             { "caption": translate("Tributes (Sent / Received)"), "yStart": 16, "width": 121 },
     100            {
     101                "caption": sprintf(translate("Tributes \n(%(sent)s / %(received)s)"),
     102                    {
     103                        "sent": g_IncomeColor + translate("Sent") + '[/color]',
     104                        "received": g_OutcomeColor + translate("Received") + '[/color]'
     105                    }),
     106                "yStart": 16,
     107                "width": 121
     108            },
    82109            { "caption": translate("Treasures collected"), "yStart": 16, "width": 100 },
    83110            { "caption": translate("Loot"), "yStart": 16, "width": 100 }
    84111        ],
    85112        "titleHeadings": [
    86             { "caption": translate("Resource Statistics (Gathered / Used)"), "yStart": 16, "width": (100 * 4 + 110) }, // width = 510
     113            {
     114                "caption": sprintf(translate("Resource Statistics (%(gathered)s / %(used)s)"),
     115                    {
     116                        "gathered": g_IncomeColor + translate("Gathered") + '[/color]',
     117                        "used": g_OutcomeColor + translate("Used") + '[/color]'
     118                    }),
     119                "yStart": 16,
     120                "width": (100 * 4 + 110)
     121            }, // width = 510
    87122        ],
    88123        "counters": [
    89             { "width": 100, "fn": calculateResources },
    90             { "width": 100, "fn": calculateResources },
    91             { "width": 100, "fn": calculateResources },
    92             { "width": 100, "fn": calculateResources },
    93             { "width": 110, "fn": calculateTotalResources },
    94             { "width": 121, "fn": calculateTributeSent },
    95             { "width": 100, "fn": calculateTreasureCollected },
    96             { "width": 100, "fn": calculateLootCollected }
     124            { "width": 100, "fn": calculateResources, "verticalOffset": 12 },
     125            { "width": 100, "fn": calculateResources, "verticalOffset": 12 },
     126            { "width": 100, "fn": calculateResources, "verticalOffset": 12 },
     127            { "width": 100, "fn": calculateResources, "verticalOffset": 12 },
     128            { "width": 110, "fn": calculateTotalResources, "verticalOffset": 12 },
     129            { "width": 121, "fn": calculateTributeSent, "verticalOffset": 12 },
     130            { "width": 100, "fn": calculateTreasureCollected, "verticalOffset": 12 },
     131            { "width": 100, "fn": calculateLootCollected, "verticalOffset": 12 }
    97132        ],
    98133        "teamCounterFn": calculateResourcesTeam
    99134    },
     
    109144        ],
    110145        "titleHeadings": [],
    111146        "counters": [
    112             { "width": 100, "fn": calculateResourceExchanged },
    113             { "width": 100, "fn": calculateResourceExchanged },
    114             { "width": 100, "fn": calculateResourceExchanged },
    115             { "width": 100, "fn": calculateResourceExchanged },
    116             { "width": 100, "fn": calculateBarterEfficiency },
    117             { "width": 100, "fn": calculateTradeIncome }
     147            { "width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12 },
     148            { "width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12 },
     149            { "width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12 },
     150            { "width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12 },
     151            { "width": 100, "fn": calculateBarterEfficiency, "verticalOffset": 12 },
     152            { "width": 100, "fn": calculateTradeIncome, "verticalOffset": 12 }
    118153        ],
    119154        "teamCounterFn": calculateMarketTeam
    120155    },
     
    132167            { "caption": translate("Map control"), "xOffset": 400, "yStart": 16, "width": 200 }
    133168        ],
    134169        "counters": [
    135             { "width": 100, "fn": calculateVegetarianRatio },
    136             { "width": 100, "fn": calculateFeminization },
    137             { "width": 100, "fn": calculateKillDeathRatio },
    138             { "width": 100, "fn": calculateMapExploration },
    139             { "width": 100, "fn": calculateMapPeakControl },
    140             { "width": 100, "fn": calculateMapFinalControl }
     170            { "width": 100, "fn": calculateVegetarianRatio, "verticalOffset": 12 },
     171            { "width": 100, "fn": calculateFeminization, "verticalOffset": 12 },
     172            { "width": 100, "fn": calculateKillDeathRatio, "verticalOffset": 12 },
     173            { "width": 100, "fn": calculateMapExploration, "verticalOffset": 12 },
     174            { "width": 100, "fn": calculateMapPeakControl, "verticalOffset": 12 },
     175            { "width": 100, "fn": calculateMapFinalControl, "verticalOffset": 12 }
    141176        ],
    142177        "teamCounterFn": calculateMiscellaneous
    143178    }
     
    214249        for (let w in counters)
    215250        {
    216251            counterObject = Engine.GetGUIObjectByName("valueData[" + p + "][" + w + "]");
    217             counterObject.size = left + " 6 " + (left + counters[w].width) + " 100%";
     252            counterObject.size = left + " " + counters[w].verticalOffset + " " + (left + counters[w].width) + " 100%";
    218253            counterObject.hidden = false;
    219254            left += counters[w].width;
    220255        }
     
    229264            for (let w in counters)
    230265            {
    231266                counterObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]");
    232                 counterObject.size = left + " 6 " + (left + counters[w].width) + " 100%";
     267                counterObject.size = left + " " + counters[w].verticalOffset + " " + (left + counters[w].width) + " 100%";
    233268                counterObject.hidden = false;
    234269
    235270                if (g_Teams[t])
    236271                {
    237                     let yStart = 30 + g_Teams[t] * (g_PlayerBoxYSize + g_PlayerBoxGap) + 2;
     272                    let yStart = 25 + g_Teams[t] * (g_PlayerBoxYSize + g_PlayerBoxGap) + 3 + counters[w].verticalOffset;
    238273                    counterTotalObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]");
    239274                    counterTotalObject.size = (left + 20) + " " + yStart + " " + (left + counters[w].width) + " 100%";
    240275                    counterTotalObject.hidden = false;
     
    272307        Engine.GetGUIObjectByName("teamNameHeadingt["+i+"]").caption = "Team "+(i+1);
    273308
    274309        let teamHeading = Engine.GetGUIObjectByName("teamHeadingt["+i+"]");
    275         let yStartTotal = 30 + g_Teams[i] * (g_PlayerBoxYSize + g_PlayerBoxGap) + 2;
    276         teamHeading.size = "50 "+yStartTotal+" 100% "+(yStartTotal+20);
     310        let yStartTotal = 30 + g_Teams[i] * (g_PlayerBoxYSize + g_PlayerBoxGap) + 10;
     311        teamHeading.size = "50 " + yStartTotal + " 100% " + (yStartTotal + 20);
    277312        teamHeading.caption = translate("Team total");
    278313    }
    279314
  • binaries/data/mods/public/gui/summary/summary.js

     
    33// const for filtering long collective headings
    44const g_LongHeadingWidth = 250;
    55
    6 const g_PlayerBoxYSize = 30;
     6const g_PlayerBoxYSize = 40;
    77const g_PlayerBoxGap = 2;
    88const g_PlayerBoxAlpha = " 32";
    99const g_PlayerColorBoxAlpha = " 255";
    10 const g_TeamsBoxYStart = 65;
     10const g_TeamsBoxYStart = 40;
    1111
    1212// Colors used for units and buildings
    1313const g_TrainedColor = '[color="201 255 200"]';
    1414const g_LostColor = '[color="255 213 213"]';
    1515const g_KilledColor = '[color="196 198 255"]';
     16const g_CapturedColor = '[color="255 255 157"]';
    1617
    1718const g_BuildingsTypes = [ "total", "House", "Economic", "Outpost", "Military", "Fortress", "CivCentre", "Wonder" ];
    1819const g_UnitsTypes = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship", "Trader" ];
  • binaries/data/mods/public/gui/summary/summary.xml

     
    1414
    1515    <!-- After settings.js, which defines g_Settings and g_MaxPlayers. -->
    1616    <script file="gui/summary/counters.js"/>
     17    <script file="gui/summary/summary.js"/>
    1718    <script file="gui/summary/layout.js"/>
    18     <script file="gui/summary/summary.js"/>
    1919
    2020    <object name="summaryWindow"
    2121        type="image"
     
    123123                    <object size="0 30 100% 100%">
    124124                        <repeat count="8" var="n">
    125125                            <object type="image" name="playerBoxt[i][n]" size="10 0 10 30" hidden="true">
    126                                 <object name="playerColorBoxt[i][n]" type="image" size="10 4 30 24"/>
    127                                 <object name="playerNamet[i][n]" type="text"  size="40 2 208 100%" style="ModernLeftLabelText" />
    128                                 <object name="civIcont[i][n]" type="image" size="208 0 240 32"/>
     126                                <object type="image" sprite="ForegroundBox" size="10 9 34 33">
     127                                    <object name="playerColorBoxt[i][n]" type="image" size="2 2 22 22"/>
     128                                </object>
     129                                <object name="playerNamet[i][n]" type="text"  size="40 2 208 100%" style="ModernLeftLabelText"/>
     130                                <object name="civIcont[i][n]" type="image" size="208 5 240 37" />
    129131                                <repeat var="x" count="8">
    130132                                    <object name="valueDataTeam[i][n][x]" type="text" style="ModernTabLabelText">
    131133                                    </object>
     
    144146            <object type="image" name="noTeamsBox" size="0 65 100% 100%-50" hidden="true">
    145147                <repeat count="8">
    146148                    <object type="image" name="playerBox[n]" size="10 0 10 30" hidden="true">
    147                         <object type="image" sprite="ForegroundBox" size="10 4 34 28">
     149                        <object type="image" sprite="ForegroundBox" size="10 9 34 33">
    148150                            <object name="playerColorBox[n]" type="image" size="2 2 22 22"/>
    149151                        </object>
    150152                        <object name="playerName[n]" type="text"  size="40 2 208 100%" style="ModernLeftLabelText"/>
    151                         <object name="civIcon[n]" type="image" size="208 0 240 32"/>
     153                        <object name="civIcon[n]" type="image" size="208 5 240 37"/>
    152154                        <repeat var="x" count="8">
    153155                            <object name="valueData[n][x]" type="text" style="ModernTabLabelText">
    154156                            </object>
  • binaries/data/mods/public/simulation/components/Capturable.js

     
    151151        if (this.cp[i] >= this.cp[bestPlayer])
    152152            bestPlayer = +i;
    153153
     154    let cmpLostPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker);
     155    if (cmpLostPlayerStatisticsTracker)
     156        cmpLostPlayerStatisticsTracker.LostEntity(this.entity);
     157
    154158    cmpOwnership.SetOwner(bestPlayer);
     159
     160    let cmpCapturedPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker);
     161    if (cmpCapturedPlayerStatisticsTracker)
     162        cmpCapturedPlayerStatisticsTracker.CapturedBuilding(this.entity);
    155163};
    156164
    157165Capturable.prototype.GetRegenRate = function()
  • binaries/data/mods/public/simulation/components/StatisticsTracker.js

     
    9292        "total": 0
    9393        };
    9494    this.enemyBuildingsDestroyedValue = 0;
     95    this.buildingsCaptured = {
     96        "House": 0,
     97        "Economic": 0,
     98        "Outpost": 0,
     99        "Military": 0,
     100        "Fortress": 0,
     101        "CivCentre": 0,
     102        "Wonder": 0,
     103        "total": 0
     104    };
     105    this.buildingsCapturedValue = 0;
    95106
    96107    this.resourcesGathered = {
    97108        "food": 0,
     
    152163        "unitsLostValue": this.unitsLostValue,
    153164        "enemyUnitsKilled": this.enemyUnitsKilled,
    154165        "enemyUnitsKilledValue": this.enemyUnitsKilledValue,
    155         "buildingsConstructed": this.buildingsConstructed,
    156         "buildingsLost": this.buildingsLost,
     166        "buildingsConstructed": this.buildingsConstructed,
     167        "buildingsLost": this.buildingsLost,
    157168        "buildingsLostValue": this.buildingsLostValue,
    158169        "enemyBuildingsDestroyed": this.enemyBuildingsDestroyed,
    159170        "enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue,
     171        "buildingsCaptured": this.buildingsCaptured,
     172        "buildingsCapturedValue": this.buildingsCapturedValue,
    160173        "resourcesGathered": this.resourcesGathered,
    161174        "resourcesUsed": this.resourcesUsed,
    162175        "resourcesSold": this.resourcesSold,
    163         "resourcesBought": this.resourcesBought,
    164         "tributesSent": this.tributesSent,
     176        "resourcesBought": this.resourcesBought,
     177        "tributesSent": this.tributesSent,
    165178        "tributesReceived": this.tributesReceived,
    166179        "tradeIncome": this.tradeIncome,
    167180        "treasuresCollected": this.treasuresCollected,
     
    295308    }
    296309};
    297310
    298 /**
    299  * @param type Generic type of resource (string)
    300  * @param amount Amount of resource, whick should be added (integer)
    301  * @param specificType Specific type of resource (string, optional)
    302  */
     311StatisticsTracker.prototype.CapturedBuilding = function(capturedBuilding)
     312{
     313    let cmpCapturedBuildingIdentity = Engine.QueryInterface(capturedBuilding, IID_Identity);
     314    let cmpCost = Engine.QueryInterface(capturedBuilding, IID_Cost);
     315    if (!cmpCapturedBuildingIdentity || !cmpCost)
     316        return;
     317    let costs = cmpCost.GetResourceCosts();
     318
     319    for (let type of this.buildingsClasses)
     320        this.CounterIncrement(cmpCapturedBuildingIdentity, "buildingsCaptured", type);
     321
     322    ++this.buildingsCaptured.total;
     323
     324    for (let i in costs)
     325        this.buildingsCapturedValue += costs[i];
     326};
     327
     328/**
     329 * @param type Generic type of resource (string)
     330 * @param amount Amount of resource, whick should be added (integer)
     331 * @param specificType Specific type of resource (string, optional)
     332 */
    303333StatisticsTracker.prototype.IncreaseResourceGatheredCounter = function(type, amount, specificType)
    304334{
    305335    this.resourcesGathered[type] += amount;
  • binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js

     
    126126            "unitsTrained": 10,
    127127            "unitsLost": 9,
    128128            "buildingsConstructed": 5,
     129            "buildingsCaptured": 7,
    129130            "buildingsLost": 4,
    130131            "civCentresBuilt": 1,
    131132            "resourcesGathered": {
     
    208209            "unitsTrained": 10,
    209210            "unitsLost": 9,
    210211            "buildingsConstructed": 5,
     212            "buildingsCaptured": 7,
    211213            "buildingsLost": 4,
    212214            "civCentresBuilt": 1,
    213215            "resourcesGathered": {
     
    362364                unitsTrained: 10,
    363365                unitsLost: 9,
    364366                buildingsConstructed: 5,
     367                buildingsCaptured: 7,
    365368                buildingsLost: 4,
    366369                civCentresBuilt: 1,
    367370                resourcesGathered: {
     
    415418                unitsTrained: 10,
    416419                unitsLost: 9,
    417420                buildingsConstructed: 5,
     421                buildingsCaptured: 7,
    418422                buildingsLost: 4,
    419423                civCentresBuilt: 1,
    420424                resourcesGathered: {