Ticket #3216: t3216_capture_statistics_v11.2.patch
File t3216_capture_statistics_v11.2.patch, 23.6 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/summary/counters.js
12 12 g_KilledColor + killed + '[/color]'; 13 13 } 14 14 15 function 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 15 23 function formatIncome(income, outcome) 16 24 { 17 25 return g_IncomeColor + income + '[/color] / ' + … … 37 45 return Math.round(divident / divisor * 100) / 100; 38 46 } 39 47 48 function cleanGUICaption(caption) 49 { 50 return caption.replace(/\[([\w\' \\\"\/\=]*)\]|\s/g, ""); 51 } 52 40 53 function updateCountersPlayer(playerState, counters, idGUI) 41 54 { 42 55 for (let w in counters) … … 97 110 function calculateMilitaryScore(playerState) 98 111 { 99 112 return Math.round((playerState.statistics.enemyUnitsKilledValue + 100 playerState.statistics.enemyBuildingsDestroyedValue) / 10); 113 playerState.statistics.enemyBuildingsDestroyedValue + 114 playerState.statistics.buildingsCapturedValue) / 10); 101 115 } 102 116 103 117 function calculateExplorationScore(playerState) … … 144 158 function calculateBuildings(playerState, position) 145 159 { 146 160 let type = g_BuildingsTypes[position]; 147 148 return formatTrained( 161 return formatCaptured( 149 162 playerState.statistics.buildingsConstructed[type], 150 playerState.statistics.buildingsLost[type], 151 playerState.statistics.enemyBuildingsDestroyed[type]); 163 playerState.statistics.enemyBuildingsDestroyed[type], 164 playerState.statistics.buildingsCaptured[type], 165 playerState.statistics.buildingsLost[type]); 152 166 } 153 167 154 function calculate ColorsTeam(counters)168 function calculateBuildingsTeam(counters) 155 169 { 156 170 for (let t in g_Teams) 157 171 { … … 161 175 for (let w in counters) 162 176 { 163 177 let total = { 178 "constructed" : 0, 179 "destroyed" : 0, 180 "captured" : 0, 181 "lost" : 0 182 }; 183 for (let p = 0; p < g_Teams[t]; ++p) 184 { 185 let caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption; 186 // clean [Color=""], [/Color] and white space for make the sum more easy 187 caption = caption.replace(/\[([\w\' \\\"\/\=]*)\]|[\t\r \f]/g, ""); 188 189 let splitCaption = caption.split("\n"); 190 let first = splitCaption[0].split("/"); 191 let second = splitCaption[1].split("/"); 192 193 total.constructed += +first[0]; 194 total.destroyed += +first[1]; 195 total.captured += +second[0]; 196 total.lost += +second[1]; 197 } 198 let teamTotal = formatCaptured(total.constructed, 199 total.destroyed, total.captured, total.lost); 200 201 Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal; 202 } 203 } 204 } 205 206 function calculateUnitsTeam(counters) 207 { 208 for (let t in g_Teams) 209 { 210 if (t == -1) 211 continue; 212 213 for (let w in counters) 214 { 215 let total = { 164 216 "constructed": 0, 165 217 "lost": 0, 166 218 "destroyed": 0 … … 170 222 { 171 223 let caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption; 172 224 // clean [Color=""], [/Color] and white space for make the sum more easy 173 caption = c aption.replace(/\[([\w\' \\\"\/\=]*)\]|\s/g, "");225 caption = cleanGUICaption(caption); 174 226 175 227 let splitCaption = caption.split("/"); 176 228 … … 253 305 { 254 306 let caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption; 255 307 // clean [Color=""], [/Color] and white space for make the sum more easy 256 caption = c aption.replace(/\[([\w\' \\\"\/\=]*)\]|\s/g, "");308 caption = cleanGUICaption(caption); 257 309 258 310 if (w >= 6) 259 311 total.income += +caption; … … 329 381 total.income += +caption; 330 382 else 331 383 { 332 let splitCaption = caption.split(" -");384 let splitCaption = caption.split("/"); 333 385 total.income += +splitCaption[0]; 334 386 total.outcome += +splitCaption[1]; 335 387 } -
binaries/data/mods/public/gui/summary/layout.js
9 9 ], 10 10 "titleHeadings": [], 11 11 "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 } 16 16 ], 17 17 "teamCounterFn": calculateScoreTeam 18 18 }, … … 29 29 { "caption": translate("Wonders"), "yStart": 34, "width": 85 } 30 30 ], 31 31 "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 33 43 ], 34 44 "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 } 43 53 ], 44 "teamCounterFn": calculate ColorsTeam54 "teamCounterFn": calculateBuildingsTeam 45 55 }, 46 56 "units": { 47 57 "headings": [ … … 56 66 { "caption": translate("Traders"), "yStart": 34, "width": 100 } 57 67 ], 58 68 "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 60 79 ], 61 80 "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 } 70 89 ], 71 "teamCounterFn": calculate ColorsTeam90 "teamCounterFn": calculateUnitsTeam 72 91 }, 73 92 "resources": { 74 93 "headings": [ … … 78 97 { "caption": translate("Stone"), "yStart": 34, "width": 100 }, 79 98 { "caption": translate("Metal"), "yStart": 34, "width": 100 }, 80 99 { "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 }, 82 109 { "caption": translate("Treasures collected"), "yStart": 16, "width": 100 }, 83 110 { "caption": translate("Loot"), "yStart": 16, "width": 100 } 84 111 ], 85 112 "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 87 122 ], 88 123 "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 } 97 132 ], 98 133 "teamCounterFn": calculateResourcesTeam 99 134 }, … … 109 144 ], 110 145 "titleHeadings": [], 111 146 "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 } 118 153 ], 119 154 "teamCounterFn": calculateMarketTeam 120 155 }, … … 132 167 { "caption": translate("Map control"), "xOffset": 400, "yStart": 16, "width": 200 } 133 168 ], 134 169 "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 } 141 176 ], 142 177 "teamCounterFn": calculateMiscellaneous 143 178 } … … 214 249 for (let w in counters) 215 250 { 216 251 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%"; 218 253 counterObject.hidden = false; 219 254 left += counters[w].width; 220 255 } … … 229 264 for (let w in counters) 230 265 { 231 266 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%"; 233 268 counterObject.hidden = false; 234 269 235 270 if (g_Teams[t]) 236 271 { 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; 238 273 counterTotalObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]"); 239 274 counterTotalObject.size = (left + 20) + " " + yStart + " " + (left + counters[w].width) + " 100%"; 240 275 counterTotalObject.hidden = false; … … 272 307 Engine.GetGUIObjectByName("teamNameHeadingt["+i+"]").caption = "Team "+(i+1); 273 308 274 309 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); 277 312 teamHeading.caption = translate("Team total"); 278 313 } 279 314 -
binaries/data/mods/public/gui/summary/summary.js
3 3 // const for filtering long collective headings 4 4 const g_LongHeadingWidth = 250; 5 5 6 const g_PlayerBoxYSize = 30;6 const g_PlayerBoxYSize = 40; 7 7 const g_PlayerBoxGap = 2; 8 8 const g_PlayerBoxAlpha = " 32"; 9 9 const g_PlayerColorBoxAlpha = " 255"; 10 const g_TeamsBoxYStart = 65;10 const g_TeamsBoxYStart = 40; 11 11 12 12 // Colors used for units and buildings 13 13 const g_TrainedColor = '[color="201 255 200"]'; 14 14 const g_LostColor = '[color="255 213 213"]'; 15 15 const g_KilledColor = '[color="196 198 255"]'; 16 const g_CapturedColor = '[color="255 255 157"]'; 16 17 17 18 const g_BuildingsTypes = [ "total", "House", "Economic", "Outpost", "Military", "Fortress", "CivCentre", "Wonder" ]; 18 19 const g_UnitsTypes = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship", "Trader" ]; -
binaries/data/mods/public/gui/summary/summary.xml
14 14 15 15 <!-- After settings.js, which defines g_Settings and g_MaxPlayers. --> 16 16 <script file="gui/summary/counters.js"/> 17 <script file="gui/summary/summary.js"/> 17 18 <script file="gui/summary/layout.js"/> 18 <script file="gui/summary/summary.js"/>19 19 20 20 <object name="summaryWindow" 21 21 type="image" … … 123 123 <object size="0 30 100% 100%"> 124 124 <repeat count="8" var="n"> 125 125 <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" /> 129 131 <repeat var="x" count="8"> 130 132 <object name="valueDataTeam[i][n][x]" type="text" style="ModernTabLabelText"> 131 133 </object> … … 144 146 <object type="image" name="noTeamsBox" size="0 65 100% 100%-50" hidden="true"> 145 147 <repeat count="8"> 146 148 <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"> 148 150 <object name="playerColorBox[n]" type="image" size="2 2 22 22"/> 149 151 </object> 150 152 <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"/> 152 154 <repeat var="x" count="8"> 153 155 <object name="valueData[n][x]" type="text" style="ModernTabLabelText"> 154 156 </object> -
binaries/data/mods/public/simulation/components/Capturable.js
151 151 if (this.cp[i] >= this.cp[bestPlayer]) 152 152 bestPlayer = +i; 153 153 154 let cmpLostPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker); 155 if (cmpLostPlayerStatisticsTracker) 156 cmpLostPlayerStatisticsTracker.LostEntity(this.entity); 157 154 158 cmpOwnership.SetOwner(bestPlayer); 159 160 let cmpCapturedPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker); 161 if (cmpCapturedPlayerStatisticsTracker) 162 cmpCapturedPlayerStatisticsTracker.CapturedBuilding(this.entity); 155 163 }; 156 164 157 165 Capturable.prototype.GetRegenRate = function() -
binaries/data/mods/public/simulation/components/StatisticsTracker.js
93 93 "total": 0 94 94 }; 95 95 this.enemyBuildingsDestroyedValue = 0; 96 this.buildingsCaptured = { 97 "House": 0, 98 "Economic": 0, 99 "Outpost": 0, 100 "Military": 0, 101 "Fortress": 0, 102 "CivCentre": 0, 103 "Wonder": 0, 104 "total": 0 105 }; 106 this.buildingsCapturedValue = 0; 96 107 // resources 97 108 this.resourcesGathered = { 98 109 "food": 0, … … 152 163 "unitsLostValue": this.unitsLostValue, 153 164 "enemyUnitsKilled": this.enemyUnitsKilled, 154 165 "enemyUnitsKilledValue": this.enemyUnitsKilledValue, 155 "buildingsConstructed": this.buildingsConstructed, 156 "buildingsLost": this.buildingsLost, 166 "buildingsConstructed": this.buildingsConstructed, 167 "buildingsLost": this.buildingsLost, 157 168 "buildingsLostValue": this.buildingsLostValue, 158 169 "enemyBuildingsDestroyed": this.enemyBuildingsDestroyed, 159 170 "enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue, 171 "buildingsCaptured": this.buildingsCaptured, 172 "buildingsCapturedValue": this.buildingsCapturedValue, 160 173 "resourcesGathered": this.resourcesGathered, 161 174 "resourcesUsed": this.resourcesUsed, 162 175 "resourcesSold": this.resourcesSold, 163 "resourcesBought": this.resourcesBought, 164 "tributesSent": this.tributesSent, 176 "resourcesBought": this.resourcesBought, 177 "tributesSent": this.tributesSent, 165 178 "tributesReceived": this.tributesReceived, 166 179 "tradeIncome": this.tradeIncome, 167 180 "treasuresCollected": this.treasuresCollected, … … 216 229 StatisticsTracker.prototype.IncreaseConstructedBuildingsCounter = function(constructedBuilding) 217 230 { 218 231 var cmpBuildingEntityIdentity = Engine.QueryInterface(constructedBuilding, IID_Identity); 219 232 220 233 if (!cmpBuildingEntityIdentity) 221 234 return; 222 235 … … 253 266 this.CounterIncrement(cmpTargetEntityIdentity, "enemyUnitsKilled", type); 254 267 255 268 this.enemyUnitsKilled.total++; 256 269 257 270 for each (var cost in costs) 258 271 this.enemyUnitsKilledValue += cost; 259 } 272 } 260 273 if (targetIsStructure) 261 274 { 262 275 for each (var type in this.buildingsClasses) … … 263 276 this.CounterIncrement(cmpTargetEntityIdentity, "enemyBuildingsDestroyed", type); 264 277 265 278 this.enemyBuildingsDestroyed.total++; 266 279 267 280 for each (var cost in costs) 268 281 this.enemyBuildingsDestroyedValue += cost; 269 282 } … … 276 289 var costs = cmpCost.GetResourceCosts(); 277 290 if (!cmpLostEntityIdentity) 278 291 return; 279 292 280 293 var cmpFoundation = Engine.QueryInterface(lostEntity, IID_Foundation); 281 294 // We want to deal only with real structures, not foundations 282 295 var lostEntityIsStructure = cmpLostEntityIdentity.HasClass("Structure") && cmpFoundation == null; … … 290 303 this.CounterIncrement(cmpLostEntityIdentity, "unitsLost", type); 291 304 292 305 this.unitsLost.total++; 293 306 294 307 for each (var cost in costs) 295 308 this.unitsLostValue += cost; 296 } 309 } 297 310 if (lostEntityIsStructure) 298 311 { 299 312 for each (var type in this.buildingsClasses) … … 306 319 } 307 320 }; 308 321 309 /** 310 * @param type Generic type of resource (string) 311 * @param amount Amount of resource, whick should be added (integer) 312 * @param specificType Specific type of resource (string, optional) 313 */ 322 StatisticsTracker.prototype.CapturedBuilding = function(capturedBuilding) 323 { 324 let cmpCapturedBuildingIdentity = Engine.QueryInterface(capturedBuilding, IID_Identity); 325 let cmpCost = Engine.QueryInterface(capturedBuilding, IID_Cost); 326 if (!cmpCapturedBuildingIdentity || !cmpCost) 327 return; 328 let costs = cmpCost.GetResourceCosts(); 329 330 for (let type of this.buildingsClasses) 331 this.CounterIncrement(cmpCapturedBuildingIdentity, "buildingsCaptured", type); 332 333 this.buildingsCaptured.total++; 334 335 for (let i in costs) 336 this.buildingsCapturedValue += costs[i]; 337 }; 338 339 /** 340 * @param type Generic type of resource (string) 341 * @param amount Amount of resource, whick should be added (integer) 342 * @param specificType Specific type of resource (string, optional) 343 */ 314 344 StatisticsTracker.prototype.IncreaseResourceGatheredCounter = function(type, amount, specificType) 315 345 { 316 346 this.resourcesGathered[type] += amount; 317 347 318 348 if (type == "food" && (specificType == "fruit" || specificType == "grain")) 319 349 this.resourcesGathered.vegetarianFood += amount; 320 350 }; -
binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
126 126 "unitsTrained": 10, 127 127 "unitsLost": 9, 128 128 "buildingsConstructed": 5, 129 "buildingsCaptured": 7, 129 130 "buildingsLost": 4, 130 131 "civCentresBuilt": 1, 131 132 "resourcesGathered": { … … 208 209 "unitsTrained": 10, 209 210 "unitsLost": 9, 210 211 "buildingsConstructed": 5, 212 "buildingsCaptured": 7, 211 213 "buildingsLost": 4, 212 214 "civCentresBuilt": 1, 213 215 "resourcesGathered": { … … 362 364 unitsTrained: 10, 363 365 unitsLost: 9, 364 366 buildingsConstructed: 5, 367 buildingsCaptured: 7, 365 368 buildingsLost: 4, 366 369 civCentresBuilt: 1, 367 370 resourcesGathered: { … … 415 418 unitsTrained: 10, 416 419 unitsLost: 9, 417 420 buildingsConstructed: 5, 421 buildingsCaptured: 7, 418 422 buildingsLost: 4, 419 423 civCentresBuilt: 1, 420 424 resourcesGathered: {