Ticket #3216: t3216_capture_statistics_v10.patch

File t3216_capture_statistics_v10.patch, 21.7 KB (added by elexis, 9 years ago)

The unalignment is caused by #3351. This patch works around the issue by adding another newline in counters.js. Also uses let instead of var in some places and replaces the deprecated "for each" loop with "for ... in".

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

     
    2525}
    2626
    2727function calculateMilitaryScore(playerState, position)
    2828{
    2929    return Math.round((playerState.statistics.enemyUnitsKilledValue +
    30         playerState.statistics.enemyBuildingsDestroyedValue) / 10);
     30        playerState.statistics.enemyBuildingsDestroyedValue +
     31        playerState.statistics.buildingsCapturedValue) / 10);
    3132}
    3233
    3334function calculateExplorationScore(playerState, position)
    3435{
    3536    return playerState.statistics.percentMapExplored * 10;
     
    6263
    6364function calculateBuildings(playerState, position)
    6465{
    6566    var type = BUILDINGS_TYPES[position];
    6667    return TRAINED_COLOR + playerState.statistics.buildingsConstructed[type] + '[/color] / ' +
    67     LOST_COLOR + playerState.statistics.buildingsLost[type] + '[/color] / ' +
    68     KILLED_COLOR + playerState.statistics.enemyBuildingsDestroyed[type] + '[/color]';
     68        KILLED_COLOR + playerState.statistics.enemyBuildingsDestroyed[type] + '[/color]\n' +
     69        CAPTURED_COLOR + playerState.statistics.buildingsCaptured[type] + '[/color] / ' +
     70        LOST_COLOR + playerState.statistics.buildingsLost[type] + '[/color]\n';
    6971}
    7072
    71 function calculateColorsTeam(counters)
     73function calculateBuildingsTeam(counters)
    7274{
    73     for (var t in g_Teams)
     75    for (let t in g_Teams)
    7476    {
    7577        if (t == -1)
    7678            continue;
    7779
    78         for (var w in counters)
     80        for (let w in counters)
     81        {
     82            let total = {
     83                constructed : 0,
     84                destroyed : 0,
     85                captured : 0,   
     86                lost : 0
     87            };
     88            for (let p = 0; p < g_Teams[t]; ++p)
     89            {
     90                let caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption;
     91                // clean [Color=""], [/Color] and white space for make the sum more easy
     92                caption = caption.replace(/\[([\w\' \\\"\/\=]*)\]|[\t\r \f]/g, "");
     93
     94                let splitCaption = caption.split("\n");
     95                let first = splitCaption[0].split("/");
     96                let second = splitCaption[1].split("/");
     97
     98                total.constructed += (+first[0]);
     99                total.destroyed += (+first[1]);
     100                total.captured += (+second[0]);
     101                total.lost += (+second[1]);
     102            }
     103            let teamTotal = TRAINED_COLOR + total.constructed + '[/color] / ' +
     104                KILLED_COLOR + total.destroyed + '[/color]\n' +
     105                CAPTURED_COLOR + total.captured + '[/color] / ' +
     106                LOST_COLOR + total.lost + '[/color]\n';
     107
     108            Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal;
     109        }
     110    }
     111}
     112
     113function calculateUnitsTeam(counters)
     114{
     115    for (let t in g_Teams)
    79116        {
    80             var total = {
     117        if (t == -1)
     118            continue;
     119
     120        for (let w in counters)
     121        {
     122            let total = {
    81123                c : 0,
    82124                l : 0,
    83125                d : 0
    84126            };
    85             for (var p = 0; p < g_Teams[t]; ++p)
     127            for (let p = 0; p < g_Teams[t]; ++p)
    86128            {
    87                 var caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption;
     129                let caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption;
    88130                // clean [Color=""], [/Color] and white space for make the sum more easy
    89131                caption = caption.replace(/\[([\w\' \\\"\/\=]*)\]|\s/g, "");
    90132
    91                 var splitCaption = caption.split("/");
     133                let splitCaption = caption.split("/");
    92134
    93135                total.c += (+splitCaption[0]);
    94136                total.l += (+splitCaption[1]);
    95137                total.d += (+splitCaption[2]);
    96138            }
    97             var teamTotal = TRAINED_COLOR + total.c + '[/color] / ' +
     139            let teamTotal = TRAINED_COLOR + total.c + '[/color] / ' +
    98140            LOST_COLOR + total.l + '[/color] / ' + KILLED_COLOR + total.d + '[/color]';
    99141
    100142            Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal;
    101143        }
    102144    }
  • binaries/data/mods/public/gui/summary/layout.js

     
    77            { "caption": translate("Exploration score"), "yStart": 16, "width": 100 },
    88            { "caption": translate("Total score"), "yStart": 16, "width": 100 }
    99        ],
    1010        "titleHeadings": [],
    1111        "counters": [   // counters on score panel
    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    },
    1919    {   // buildings panel
    2020        "headings": [   // headings on buildings panel
     
    2727            { "caption": translate("Fortresses"), "yStart": 34, "width": 85 },
    2828            { "caption": translate("Civ centers"), "yStart": 34, "width": 85 },
    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            {
     33                "caption": sprintf(translate("Buildings Statistics (%(constructed)s / %(destroyed)s / %(captured)s / %(lost)s)"),
     34                            {
     35                                constructed: '[color="201 255 200"]' + translate("Constructed") + '[/color]',
     36                                destroyed: '[color="196 198 255"]' + translate("Destroyed") + '[/color]',
     37                                captured: '[color="255 255 157"]' + translate("Captured") + '[/color]',
     38                                lost: '[color="255 213 213"]' + translate("Lost") + '[/color]'
     39                            }),
     40                "yStart": 16,
     41                "width": (85 * 7 + 105)
     42            },  // width = 735
    3343        ],
    3444        "counters": [   // counters on buildings panel
    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 panel
    4757        "headings": [   // headings on units panel
    4858            { "caption": translate("Player name"), "yStart": 26, "width": 200 },
    4959            { "caption": translate("Total"), "yStart": 34, "width": 120 },
     
    5363            { "caption": translate("Champion"), "yStart": 34, "width": 100 },
    5464            { "caption": translate("Heroes"), "yStart": 34, "width": 100 },
    5565            { "caption": translate("Navy"), "yStart": 34, "width": 100 }
    5666        ],
    5767        "titleHeadings": [
    58             { "caption": translate("Units Statistics (Trained / Lost / Killed)"), "yStart": 16, "width": (100 * 6 + 120) }, // width = 720
     68            {
     69                "caption": sprintf(translate("Units Statistics (%(trained)s / %(lost)s / %(killed)s)"),
     70                            {
     71                                trained: '[color="201 255 200"]' + translate("Trained") + '[/color]',
     72                                lost: '[color="255 213 213"]' + translate("Lost") + '[/color]',
     73                                killed: '[color="196 198 255"]' + translate("Killed") + '[/color]'
     74                            }),
     75                "yStart": 16,
     76                "width": (100 * 6 + 120)
     77            },  // width = 720
    5978        ],
    6079        "counters": [   // counters on units panel
    61             {"width": 120, "fn": calculateUnits},
    62             {"width": 100, "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}
     80            {"width": 120, "fn": calculateUnits, "verticalOffset": 12},
     81            {"width": 100, "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}
    6887        ],
    69         "teamCounterFn": calculateColorsTeam
     88        "teamCounterFn": calculateUnitsTeam
    7089    },
    7190    {   // resources panel
    7291        "headings": [   // headings on resources panel
    7392            { "caption": translate("Player name"), "yStart": 26, "width": 200 },
    7493            { "caption": translate("Food"), "yStart": 34, "width": 100 },
    7594            { "caption": translate("Wood"), "yStart": 34, "width": 100 },
    7695            { "caption": translate("Stone"), "yStart": 34, "width": 100 },
    7796            { "caption": translate("Metal"), "yStart": 34, "width": 100 },
    7897            { "caption": translate("Total"), "yStart": 34, "width": 110 },
    7998            { "caption": translate("Treasures collected"), "yStart": 16, "width": 100 },
    80             { "caption": translate("Tributes (Sent / Received)"), "yStart": 16, "width": 121 }
     99            {
     100                "caption": sprintf(translate("Tributes (%(sent)s / %(received)s)"),
     101                            {
     102                                sent: '[color="201 255 200"]' + translate("Sent") + '[/color]',
     103                                received: '[color="255 213 213"]' + translate("Received") + '[/color]'
     104                            }),
     105                "yStart": 16,
     106                "width": 121
     107            }
    81108        ],
    82109        "titleHeadings": [
    83             { "caption": translate("Resource Statistics (Gathered / Used)"), "yStart": 16, "width": (100 * 4 + 110) }, // width = 510
     110            {
     111                "caption": sprintf(translate("Resource Statistics (%(gathered)s / %(used)s)"),
     112                            {
     113                                gathered: '[color="201 255 200"]' + translate("Gathered") + '[/color]',
     114                                used: '[color="255 213 213"]' + translate("Used") + '[/color]'
     115                            }),
     116                "yStart": 16,
     117                "width": (100 * 4 + 110)
     118            }, // width = 510
    84119        ],
    85120        "counters": [   // counters on resources panel
    86             {"width": 100, "fn": calculateResources},
    87             {"width": 100, "fn": calculateResources},
    88             {"width": 100, "fn": calculateResources},
    89             {"width": 100, "fn": calculateResources},
    90             {"width": 110, "fn": calculateTotalResources},
    91             {"width": 100, "fn": calculateTreasureCollected},
    92             {"width": 121, "fn": calculateTributeSent}
     121            {"width": 100, "fn": calculateResources, "verticalOffset": 12},
     122            {"width": 100, "fn": calculateResources, "verticalOffset": 12},
     123            {"width": 100, "fn": calculateResources, "verticalOffset": 12},
     124            {"width": 100, "fn": calculateResources, "verticalOffset": 12},
     125            {"width": 110, "fn": calculateTotalResources, "verticalOffset": 12},
     126            {"width": 100, "fn": calculateTreasureCollected, "verticalOffset": 12},
     127            {"width": 121, "fn": calculateTributeSent, "verticalOffset": 12}
    93128        ],
    94129        "teamCounterFn": calculateResourcesTeam
    95130    },
    96131    {   // market panel
    97132        "headings": [   // headings on market panel
     
    103138            { "caption": translate("Barter efficiency"), "yStart": 16, "width": 100 },
    104139            { "caption": translate("Trade income"), "yStart": 16, "width": 100 }
    105140        ],
    106141        "titleHeadings": [],
    107142        "counters": [   // counters on market panel
    108             {"width": 100, "fn": calculateResourceExchanged},
    109             {"width": 100, "fn": calculateResourceExchanged},
    110             {"width": 100, "fn": calculateResourceExchanged},
    111             {"width": 100, "fn": calculateResourceExchanged},
    112             {"width": 100, "fn": calculateBatteryEfficiency},
    113             {"width": 100, "fn": calculateTradeIncome}
     143            {"width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12},
     144            {"width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12},
     145            {"width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12},
     146            {"width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12},
     147            {"width": 100, "fn": calculateBatteryEfficiency, "verticalOffset": 12},
     148            {"width": 100, "fn": calculateTradeIncome, "verticalOffset": 12}
    114149        ],
    115150        "teamCounterFn": calculateMarketTeam
    116151    },
    117152    {   // miscellaneous panel
    118153        "headings": [   // headings on miscellaneous panel
     
    122157            { "caption": translate("Kill / Death\nratio"), "yStart": 16, "width": 100 },
    123158            { "caption": translate("Map\nexploration"), "yStart": 16, "width": 100 }
    124159        ],
    125160        "titleHeadings": [],
    126161        "counters": [   // counters on miscellaneous panel
    127             {"width": 100, "fn": calculateVegetarianRatio},
    128             {"width": 100, "fn": calculateFeminisation},
    129             {"width": 100, "fn": calculateKillDeathRatio},
    130             {"width": 100, "fn": calculateMapExploration}
     162            {"width": 100, "fn": calculateVegetarianRatio, "verticalOffset": 12},
     163            {"width": 100, "fn": calculateFeminisation, "verticalOffset": 12},
     164            {"width": 100, "fn": calculateKillDeathRatio, "verticalOffset": 12},
     165            {"width": 100, "fn": calculateMapExploration, "verticalOffset": 12}
    131166        ],
    132167        "teamCounterFn": calculateMiscellaneous
    133168    }
    134169];
    135170
     
    187222
    188223function updateGeneralPanelCounter(counters)
    189224{
    190225    var rowPlayerObjectWidth = 0;
    191226    var left = 0;
     227       
    192228    for (var p = 0; p < MAX_SLOTS; ++p)
    193229    {
    194230        left = 240;
    195231        var counterObject;
    196232        for (var w in counters)
    197233        {
    198234            counterObject = Engine.GetGUIObjectByName("valueData[" + p + "][" + w + "]");
    199             counterObject.size = left + " 6 " + (left + counters[w].width) + " 100%";
     235            counterObject.size = left + " " + counters[w].verticalOffset + " " + (left + counters[w].width) + " 100%";
    200236            counterObject.hidden = false;
    201237            left += counters[w].width;
    202238        }
    203239        if (rowPlayerObjectWidth == 0)
    204240            rowPlayerObjectWidth = left;
     
    208244        {
    209245            left = 240;
    210246            for (var w in counters)
    211247            {
    212248                counterObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]");
    213                 counterObject.size = left + " 6 " + (left + counters[w].width) + " 100%";
     249                counterObject.size = left + " " + counters[w].verticalOffset + " " + (left + counters[w].width) + " 100%";
    214250                counterObject.hidden = false;
    215251
    216252                if (g_Teams[t])
    217253                {
    218                     var yStart = 30 + g_Teams[t] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 2;
     254                    let yStart = 25 + g_Teams[t] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 3 + counters[w].verticalOffset;
    219255                    counterTotalObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]");
    220256                    counterTotalObject.size = (left + 20) + " " + yStart + " " + (left + counters[w].width) + " 100%";
    221257                    counterTotalObject.hidden = false;
    222258                }
    223259
     
    250286
    251287        yStart += 30 + g_Teams[i] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 32;
    252288
    253289        Engine.GetGUIObjectByName("teamNameHeadingt["+i+"]").caption = "Team "+(i+1);
    254290
    255         var teamHeading = Engine.GetGUIObjectByName("teamHeadingt["+i+"]");
    256         var yStartTotal = 30 + g_Teams[i] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 2;
    257         teamHeading.size = "50 "+yStartTotal+" 100% "+(yStartTotal+20);
     291        let teamHeading = Engine.GetGUIObjectByName("teamHeadingt["+i+"]");
     292        let yStartTotal = 30 + g_Teams[i] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 10;
     293        teamHeading.size = "50 " + yStartTotal + " 100% " + (yStartTotal + 20);
    258294        teamHeading.caption = translate("Team total");
    259295    }
    260296    // If there are no players without team, hide "player name" heading
    261297    if (!g_WithoutTeam)
    262298        Engine.GetGUIObjectByName("playerNameHeading").caption = "";
  • binaries/data/mods/public/gui/summary/summary.js

     
    44const MAX_HEADINGTITLE = 8;
    55
    66// const for filtering long collective headings
    77const LONG_HEADING_WIDTH = 250;
    88// Vertical size of player box
    9 const PLAYER_BOX_Y_SIZE = 30;
     9const PLAYER_BOX_Y_SIZE = 40;
    1010// Gap between players boxes
    1111const PLAYER_BOX_GAP = 2;
    1212// Alpha for player box
    1313const PLAYER_BOX_ALPHA = " 32";
    1414// Alpha for player color box
    1515const PLAYER_COLOR_BOX_ALPHA = " 255";
    1616// yStart value for spacing teams boxes (and noTeamsBox)
    17 const TEAMS_BOX_Y_START = 65;
     17const TEAMS_BOX_Y_START = 40;
    1818// Colors used for units and buildings
    1919const TRAINED_COLOR = '[color="201 255 200"]';
    2020const LOST_COLOR = '[color="255 213 213"]';
    2121const KILLED_COLOR = '[color="196 198 255"]';
     22const CAPTURED_COLOR = '[color="255 255 157"]';
    2223
    2324const BUILDINGS_TYPES = [ "total", "House", "Economic", "Outpost", "Military", "Fortress", "CivCentre", "Wonder" ];
    2425const UNITS_TYPES = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship" ];
    2526const RESOURCES_TYPES = [ "food", "wood", "stone", "metal" ];
    2627
  • binaries/data/mods/public/gui/summary/summary.xml

     
    117117                <object type="image" name="teamBoxt[i]" size="0 65 100% 100%-50" hidden="true">
    118118                    <object type="text" name="teamNameHeadingt[i]" size="15 5 100% 100%" style="ModernLeftTabLabelText"/>
    119119                    <object size="0 30 100% 100%">
    120120                        <repeat count="8" var="n">
    121121                            <object type="image" name="playerBoxt[i][n]" size="10 0 10 30" hidden="true">
    122                                 <object name="playerColorBoxt[i][n]" type="image" size="10 4 30 24"/>
     122                                <object type="image" sprite="ForegroundBox" size="10 9 34 33">
     123                                    <object name="playerColorBoxt[i][n]" type="image" size="2 2 22 22"/>
     124                                </object>
    123125                                <object name="playerNamet[i][n]" type="text"  size="40 2 208 100%" style="ModernLeftLabelText" />
    124                                 <object name="civIcont[i][n]" type="image" size="208 0 240 32"/>
     126                                <object name="civIcont[i][n]" type="image" size="208 5 240 37"  tooltip_style="sessionToolTip"/>
    125127                                <repeat var="x" count="8">
    126128                                    <object name="valueDataTeam[i][n][x]" type="text" style="ModernTabLabelText">
    127129                                    </object>
    128130                                </repeat>
    129131                            </object>
     
    138140            </repeat>
    139141
    140142            <object type="image" name="noTeamsBox" size="0 65 100% 100%-50" hidden="true">
    141143                <repeat count="8">
    142144                    <object type="image" name="playerBox[n]" size="10 0 10 30" hidden="true">
    143                         <object type="image" sprite="ForegroundBox" size="10 4 34 28">
     145                        <object type="image" sprite="ForegroundBox" size="10 9 34 33">
    144146                            <object name="playerColorBox[n]" type="image" size="2 2 22 22"/>
    145147                        </object>
    146148                        <object name="playerName[n]" type="text"  size="40 2 208 100%" style="ModernLeftLabelText"/>
    147                         <object name="civIcon[n]" type="image" size="208 0 240 32"/>
     149                        <object name="civIcon[n]" type="image" size="208 5 240 37"/>
    148150                        <repeat var="x" count="8">
    149151                            <object name="valueData[n][x]" type="text" style="ModernTabLabelText">
    150152                            </object>
    151153                        </repeat>
    152154                    </object>
  • binaries/data/mods/public/simulation/components/Capturable.js

     
    149149    var bestPlayer = 0;
    150150    for (let i in this.cp)
    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()
    158166{
    159167    var regenRate = +this.template.RegenRate;
  • binaries/data/mods/public/simulation/components/StatisticsTracker.js

     
    8787        "CivCentre": 0,
    8888        "Wonder": 0,
    8989        "total": 0
    9090        };
    9191    this.enemyBuildingsDestroyedValue = 0;
     92    this.buildingsCaptured = {
     93        "House": 0,
     94        "Economic": 0,
     95        "Outpost": 0,
     96        "Military": 0,
     97        "Fortress": 0,
     98        "CivCentre": 0,
     99        "Wonder": 0,
     100        "total": 0
     101    };
     102    this.buildingsCapturedValue = 0;
    92103    // resources
    93104    this.resourcesGathered = {
    94105        "food": 0,
    95106        "wood": 0,
    96107        "metal": 0,
     
    148159        "buildingsConstructed": this.buildingsConstructed,
    149160        "buildingsLost": this.buildingsLost,
    150161        "buildingsLostValue": this.buildingsLostValue,
    151162        "enemyBuildingsDestroyed": this.enemyBuildingsDestroyed,
    152163        "enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue,
     164        "buildingsCaptured": this.buildingsCaptured,
     165        "buildingsCapturedValue": this.buildingsCapturedValue,
    153166        "resourcesGathered": this.resourcesGathered,
    154167        "resourcesUsed": this.resourcesUsed,
    155168        "resourcesSold": this.resourcesSold,
    156169        "resourcesBought": this.resourcesBought,
    157170        "tributesSent": this.tributesSent,
     
    292305        for each (var cost in costs)
    293306            this.buildingsLostValue += cost;
    294307    }
    295308};
    296309
     310StatisticsTracker.prototype.CapturedBuilding = function(capturedBuilding)
     311{
     312    let cmpCapturedBuildingIdentity = Engine.QueryInterface(capturedBuilding, IID_Identity);
     313    let cmpCost = Engine.QueryInterface(capturedBuilding, IID_Cost);
     314    let costs = cmpCost.GetResourceCosts();
     315
     316    for (let type of this.buildingsClasses)
     317        this.CounterIncrement(cmpCapturedBuildingIdentity, "buildingsCaptured", type);
     318   
     319    this.buildingsCaptured.total++;
     320   
     321    for (let i in costs)
     322        this.buildingsCapturedValue += costs[i];
     323};
     324
    297325/**
    298326 * @param type Generic type of resource (string)
    299327 * @param amount Amount of resource, whick should be added (integer)
    300328 * @param specificType Specific type of resource (string, optional)
    301329 */