Ticket #686: summary_screen_counters.patch
File summary_screen_counters.patch, 51.3 KB (added by , 10 years ago) |
---|
-
binaries/data/mods/public/gui/summary/summary.js
1 1 // Max player slots for any map (should read from config) 2 2 const MAX_SLOTS = 8; 3 3 4 var panelNames = [ 'scorePanel', ' unitsBuildingsPanel', 'conquestPanel', 'resourcesPanel', 'marketPanel' ];5 var panelButtonNames = [ 'scorePanelButton', ' unitsBuildingsPanelButton', 'conquestPanelButton', 'resourcesPanelButton', 'marketPanelButton' ];4 var panelNames = [ 'scorePanel', 'buildingsPanel', 'unitsPanel', 'conquestPanel', 'resourcesPanel', 'marketPanel', 'miscPanel' ]; 5 var panelButtonNames = [ 'scorePanelButton', 'buildingsPanelButton', 'unitsPanelButton', 'conquestPanelButton', 'resourcesPanelButton', 'marketPanelButton', 'miscPanelButton' ]; 6 6 7 7 /** 8 8 * Select active panel … … 36 36 37 37 function init(data) 38 38 { 39 // colours used for units and buildings 40 const TRAINED_COLOR = '[color="201 255 200"]'; 41 const LOST_COLOR = '[color="255 213 213"]'; 42 const KILLED_COLOR = '[color="196 198 255"]'; 43 44 // colours used for gathered and traded resources 45 const SOLD_COLOR = '[color="201 255 200"]'; 46 const BOUGHT_COLOR = '[color="255 213 213"]'; 47 48 function captionUnits(type) 49 { 50 return TRAINED_COLOR + playerState.statistics.unitsTrained[type] + "[/color] / " 51 + LOST_COLOR + playerState.statistics.unitsLost[type] + "[/color] / " 52 + KILLED_COLOR + playerState.statistics.enemyUnitsKilled[type] + "[/color]"; 53 } 54 55 function captionBuildings(type) 56 { 57 return TRAINED_COLOR + playerState.statistics.buildingsConstructed[type] + "[/color] / " 58 + LOST_COLOR + playerState.statistics.buildingsLost[type] + "[/color] / " 59 + KILLED_COLOR + playerState.statistics.enemyBuildingsDestroyed[type] + "[/color]"; 60 } 61 62 function captionResourcesGathered(type) 63 { 64 return SOLD_COLOR + playerState.statistics.resourcesGathered[type] + "[/color] / " 65 + BOUGHT_COLOR + (playerState.statistics.resourcesUsed[type] - playerState.statistics.resourcesSold[type]) + "[/color]"; 66 } 67 68 function captionResourcesExchanged(type) 69 { 70 return SOLD_COLOR + '+' + playerState.statistics.resourcesBought[type] + '[/color] ' 71 + BOUGHT_COLOR + '-' + playerState.statistics.resourcesSold[type] + '[/color]'; 72 } 73 39 74 var civData = loadCivData(); 40 75 var mapSize = "Scenario"; 41 76 … … 86 121 var playerNameHeadingWidth = 200; 87 122 // Special cased to make the (Sent / Received) part fit 88 123 var tributesWidth = 121; 124 // Special cased to make the (total buildings) part fit 125 var totalBuildingsWidth = 105; 126 // Special cased to make the (total units) part fit 127 var totalUnitsWidth = 120; 128 // Special cased to make the (total gathered resources) part fit 129 var totalGatheredWidth = 110; 89 130 getGUIObjectByName("playerName0Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth; 90 131 getGUIObjectByName("economyScoreHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 91 132 getGUIObjectByName("militaryScoreHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; … … 93 134 getGUIObjectByName("totalScoreHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 94 135 95 136 left = 50; 137 width = 85; 96 138 getGUIObjectByName("playerName1Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth; 97 getGUIObjectByName("unitsTrainedHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 98 getGUIObjectByName("unitsLostHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 99 getGUIObjectByName("enemyUnitsKilledHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 100 getGUIObjectByName("buildingsConstructedHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 101 getGUIObjectByName("buildingsLostHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 102 getGUIObjectByName("enemyBuildingsDestroyedHeading").size = left + " 6 " + (left + width) + " 100%"; left += width; 139 getGUIObjectByName("buildingsHeading").size = left + " 16 " + (left + width * 6 + totalBuildingsWidth) + " 100%"; 140 getGUIObjectByName("totalBuildingsHeading").size = left + " 34 " + (left + totalBuildingsWidth) + " 100%"; left += totalBuildingsWidth; 141 getGUIObjectByName("houseBuildingsHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 142 getGUIObjectByName("economicBuildingsHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 143 getGUIObjectByName("outpostBuildingsHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 144 getGUIObjectByName("militaryBuildingsHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 145 getGUIObjectByName("fortressBuildingsHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 146 getGUIObjectByName("specialBuildingsHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 147 getGUIObjectByName("wonderBuildingsHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 148 103 149 104 150 left = 50; 151 width = 100; 105 152 getGUIObjectByName("playerName2Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth; 153 getGUIObjectByName("unitsHeading").size = left + " 16 " + (left + width * 6 + totalUnitsWidth) + " 100%"; 154 getGUIObjectByName("totalUnitsHeading").size = left + " 34 " + (left + totalUnitsWidth) + " 100%"; left += totalUnitsWidth; 155 getGUIObjectByName("infantryUnitsHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 156 getGUIObjectByName("workerUnitsHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 157 getGUIObjectByName("cavalryUnitsHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 158 getGUIObjectByName("championUnitsHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 159 getGUIObjectByName("heroesUnitsHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 160 getGUIObjectByName("navyUnitsHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 161 162 left = 50; 163 width = 100; 164 getGUIObjectByName("playerName3Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth; 106 165 getGUIObjectByName("civCentresBuiltHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 107 166 getGUIObjectByName("enemyCivCentresDestroyedHeading").size = left + " 6 " + (left + width) + " 100%"; left += width; 108 getGUIObjectByName("mapExplorationHeading").size = left + " 6 " + (left + width) + " 100%"; left += width;167 getGUIObjectByName("mapExplorationHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 109 168 110 169 left = 50; 111 getGUIObjectByName("playerName3Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth; 112 getGUIObjectByName("resourceHeading").size = left + " 16 " + (left + width * 4) + " 100%"; 170 width = 100; 171 getGUIObjectByName("playerName4Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth; 172 getGUIObjectByName("resourceHeading").size = left + " 16 " + (left + width * 4 + totalGatheredWidth) + " 100%"; 113 173 getGUIObjectByName("foodGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 114 174 getGUIObjectByName("woodGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 115 175 getGUIObjectByName("stoneGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 116 176 getGUIObjectByName("metalGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 117 getGUIObjectByName(" vegetarianRatioHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;177 getGUIObjectByName("totalGatheredHeading").size = left + " 34 " + (left + totalGatheredWidth) + " 100%"; left += totalGatheredWidth; 118 178 getGUIObjectByName("treasuresCollectedHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 119 179 getGUIObjectByName("resourcesTributedHeading").size = left + " 16 " + (left + tributesWidth) + " 100%"; left += tributesWidth; 120 180 121 181 left = 50; 122 getGUIObjectByName("playerName4Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth; 182 width = 100; 183 getGUIObjectByName("playerName5Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth; 123 184 getGUIObjectByName("exchangedFoodHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 124 185 getGUIObjectByName("exchangedWoodHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 125 186 getGUIObjectByName("exchangedStoneHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; … … 126 187 getGUIObjectByName("exchangedMetalHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 127 188 getGUIObjectByName("barterEfficiencyHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 128 189 getGUIObjectByName("tradeIncomeHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 129 190 191 left = 50; 192 width = 100; 193 getGUIObjectByName("playerName6Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth; 194 getGUIObjectByName("vegetarianRatioHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 195 getGUIObjectByName("feminisationHeading").size = left + " 26 " + (left + width) + " 100%"; left += width; 196 getGUIObjectByName("killDeathRatioHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 197 198 130 199 // Show counters 131 200 for (var i = 0; i < MAX_SLOTS; ++i) 132 201 { … … 160 229 var militaryScore = getGUIObjectByName("militaryScore["+i+"]"); 161 230 var explorationScore = getGUIObjectByName("explorationScore["+i+"]"); 162 231 var totalScore = getGUIObjectByName("totalScore["+i+"]"); 232 233 var totalBuildings = getGUIObjectByName("totalBuildings["+i+"]"); 234 var houseBuildings = getGUIObjectByName("houseBuildings["+i+"]"); 235 var economicBuildings = getGUIObjectByName("economicBuildings["+i+"]"); 236 var outpostBuildings = getGUIObjectByName("outpostBuildings["+i+"]"); 237 var militaryBuildings = getGUIObjectByName("militaryBuildings["+i+"]"); 238 var fortressBuildings = getGUIObjectByName("fortressBuildings["+i+"]"); 239 var specialBuildings = getGUIObjectByName("specialBuildings["+i+"]"); 240 var wonderBuildings = getGUIObjectByName("wonderBuildings["+i+"]"); 163 241 164 var unitsTrained = getGUIObjectByName("unitsTrained["+i+"]"); 165 var unitsLost = getGUIObjectByName("unitsLost["+i+"]"); 166 var enemyUnitsKilled = getGUIObjectByName("enemyUnitsKilled["+i+"]"); 167 var buildingsConstructed = getGUIObjectByName("buildingsConstructed["+i+"]"); 168 var buildingsLost = getGUIObjectByName("buildingsLost["+i+"]"); 169 var enemyBuildingsDestroyed = getGUIObjectByName("enemyBuildingsDestroyed["+i+"]"); 242 var totalUnits = getGUIObjectByName("totalUnits["+i+"]"); 243 var infantryUnits = getGUIObjectByName("infantryUnits["+i+"]"); 244 var workerUnits = getGUIObjectByName("workerUnits["+i+"]"); 245 var cavalryUnits = getGUIObjectByName("cavalryUnits["+i+"]"); 246 var championUnits = getGUIObjectByName("championUnits["+i+"]"); 247 var heroesUnits = getGUIObjectByName("heroesUnits["+i+"]"); 248 var navyUnits = getGUIObjectByName("navyUnits["+i+"]"); 170 249 171 250 var civCentresBuilt = getGUIObjectByName("civCentresBuilt["+i+"]"); 172 251 var enemyCivCentresDestroyed = getGUIObjectByName("enemyCivCentresDestroyed["+i+"]"); … … 176 255 var woodGathered = getGUIObjectByName("woodGathered["+i+"]"); 177 256 var stoneGathered = getGUIObjectByName("stoneGathered["+i+"]"); 178 257 var metalGathered = getGUIObjectByName("metalGathered["+i+"]"); 179 var vegetarianRatio = getGUIObjectByName("vegetarianRatio["+i+"]");258 var totalGathered = getGUIObjectByName("totalGathered["+i+"]"); 180 259 var treasuresCollected = getGUIObjectByName("treasuresCollected["+i+"]"); 181 260 var resourcesTributed = getGUIObjectByName("resourcesTributed["+i+"]"); 182 261 … … 186 265 var exchangedMetal = getGUIObjectByName("exchangedMetal["+i+"]"); 187 266 var barterEfficiency = getGUIObjectByName("barterEfficiency["+i+"]"); 188 267 var tradeIncome = getGUIObjectByName("tradeIncome["+i+"]"); 268 269 var vegetarianRatio = getGUIObjectByName("vegetarianRatio["+i+"]"); 270 var feminisationRatio = getGUIObjectByName("feminisation["+i+"]"); 271 var killDeathRatio = getGUIObjectByName("killDeathRatio["+i+"]"); 189 272 190 273 // align counters 191 274 … … 200 283 getGUIObjectByName("playerBox0["+i+"]").size = size; 201 284 202 285 left = 240; 203 unitsTrained.size = left + " 2 " + (left + width) + " 100%"; left += width; 204 unitsLost.size = left + " 2 " + (left + width) + " 100%"; left += width; 205 enemyUnitsKilled.size = left + " 2 " + (left + width) + " 100%"; left += width; 206 buildingsConstructed.size = left + " 2 " + (left + width) + " 100%"; left += width; 207 buildingsLost.size = left + " 2 " + (left + width) + " 100%"; left += width; 208 enemyBuildingsDestroyed.size = left + " 2 " + (left + width) + " 100%"; left += width; 286 width = 85; 287 totalBuildings.size = left + " 2 " + (left + width + 20) + " 100%"; left += width + 20; 288 houseBuildings.size = left + " 2 " + (left + width) + " 100%"; left += width; 289 economicBuildings.size = left + " 2 " + (left + width) + " 100%"; left += width; 290 outpostBuildings.size = left + " 2 " + (left + width) + " 100%"; left += width; 291 militaryBuildings.size = left + " 2 " + (left + width) + " 100%"; left += width; 292 fortressBuildings.size = left + " 2 " + (left + width) + " 100%"; left += width; 293 specialBuildings.size = left + " 2 " + (left + width) + " 100%"; left += width; 294 wonderBuildings.size = left + " 2 " + (left + width) + " 100%"; left += width; 209 295 size = getGUIObjectByName("playerBox1["+i+"]").size; 210 296 size.right = left + 10; 211 297 getGUIObjectByName("playerBox1["+i+"]").size = size; 298 299 left = 240; 300 width = 100; 301 totalUnits.size = left + " 2 " + (left + width + 20) + " 100%"; left += width + 20; 302 infantryUnits.size = left + " 2 " + (left + width) + " 100%"; left += width; 303 workerUnits.size = left + " 2 " + (left + width) + " 100%"; left += width; 304 cavalryUnits.size = left + " 2 " + (left + width) + " 100%"; left += width; 305 championUnits.size = left + " 2 " + (left + width) + " 100%"; left += width; 306 heroesUnits.size = left + " 2 " + (left + width) + " 100%"; left += width; 307 navyUnits.size = left + " 2 " + (left + width) + " 100%"; left += width; 308 size = getGUIObjectByName("playerBox2["+i+"]").size; 309 size.right = left + 10; 310 getGUIObjectByName("playerBox2["+i+"]").size = size; 212 311 213 312 left = 240; 313 width = 100; 214 314 civCentresBuilt.size = left + " 2 " + (left + width) + " 100%"; left += width; 215 315 enemyCivCentresDestroyed.size = left + " 2 " + (left + width) + " 100%"; left += width; 216 316 mapExploration.size = left + " 2 " + (left + width) + " 100%"; left += width; 217 size = getGUIObjectByName("playerBox 2["+i+"]").size;317 size = getGUIObjectByName("playerBox3["+i+"]").size; 218 318 size.right = left + 10; 219 getGUIObjectByName("playerBox 2["+i+"]").size = size;319 getGUIObjectByName("playerBox3["+i+"]").size = size; 220 320 221 321 left = 240; 322 width = 100; 222 323 foodGathered.size = left + " 2 " + (left + width) + " 100%"; left += width; 223 324 woodGathered.size = left + " 2 " + (left + width) + " 100%"; left += width; 224 325 stoneGathered.size = left + " 2 " + (left + width) + " 100%"; left += width; 225 326 metalGathered.size = left + " 2 " + (left + width) + " 100%"; left += width; 226 vegetarianRatio.size = left + " 2 " + (left + width) + " 100%"; left += width;327 totalGathered.size = left + " 2 " + (left + width + 10) + " 100%"; left += width + 10; 227 328 treasuresCollected.size = left + " 2 " + (left + width) + " 100%"; left += width; 228 329 resourcesTributed.size = left + " 2 " + (left + tributesWidth) + " 100%"; left += tributesWidth; 229 size = getGUIObjectByName("playerBox 3["+i+"]").size;330 size = getGUIObjectByName("playerBox4["+i+"]").size; 230 331 size.right = left + 10; 231 getGUIObjectByName("playerBox 3["+i+"]").size = size;332 getGUIObjectByName("playerBox4["+i+"]").size = size; 232 333 233 334 left = 240; 335 width = 100; 234 336 exchangedFood.size = left + " 2 " + (left + width) + " 100%"; left += width; 235 337 exchangedWood.size = left + " 2 " + (left + width) + " 100%"; left += width; 236 338 exchangedStone.size = left + " 2 " + (left + width) + " 100%"; left += width; … … 237 339 exchangedMetal.size = left + " 2 " + (left + width) + " 100%"; left += width; 238 340 barterEfficiency.size = left + " 2 " + (left + width) + " 100%"; left += width; 239 341 tradeIncome.size = left + " 2 " + (left + width) + " 100%"; left += width; 240 size = getGUIObjectByName("playerBox 4["+i+"]").size;342 size = getGUIObjectByName("playerBox5["+i+"]").size; 241 343 size.right = left + 10; 242 getGUIObjectByName("playerBox4["+i+"]").size = size; 344 getGUIObjectByName("playerBox5["+i+"]").size = size; 345 346 left = 240; 347 width = 100; 348 size = getGUIObjectByName("playerBox6["+i+"]").size; 349 vegetarianRatio.size = left + " 2 " + (left + width) + " 100%"; left += width; 350 feminisationRatio.size = left + " 2 " + (left + width) + " 100%"; left += width; 351 killDeathRatio.size = left + " 2 " + (left + width) + " 100%"; left += width; 352 size.right = left + 10; 353 getGUIObjectByName("playerBox6["+i+"]").size = size; 243 354 244 355 // display counters 245 economyScore.caption = Math.round((playerState.statistics.resourcesGathered.food + playerState.statistics.resourcesGathered.wood + 246 playerState.statistics.resourcesGathered.stone + playerState.statistics.resourcesGathered.metal) / 10); 356 economyScore.caption = Math.round(playerState.statistics.resourcesGathered.total / 10); 247 357 militaryScore.caption = Math.round((playerState.statistics.enemyUnitsKilledValue + playerState.statistics.enemyBuildingsDestroyedValue) / 10); 248 358 explorationScore.caption = playerState.statistics.percentMapExplored * 10; 249 359 totalScore.caption = Number(economyScore.caption) + Number(militaryScore.caption) + Number(explorationScore.caption); 250 251 unitsTrained.caption = playerState.statistics.unitsTrained;252 unitsLost.caption = playerState.statistics.unitsLost;253 enemyUnitsKilled.caption = playerState.statistics.enemyUnitsKilled;254 buildingsConstructed.caption = playerState.statistics.buildingsConstructed;255 buildingsLost.caption = playerState.statistics.buildingsLost;256 enemyBuildingsDestroyed.caption = playerState.statistics.enemyBuildingsDestroyed;257 360 361 totalBuildings.caption = captionBuildings("total"); 362 houseBuildings.caption = captionBuildings("House"); 363 economicBuildings.caption = captionBuildings("Economic"); 364 outpostBuildings.caption = captionBuildings("Outpost"); 365 militaryBuildings.caption = captionBuildings("Military"); 366 fortressBuildings.caption = captionBuildings("Fortress"); 367 specialBuildings.caption = captionBuildings("SpecialBuilding"); 368 wonderBuildings.caption = captionBuildings("Wonder"); 369 370 totalUnits.caption = captionUnits("total"); 371 infantryUnits.caption = captionUnits("Infantry"); 372 workerUnits.caption = captionUnits("Worker"); 373 cavalryUnits.caption = captionUnits("Cavalry"); 374 championUnits.caption = captionUnits("Champion"); 375 heroesUnits.caption = captionUnits("Hero"); 376 navyUnits.caption = captionUnits("Ship"); 377 258 378 civCentresBuilt.caption = playerState.statistics.civCentresBuilt; 259 379 enemyCivCentresDestroyed.caption = playerState.statistics.enemyCivCentresDestroyed; 260 380 mapExploration.caption = playerState.statistics.percentMapExplored + "%"; 261 381 262 const SOLD_COLOR = '[color="201 255 200"]'; 263 const BOUGHT_COLOR = '[color="255 213 213"]'; 264 foodGathered.caption = SOLD_COLOR + playerState.statistics.resourcesGathered.food + "[/color] / " + 265 BOUGHT_COLOR + (playerState.statistics.resourcesUsed.food - playerState.statistics.resourcesSold.food) + "[/color]"; 266 woodGathered.caption = SOLD_COLOR + playerState.statistics.resourcesGathered.wood + "[/color] / " + 267 BOUGHT_COLOR + (playerState.statistics.resourcesUsed.wood - playerState.statistics.resourcesSold.wood) + "[/color]"; 268 stoneGathered.caption = SOLD_COLOR + playerState.statistics.resourcesGathered.stone + "[/color] / " + 269 BOUGHT_COLOR + (playerState.statistics.resourcesUsed.stone - playerState.statistics.resourcesSold.stone) + "[/color]"; 270 metalGathered.caption = SOLD_COLOR + playerState.statistics.resourcesGathered.metal + "[/color] / " + 271 BOUGHT_COLOR + (playerState.statistics.resourcesUsed.metal - playerState.statistics.resourcesSold.metal) + "[/color]"; 272 vegetarianRatio.caption = Math.floor(playerState.statistics.resourcesGathered.food > 0 ? 273 (playerState.statistics.resourcesGathered.vegetarianFood / playerState.statistics.resourcesGathered.food) * 100 : 0) + "%"; 382 foodGathered.caption = captionResourcesGathered("food"); 383 woodGathered.caption = captionResourcesGathered("wood"); 384 stoneGathered.caption = captionResourcesGathered("stone"); 385 metalGathered.caption = captionResourcesGathered("metal"); 386 totalGathered.caption = captionResourcesGathered("total"); 274 387 treasuresCollected.caption = playerState.statistics.treasuresCollected; 275 388 resourcesTributed.caption = SOLD_COLOR + playerState.statistics.tributesSent + "[/color] / " + 276 389 BOUGHT_COLOR + playerState.statistics.tributesReceived + "[/color]"; 277 390 278 exchangedFood.caption = SOLD_COLOR + '+' + playerState.statistics.resourcesBought.food 279 + '[/color] ' + BOUGHT_COLOR + '-' + playerState.statistics.resourcesSold.food + '[/color]'; 280 exchangedWood.caption = SOLD_COLOR + '+' + playerState.statistics.resourcesBought.wood 281 + '[/color] ' + BOUGHT_COLOR + '-' + playerState.statistics.resourcesSold.wood + '[/color]'; 282 exchangedStone.caption = SOLD_COLOR + '+' + playerState.statistics.resourcesBought.stone 283 + '[/color] ' + BOUGHT_COLOR + '-' + playerState.statistics.resourcesSold.stone + '[/color]'; 284 exchangedMetal.caption = SOLD_COLOR + '+' + playerState.statistics.resourcesBought.metal 285 + '[/color] ' + BOUGHT_COLOR + '-' + playerState.statistics.resourcesSold.metal + '[/color]'; 391 exchangedFood.caption = captionResourcesExchanged("food"); 392 exchangedWood.caption = captionResourcesExchanged("wood"); 393 exchangedStone.caption = captionResourcesExchanged("stone"); 394 exchangedMetal.caption = captionResourcesExchanged("metal"); 286 395 var totalBought = 0; 287 396 for each (var boughtAmount in playerState.statistics.resourcesBought) 288 397 totalBought += boughtAmount; … … 291 400 totalSold += soldAmount; 292 401 barterEfficiency.caption = Math.floor(totalSold > 0 ? (totalBought / totalSold) * 100 : 0) + "%"; 293 402 tradeIncome.caption = playerState.statistics.tradeIncome; 403 404 vegetarianRatio.caption = Math.floor(playerState.statistics.resourcesGathered.food > 0 ? 405 (playerState.statistics.resourcesGathered.vegetarianFood / playerState.statistics.resourcesGathered.food) * 100 : 0) + "%"; 406 feminisationRatio.caption = playerState.statistics.feminisation + "%"; 407 killDeathRatio.caption = Math.round((playerState.statistics.enemyUnitsKilled.total > 0 ? 408 (playerState.statistics.enemyUnitsKilled.total / playerState.statistics.unitsLost.total) : 0)*100)/100; 294 409 } 295 410 else 296 411 { -
binaries/data/mods/public/gui/summary/summary.xml
57 57 <object name="tabDividerLeft" type="image" sprite="TabSpacer" size="172 120 174 122"/> 58 58 <object name="tabDividerRight" type="image" sprite="TabSpacer" size="328 120 330 122"/> 59 59 60 <object name="scorePanelButton" type="button" sprite="ForegroundTab" size="20 95 170120">60 <object name="scorePanelButton" type="button" sprite="ForegroundTab" size="20 82 136 120"> 61 61 <action on="Press">selectPanel(0);</action> 62 62 <object type="text" style="TitleText" ghost="true">Score</object> 63 63 </object> 64 64 65 <object name=" unitsBuildingsPanelButton" type="button" sprite="BackgroundTab" size="176 95 326120">65 <object name="buildingsPanelButton" type="button" sprite="BackgroundTab" size="142 82 260 120"> 66 66 <action on="Press">selectPanel(1);</action> 67 <object type="text" style="TitleText" ghost="true"> Units/buildings</object>67 <object type="text" style="TitleText" ghost="true">Buildings</object> 68 68 </object> 69 69 70 <object name=" conquestPanelButton" type="button" sprite="BackgroundTab" size="332 95 480120">70 <object name="unitsPanelButton" type="button" sprite="BackgroundTab" size="266 82 384 120"> 71 71 <action on="Press">selectPanel(2);</action> 72 <object type="text" style="TitleText" ghost="true">Units</object> 73 </object> 74 75 <object name="conquestPanelButton" type="button" sprite="BackgroundTab" size="390 82 508 120"> 76 <action on="Press">selectPanel(3);</action> 72 77 <object type="text" style="TitleText" ghost="true">Conquest</object> 73 78 </object> 74 79 75 <object name="resourcesPanelButton" type="button" sprite="BackgroundTab" size=" 486 95 636120">76 <action on="Press">selectPanel( 3);</action>80 <object name="resourcesPanelButton" type="button" sprite="BackgroundTab" size="514 82 632 120"> 81 <action on="Press">selectPanel(4);</action> 77 82 <object type="text" style="TitleText" ghost="true">Resources</object> 78 83 </object> 79 84 80 <object name="marketPanelButton" type="button" sprite="BackgroundTab" size="6 42 95 792120">81 <action on="Press">selectPanel( 4);</action>85 <object name="marketPanelButton" type="button" sprite="BackgroundTab" size="638 82 756 120"> 86 <action on="Press">selectPanel(5);</action> 82 87 <object type="text" style="TitleText" ghost="true">Market</object> 83 88 </object> 84 89 90 <object name="miscPanelButton" type="button" sprite="BackgroundTab" size="762 82 880 120"> 91 <action on="Press">selectPanel(6);</action> 92 <object type="text" style="TitleText" ghost="true">Miscellaneous</object> 93 </object> 94 85 95 <object name="scorePanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100%-58"> 86 96 87 97 <object size="0 0 100% 100%-50"> … … 117 127 </object> 118 128 119 129 </object> 120 <object name=" unitsBuildingsPanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100%-58" hidden="true">130 <object name="buildingsPanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100%-58" hidden="true"> 121 131 122 132 <object size="0 0 100% 100%-50"> 123 133 <object name="playerName1Heading" type="text" style="LeftTabLabelText"> 124 134 Player name 125 135 </object> 126 <object name=" unitsTrainedHeading" type="text" style="CenteredTabLabelText">127 Units trained136 <object name="buildingsHeading" type="text" style="CenteredTabLabelText"> 137 Buildings Statistics (Constructed / Lost / Destroyed) 128 138 </object> 129 <object name=" unitsLostHeading" type="text" style="CenteredTabLabelText">130 Units lost139 <object name="totalBuildingsHeading" type="text" style="CenteredTabLabelText"> 140 Total 131 141 </object> 132 <object name=" enemyUnitsKilledHeading" type="text" style="CenteredTabLabelText">133 Enemy units killed142 <object name="houseBuildingsHeading" type="text" style="CenteredTabLabelText"> 143 Houses 134 144 </object> 135 <object name=" buildingsConstructedHeading" type="text" style="CenteredTabLabelText">136 Buildings constructed145 <object name="economicBuildingsHeading" type="text" style="CenteredTabLabelText"> 146 Economic 137 147 </object> 138 <object name=" buildingsLostHeading" type="text" style="CenteredTabLabelText">139 Buildings lost148 <object name="outpostBuildingsHeading" type="text" style="CenteredTabLabelText"> 149 Outposts 140 150 </object> 141 <object name=" enemyBuildingsDestroyedHeading" type="text" style="CenteredTabLabelText">142 Enemy buildings destroyed151 <object name="militaryBuildingsHeading" type="text" style="CenteredTabLabelText"> 152 Military 143 153 </object> 154 <object name="fortressBuildingsHeading" type="text" style="CenteredTabLabelText"> 155 Fortresses 156 </object> 157 <object name="specialBuildingsHeading" type="text" style="CenteredTabLabelText"> 158 Special 159 </object> 160 <object name="wonderBuildingsHeading" type="text" style="CenteredTabLabelText"> 161 Wonders 162 </object> 163 144 164 </object> 145 165 146 166 <object size="0 65 100% 100%-50"> 147 167 <repeat count="8"> 148 168 <object type="image" name="playerBox1[n]" size="10 0 10 30" hidden="true"> 149 <object name="playerColourBox1[n]" type="image" size="10 4 30 24" /> 150 <object name="playerName1[n]" type="text" style="LeftLabelText" size="40 2 208 100%" /> 151 <object name="civIcon1[n]" type="image" size="208 0 240 32" tooltip_style="sessionToolTip"/> 152 <object name="unitsTrained[n]" type="text" style="CenteredLabelText"/> 153 <object name="unitsLost[n]" type="text" style="CenteredLabelText"/> 154 <object name="enemyUnitsKilled[n]" type="text" style="CenteredLabelText"/> 155 <object name="buildingsConstructed[n]" type="text" style="CenteredLabelText"/> 156 <object name="buildingsLost[n]" type="text" style="CenteredLabelText"/> 157 <object name="enemyBuildingsDestroyed[n]" type="text" style="CenteredLabelText"/> 169 <object name="playerColourBox1[n]" type="image" size="10 4 30 24" /> 170 <object name="playerName1[n]" type="text" style="LeftLabelText" size="40 2 208 100%" /> 171 <object name="civIcon1[n]" type="image" size="208 0 240 32" tooltip_style="sessionToolTip"/> 172 <object name="totalBuildings[n]" type="text" style="CenteredLabelText"/> 173 <object name="houseBuildings[n]" type="text" style="CenteredLabelText"/> 174 <object name="economicBuildings[n]" type="text" style="CenteredLabelText"/> 175 <object name="outpostBuildings[n]" type="text" style="CenteredLabelText"/> 176 <object name="militaryBuildings[n]" type="text" style="CenteredLabelText"/> 177 <object name="fortressBuildings[n]" type="text" style="CenteredLabelText"/> 178 <object name="specialBuildings[n]" type="text" style="CenteredLabelText"/> 179 <object name="wonderBuildings[n]" type="text" style="CenteredLabelText"/> 158 180 </object> 159 181 </repeat> 160 182 </object> 161 183 162 184 </object> 163 <object name="conquestPanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100%-58" hidden="true"> 185 186 <object name="unitsPanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100%-58" hidden="true"> 164 187 165 188 <object size="0 0 100% 100%-50"> 166 189 <object name="playerName2Heading" type="text" style="LeftTabLabelText"> 167 190 Player name 168 191 </object> 192 <object name="unitsHeading" type="text" style="CenteredTabLabelText"> 193 Units Statistics (Trained / Lost / Killed) 194 </object> 195 <object name="totalUnitsHeading" type="text" style="CenteredTabLabelText"> 196 Total 197 </object> 198 <object name="infantryUnitsHeading" type="text" style="CenteredTabLabelText"> 199 Infantry 200 </object> 201 <object name="workerUnitsHeading" type="text" style="CenteredTabLabelText"> 202 Worker 203 </object> 204 <object name="cavalryUnitsHeading" type="text" style="CenteredTabLabelText"> 205 Cavalry 206 </object> 207 <object name="championUnitsHeading" type="text" style="CenteredTabLabelText"> 208 Champion 209 </object> 210 <object name="heroesUnitsHeading" type="text" style="CenteredTabLabelText"> 211 Heroes 212 </object> 213 <object name="navyUnitsHeading" type="text" style="CenteredTabLabelText"> 214 Navy 215 </object> 216 </object> 217 218 <object size="0 65 100% 100%-50"> 219 <repeat count="8"> 220 <object type="image" name="playerBox2[n]" size="10 0 10 30" hidden="true"> 221 <object name="playerColourBox2[n]" type="image" size="10 4 30 24" /> 222 <object name="playerName2[n]" type="text" style="LeftLabelText" size="40 2 208 100%" /> 223 <object name="civIcon2[n]" type="image" size="208 0 240 32" tooltip_style="sessionToolTip"/> 224 <object name="totalUnits[n]" type="text" style="CenteredLabelText"/> 225 <object name="infantryUnits[n]" type="text" style="CenteredLabelText"/> 226 <object name="workerUnits[n]" type="text" style="CenteredLabelText"/> 227 <object name="cavalryUnits[n]" type="text" style="CenteredLabelText"/> 228 <object name="championUnits[n]" type="text" style="CenteredLabelText"/> 229 <object name="heroesUnits[n]" type="text" style="CenteredLabelText"/> 230 <object name="navyUnits[n]" type="text" style="CenteredLabelText"/> 231 </object> 232 </repeat> 233 </object> 234 235 </object> 236 <object name="conquestPanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100%-58" hidden="true"> 237 238 <object size="0 0 100% 100%-50"> 239 <object name="playerName3Heading" type="text" style="LeftTabLabelText"> 240 Player name 241 </object> 169 242 <object name="civCentresBuiltHeading" type="text" style="CenteredTabLabelText"> 170 243 Civ centres built 171 244 </object> … … 179 252 180 253 <object size="0 65 100% 100%-50"> 181 254 <repeat count="8"> 182 <object type="image" name="playerBox 2[n]" size="10 0 10 30" hidden="true">183 <object name="playerColourBox 2[n]" type="image" size="10 4 30 24" />184 <object name="playerName 2[n]" type="text" style="LeftLabelText" size="40 2 208 100%" />185 <object name="civIcon 2[n]" type="image" size="208 0 240 32" tooltip_style="sessionToolTip"/>255 <object type="image" name="playerBox3[n]" size="10 0 10 30" hidden="true"> 256 <object name="playerColourBox3[n]" type="image" size="10 4 30 24" /> 257 <object name="playerName3[n]" type="text" style="LeftLabelText" size="40 2 208 100%" /> 258 <object name="civIcon3[n]" type="image" size="208 0 240 32" tooltip_style="sessionToolTip"/> 186 259 <object name="civCentresBuilt[n]" type="text" style="CenteredLabelText"/> 187 260 <object name="enemyCivCentresDestroyed[n]" type="text" style="CenteredLabelText"/> 188 261 <object name="mapExploration[n]" type="text" style="CenteredLabelText"/> … … 194 267 <object name="resourcesPanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100%-58" hidden="true"> 195 268 196 269 <object size="0 0 100% 100%-50"> 197 <object name="playerName 3Heading" type="text" style="LeftTabLabelText">270 <object name="playerName4Heading" type="text" style="LeftTabLabelText"> 198 271 Player name 199 272 </object> 200 273 <object name="resourceHeading" type="text" style="CenteredTabLabelText"> … … 212 285 <object name="metalGatheredHeading" type="text" style="CenteredTabLabelText"> 213 286 Metal 214 287 </object> 215 <object name=" vegetarianRatioHeading" type="text" style="CenteredTabLabelText">216 Vegetarian ratio288 <object name="totalGatheredHeading" type="text" style="CenteredTabLabelText"> 289 Total 217 290 </object> 218 291 <object name="treasuresCollectedHeading" type="text" style="CenteredTabLabelText"> 219 292 Treasures collected … … 225 298 226 299 <object size="0 65 100% 100%-50"> 227 300 <repeat count="8"> 228 <object type="image" name="playerBox 3[n]" size="10 0 10 30" hidden="true">229 <object name="playerColourBox 3[n]" type="image" size="10 4 30 24" />230 <object name="playerName 3[n]" type="text" style="LeftLabelText" size="40 2 208 100%" />231 <object name="civIcon 3[n]" type="image" size="208 0 240 32" tooltip_style="sessionToolTip"/>301 <object type="image" name="playerBox4[n]" size="10 0 10 30" hidden="true"> 302 <object name="playerColourBox4[n]" type="image" size="10 4 30 24" /> 303 <object name="playerName4[n]" type="text" style="LeftLabelText" size="40 2 208 100%" /> 304 <object name="civIcon4[n]" type="image" size="208 0 240 32" tooltip_style="sessionToolTip"/> 232 305 <object name="foodGathered[n]" type="text" style="CenteredLabelText"/> 233 306 <object name="woodGathered[n]" type="text" style="CenteredLabelText"/> 234 307 <object name="stoneGathered[n]" type="text" style="CenteredLabelText" /> 235 308 <object name="metalGathered[n]" type="text" style="CenteredLabelText"/> 236 <object name=" vegetarianRatio[n]"type="text" style="CenteredLabelText"/>309 <object name="totalGathered[n]" type="text" style="CenteredLabelText"/> 237 310 <object name="treasuresCollected[n]" type="text" style="CenteredLabelText"/> 238 311 <object name="resourcesTributed[n]" type="text" style="CenteredLabelText"/> 239 312 </object> … … 244 317 <object name="marketPanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100%-58" hidden="true"> 245 318 246 319 <object size="0 0 100% 100%-50"> 247 <object name="playerName 4Heading" type="text" style="LeftTabLabelText">320 <object name="playerName5Heading" type="text" style="LeftTabLabelText"> 248 321 Player name 249 322 </object> 250 323 <object name="exchangedFoodHeading" type="text" style="CenteredTabLabelText"> … … 269 342 270 343 <object size="0 65 100% 100%-50"> 271 344 <repeat count="8"> 272 <object type="image" name="playerBox 4[n]" size="10 0 10 30" hidden="true">273 <object name="playerColourBox 4[n]" type="image" size="10 4 30 24" />274 <object name="playerName 4[n]" type="text" style="LeftLabelText" size="40 2 208 100%" />275 <object name="civIcon 4[n]" type="image" size="208 0 240 32" tooltip_style="sessionToolTip"/>345 <object type="image" name="playerBox5[n]" size="10 0 10 30" hidden="true"> 346 <object name="playerColourBox5[n]" type="image" size="10 4 30 24" /> 347 <object name="playerName5[n]" type="text" style="LeftLabelText" size="40 2 208 100%" /> 348 <object name="civIcon5[n]" type="image" size="208 0 240 32" tooltip_style="sessionToolTip"/> 276 349 <object name="exchangedFood[n]" type="text" style="CenteredLabelText"/> 277 350 <object name="exchangedWood[n]" type="text" style="CenteredLabelText"/> 278 351 <object name="exchangedStone[n]" type="text" style="CenteredLabelText"/> … … 285 358 286 359 </object> 287 360 361 <object name="miscPanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100%-58" hidden="true"> 362 363 <object size="0 0 100% 100%-50"> 364 <object name="playerName6Heading" type="text" style="LeftTabLabelText"> 365 Player name 366 </object> 367 <object name="vegetarianRatioHeading" type="text" style="CenteredTabLabelText"> 368 Vegetarian ratio 369 </object> 370 <object name="feminisationHeading" type="text" style="CenteredTabLabelText"> 371 Feminisation 372 </object> 373 <object name="killDeathRatioHeading" type="text" style="CenteredTabLabelText"> 374 Kill / Death ratio 375 </object> 376 </object> 377 378 <object size="0 65 100% 100%-50"> 379 <repeat count="8"> 380 <object type="image" name="playerBox6[n]" size="10 0 10 30" hidden="true"> 381 <object name="playerColourBox6[n]" type="image" size="10 4 30 24" /> 382 <object name="playerName6[n]" type="text" style="LeftLabelText" size="40 2 208 100%" /> 383 <object name="civIcon6[n]" type="image" size="208 0 240 32" tooltip_style="sessionToolTip"/> 384 <object name="vegetarianRatio[n]" type="text" style="CenteredLabelText"/> 385 <object name="feminisation[n]" type="text" style="CenteredLabelText"/> 386 <object name="killDeathRatio[n]" type="text" style="CenteredLabelText"/> 387 </object> 388 </repeat> 389 </object> 390 391 </object> 392 288 393 <object type="button" style="StoneButton" size="100%-164 100%-52 100%-24 100%-24"> 289 394 Continue 290 395 <action on="Press"><![CDATA[ -
binaries/data/mods/public/simulation/components/Foundation.js
312 312 // ---------------------------------------------------------------------- 313 313 314 314 var cmpPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker); 315 cmpPlayerStatisticsTracker.IncreaseConstructedBuildingsCounter( );315 cmpPlayerStatisticsTracker.IncreaseConstructedBuildingsCounter(building); 316 316 317 317 var cmpIdentity = Engine.QueryInterface(building, IID_Identity); 318 318 if (cmpIdentity.GetClassesList().indexOf("CivCentre") != -1) -
binaries/data/mods/public/simulation/components/ProductionQueue.js
516 516 } 517 517 518 518 var cmpPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker); 519 cmpPlayerStatisticsTracker.IncreaseTrainedUnitsCounter( );519 cmpPlayerStatisticsTracker.IncreaseTrainedUnitsCounter(ent); 520 520 521 521 // Play a sound, but only for the first in the batch (to avoid nasty phasing effects) 522 522 if (createdEnts.length == 0) -
binaries/data/mods/public/simulation/components/StatisticsTracker.js
6 6 StatisticsTracker.prototype.Init = function() 7 7 { 8 8 // units 9 this.unitsTrained = 0; 10 this.unitsLost = 0; 9 this.unitsTrained = { 10 "Infantry": 0, 11 "Worker": 0, 12 "Female": 0, 13 "Cavalry": 0, 14 "Champion": 0, 15 "Hero": 0, 16 "Ship": 0, 17 "total": 0 18 }; 19 this.unitsLost = { 20 "Infantry": 0, 21 "Worker": 0, 22 "Female": 0, 23 "Cavalry": 0, 24 "Champion": 0, 25 "Hero": 0, 26 "Ship": 0, 27 "total": 0 28 }; 11 29 this.unitsLostValue = 0; 12 this.enemyUnitsKilled = 0; 30 this.enemyUnitsKilled = { 31 "Infantry": 0, 32 "Worker": 0, 33 "Female": 0, 34 "Cavalry": 0, 35 "Champion": 0, 36 "Hero": 0, 37 "Ship": 0, 38 "total": 0 39 }; 13 40 this.enemyUnitsKilledValue = 0; 14 //buildings 15 this.buildingsConstructed = 0; 16 this.buildingsLost = 0; 41 //buildings 42 this.buildingsConstructed = { 43 "House": 0, 44 "Economic": 0, 45 "Outpost": 0, 46 "Military": 0, 47 "Fortress": 0, 48 "SpecialBuilding": 0, 49 "Wonder": 0, 50 "total": 0 51 }; 52 this.buildingsLost = { 53 "House": 0, 54 "Economic": 0, 55 "Outpost": 0, 56 "Military": 0, 57 "Fortress": 0, 58 "SpecialBuilding": 0, 59 "Wonder": 0, 60 "total": 0 61 }; 17 62 this.buildingsLostValue = 0; 18 this.enemyBuildingsDestroyed = 0; 63 this.enemyBuildingsDestroyed = { 64 "House": 0, 65 "Economic": 0, 66 "Outpost": 0, 67 "Military": 0, 68 "Fortress": 0, 69 "SpecialBuilding": 0, 70 "Wonder": 0, 71 "total": 0 72 }; 19 73 this.enemyBuildingsDestroyedValue = 0; 20 74 // civ centres 21 75 this.civCentresBuilt = 0; … … 22 76 this.enemyCivCentresDestroyed = 0; 23 77 // resources 24 78 this.resourcesGathered = { 79 "total": 0, 25 80 "food": 0, 26 81 "wood": 0, 27 82 "metal": 0, … … 29 84 "vegetarianFood": 0 30 85 }; 31 86 this.resourcesUsed = { 87 "total": 0, 32 88 "food": 0, 33 89 "wood": 0, 34 90 "metal": 0, … … 35 91 "stone": 0 36 92 }; 37 93 this.resourcesSold = { 94 "total": 0, 38 95 "food": 0, 39 96 "wood": 0, 40 97 "metal": 0, … … 41 98 "stone": 0 42 99 }; 43 100 this.resourcesBought = { 101 "total": 0, 44 102 "food": 0, 45 103 "wood": 0, 46 104 "metal": 0, … … 75 133 "tributesReceived": this.tributesReceived, 76 134 "tradeIncome": this.tradeIncome, 77 135 "treasuresCollected": this.treasuresCollected, 78 "percentMapExplored": this.GetPercentMapExplored() 136 "percentMapExplored": this.GetPercentMapExplored(), 137 "feminisation": this.GetFeminisation() 79 138 }; 80 139 }; 81 140 82 StatisticsTracker.prototype.IncreaseTrainedUnitsCounter = function() 141 /** 142 *Increments counter associated with certain entity/counter and type of given entity. 143 *@param entity Variable containing a class by which the unit is being identified 144 *@param counter The name of the counter to increment(e.g. "unitsTrained") 145 *@param type The type of the counter (e.g. "workers") 146 */ 147 StatisticsTracker.prototype.CounterIncrement = function(entity, counter, type) 83 148 { 84 return this.unitsTrained++; 149 var classes = entity.GetClassesList(); 150 151 if (classes) 152 if (classes.indexOf(type) != -1) 153 this[counter][type]++; 85 154 }; 86 155 87 StatisticsTracker.prototype.IncreaseConstructedBuildingsCounter = function() 156 /** 157 * Counts the total number of units trained as well as an individual count for 158 * each unit type. Based on templates. 159 * @param trainedUnit The unit that has been trained 160 */ 161 StatisticsTracker.prototype.IncreaseTrainedUnitsCounter = function(trainedUnit) 88 162 { 89 return this.buildingsConstructed++; 163 var cmpUnitEntityIdentity = Engine.QueryInterface(trainedUnit, IID_Identity); 164 165 if (cmpUnitEntityIdentity) 166 { 167 this.CounterIncrement(cmpUnitEntityIdentity, "unitsTrained", "Infantry"); 168 this.CounterIncrement(cmpUnitEntityIdentity, "unitsTrained", "Worker"); 169 this.CounterIncrement(cmpUnitEntityIdentity, "unitsTrained", "Female"); 170 this.CounterIncrement(cmpUnitEntityIdentity, "unitsTrained", "Cavalry"); 171 this.CounterIncrement(cmpUnitEntityIdentity, "unitsTrained", "Champion"); 172 this.CounterIncrement(cmpUnitEntityIdentity, "unitsTrained", "Hero"); 173 this.CounterIncrement(cmpUnitEntityIdentity, "unitsTrained", "Ship"); 174 this.unitsTrained.total++; 175 } 90 176 }; 91 177 178 StatisticsTracker.prototype.GetFeminisation = function() 179 { 180 return Math.floor(this.unitsTrained.Female > 0 ? (this.unitsTrained.Female / this.unitsTrained.Worker) * 100 : 0) 181 }; 182 183 184 /** 185 * Counts the total number of buildings constructed as well as an individual count for 186 * each building type. Based on templates. 187 * @param constructedBuilding The building that has been constructed 188 */ 189 StatisticsTracker.prototype.IncreaseConstructedBuildingsCounter = function(constructedBuilding) 190 { 191 var cmpBuildingEntityIdentity = Engine.QueryInterface(constructedBuilding, IID_Identity); 192 193 if (cmpBuildingEntityIdentity) 194 { 195 this.CounterIncrement(cmpBuildingEntityIdentity, "buildingsConstructed", "House"); 196 this.CounterIncrement(cmpBuildingEntityIdentity, "buildingsConstructed", "Economic"); 197 this.CounterIncrement(cmpBuildingEntityIdentity, "buildingsConstructed", "Outpost"); 198 this.CounterIncrement(cmpBuildingEntityIdentity, "buildingsConstructed", "Military"); 199 this.CounterIncrement(cmpBuildingEntityIdentity, "buildingsConstructed", "Fortress"); 200 this.CounterIncrement(cmpBuildingEntityIdentity, "buildingsConstructed", "SpecialBuilding"); 201 this.CounterIncrement(cmpBuildingEntityIdentity, "buildingsConstructed", "Wonder"); 202 this.buildingsConstructed.total++; 203 } 204 }; 205 92 206 StatisticsTracker.prototype.IncreaseBuiltCivCentresCounter = function() 93 207 { 94 208 return this.civCentresBuilt++; 95 209 }; 96 210 211 97 212 StatisticsTracker.prototype.KilledEntity = function(targetEntity) 98 213 { 99 214 var cmpTargetEntityIdentity = Engine.QueryInterface(targetEntity, IID_Identity); … … 116 231 { 117 232 if (targetIsUnit) 118 233 { 119 this.enemyUnitsKilled++; 234 this.CounterIncrement(cmpTargetEntityIdentity, "enemyUnitsKilled", "Infantry"); 235 this.CounterIncrement(cmpTargetEntityIdentity, "enemyUnitsKilled", "Worker"); 236 this.CounterIncrement(cmpTargetEntityIdentity, "enemyUnitsKilled", "Female"); 237 this.CounterIncrement(cmpTargetEntityIdentity, "enemyUnitsKilled", "Cavalry"); 238 this.CounterIncrement(cmpTargetEntityIdentity, "enemyUnitsKilled", "Champion"); 239 this.CounterIncrement(cmpTargetEntityIdentity, "enemyUnitsKilled", "Hero"); 240 this.CounterIncrement(cmpTargetEntityIdentity, "enemyUnitsKilled", "Ship"); 241 this.enemyUnitsKilled.total++; 242 120 243 for (var r in costs) 121 244 { 122 245 this.enemyUnitsKilledValue += costs[r]; … … 124 247 } 125 248 if (targetIsStructure) 126 249 { 127 this.enemyBuildingsDestroyed++; 250 this.CounterIncrement(cmpTargetEntityIdentity, "enemyBuildingsDestroyed", "House"); 251 this.CounterIncrement(cmpTargetEntityIdentity, "enemyBuildingsDestroyed", "Economic"); 252 this.CounterIncrement(cmpTargetEntityIdentity, "enemyBuildingsDestroyed", "Outpost"); 253 this.CounterIncrement(cmpTargetEntityIdentity, "enemyBuildingsDestroyed", "Military"); 254 this.CounterIncrement(cmpTargetEntityIdentity, "enemyBuildingsDestroyed", "Fortress"); 255 this.CounterIncrement(cmpTargetEntityIdentity, "enemyBuildingsDestroyed", "SpecialBuilding"); 256 this.CounterIncrement(cmpTargetEntityIdentity, "enemyBuildingsDestroyed", "Wonder"); 257 this.enemyBuildingsDestroyed.total++; 258 128 259 for (var r in costs) 129 260 { 130 261 this.enemyBuildingsDestroyedValue += costs[r]; … … 152 283 153 284 if (lostEntityIsUnit) 154 285 { 155 this.unitsLost++; 286 this.CounterIncrement(cmpLostEntityIdentity, "unitsLost", "Infantry"); 287 this.CounterIncrement(cmpLostEntityIdentity, "unitsLost", "Worker"); 288 this.CounterIncrement(cmpLostEntityIdentity, "unitsLost", "Female"); 289 this.CounterIncrement(cmpLostEntityIdentity, "unitsLost", "Cavalry"); 290 this.CounterIncrement(cmpLostEntityIdentity, "unitsLost", "Champion"); 291 this.CounterIncrement(cmpLostEntityIdentity, "unitsLost", "Hero"); 292 this.CounterIncrement(cmpLostEntityIdentity, "unitsLost", "Ship"); 293 this.unitsLost.total++; 294 156 295 for (var r in costs) 157 296 { 158 297 this.unitsLostValue += costs[r]; … … 160 299 } 161 300 if (lostEntityIsStructure) 162 301 { 163 this.buildingsLost++; 302 this.CounterIncrement(cmpLostEntityIdentity, "buildingsLost", "House"); 303 this.CounterIncrement(cmpLostEntityIdentity, "buildingsLost", "Economic"); 304 this.CounterIncrement(cmpLostEntityIdentity, "buildingsLost", "Outpost"); 305 this.CounterIncrement(cmpLostEntityIdentity, "buildingsLost", "Military"); 306 this.CounterIncrement(cmpLostEntityIdentity, "buildingsLost", "Fortress"); 307 this.CounterIncrement(cmpLostEntityIdentity, "buildingsLost", "SpecialBuilding"); 308 this.CounterIncrement(cmpLostEntityIdentity, "buildingsLost", "Wonder"); 309 this.buildingsLost.total++; 310 164 311 for (var r in costs) 165 312 { 166 313 this.buildingsLostValue += costs[r]; … … 177 324 StatisticsTracker.prototype.IncreaseResourceGatheredCounter = function(type, amount, specificType) 178 325 { 179 326 this.resourcesGathered[type] += amount; 327 this.resourcesGathered.total += amount; 180 328 181 329 if (type == "food" && (specificType == "fruit" || specificType == "grain")) 182 330 this.resourcesGathered["vegetarianFood"] += amount; … … 189 337 StatisticsTracker.prototype.IncreaseResourceUsedCounter = function(type, amount) 190 338 { 191 339 this.resourcesUsed[type] += amount; 340 this.resourcesUsed.total += amount; 192 341 }; 193 342 194 343 StatisticsTracker.prototype.IncreaseTreasuresCollectedCounter = function() … … 199 348 StatisticsTracker.prototype.IncreaseResourcesSoldCounter = function(type, amount) 200 349 { 201 350 this.resourcesSold[type] += amount; 202 } 351 this.resourcesSold.total += amount; 352 }; 203 353 204 354 StatisticsTracker.prototype.IncreaseResourcesBoughtCounter = function(type, amount) 205 355 { 206 356 this.resourcesBought[type] += amount; 207 } 357 this.resourcesBought.total += amount; 358 }; 208 359 209 360 StatisticsTracker.prototype.IncreaseTributesSentCounter = function(amount) 210 361 { 211 362 this.tributesSent += amount; 212 } 363 }; 213 364 214 365 StatisticsTracker.prototype.IncreaseTributesReceivedCounter = function(amount) 215 366 { 216 367 this.tributesReceived += amount; 217 } 368 }; 218 369 219 370 StatisticsTracker.prototype.IncreaseTradeIncomeCounter = function(amount) 220 371 { 221 372 this.tradeIncome += amount; 222 } 373 }; 223 374 224 375 StatisticsTracker.prototype.GetPercentMapExplored = function() 225 376 {