Ticket #3150: team_exploration_score_v5.3.patch
File team_exploration_score_v5.3.patch, 11.7 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/credits/texts/programming.json
83 83 {"nick": "h20", "name": "Daniel Wilhelm"}, 84 84 {"nick": "historic_bruno", "name": "Ben Brian"}, 85 85 {"nick": "idanwin"}, 86 {"nick": "Imarok", "name": "J. S."}, 86 87 {"nick": "infyquest", "name": "Vijay Kiran Kamuju"}, 87 88 {"nick": "IronNerd", "name": "Matthew McMullan"}, 88 89 {"nick": "Itms", "name": "Nicolas Auvray"}, -
binaries/data/mods/public/gui/summary/counters.js
1 1 // FUNCTIONS FOR CALCULATING SCORES 2 var g_Team MiscHelperData = [];2 var g_TeamHelperData = []; 3 3 4 4 function resetDataHelpers() 5 5 { 6 g_Team MiscHelperData = [];6 g_TeamHelperData = []; 7 7 } 8 8 9 9 function updateCountersPlayer(playerState, counters, idGUI) … … 15 15 } 16 16 } 17 17 18 function calculate EconomyScore(playerState, position)18 function calculateTeamCounters(playerState) 19 19 { 20 if (!g_TeamHelperData[playerState.team]) 21 g_TeamHelperData[playerState.team] = { 22 "food": 0, 23 "vegetarianFood": 0, 24 "female": 0, 25 "worker": 0, 26 "enemyUnitsKilled": 0, 27 "unitsLost": 0, 28 "percentMapControlled": 0, 29 "peakPercentMapControlled": 0, 30 "percentMapExplored": 0, 31 }; 32 33 g_TeamHelperData[playerState.team].food += playerState.statistics.resourcesGathered.food; 34 g_TeamHelperData[playerState.team].vegetarianFood += playerState.statistics.resourcesGathered.vegetarianFood; 35 36 g_TeamHelperData[playerState.team].female = playerState.statistics.unitsTrained.Female; 37 g_TeamHelperData[playerState.team].worker = playerState.statistics.unitsTrained.Worker; 38 39 g_TeamHelperData[playerState.team].enemyUnitsKilled = playerState.statistics.enemyUnitsKilled.total; 40 g_TeamHelperData[playerState.team].unitsLost = playerState.statistics.unitsLost.total; 41 42 g_TeamHelperData[playerState.team].percentMapControlled = playerState.statistics.teamPercentMapControlled; 43 g_TeamHelperData[playerState.team].peakPercentMapControlled = playerState.statistics.teamPeakPercentMapControlled; 44 45 g_TeamHelperData[playerState.team].percentMapExplored = playerState.statistics.teamPercentMapExplored; 46 } 47 48 function calculateEconomyScore(playerState) 49 { 20 50 let total = 0; 21 51 for (let type in playerState.statistics.resourcesGathered) 22 52 total += playerState.statistics.resourcesGathered[type]; … … 24 54 return Math.round(total / 10); 25 55 } 26 56 27 function calculateMilitaryScore(playerState , position)57 function calculateMilitaryScore(playerState) 28 58 { 29 59 return Math.round((playerState.statistics.enemyUnitsKilledValue + 30 60 playerState.statistics.enemyBuildingsDestroyedValue) / 10); 31 61 } 32 62 33 function calculateExplorationScore(playerState , position)63 function calculateExplorationScore(playerState) 34 64 { 35 65 return playerState.statistics.percentMapExplored * 10; 36 66 } 37 67 38 function calculateScoreTotal(playerState , position)68 function calculateScoreTotal(playerState) 39 69 { 40 70 return calculateEconomyScore(playerState) + 41 71 calculateMilitaryScore(playerState) + … … 52 82 for (let w in counters) 53 83 { 54 84 let total = 0; 55 for (let p = 0; p < g_Teams[t]; ++p) 56 total += (+Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption); 85 // w == 2 is the team exploration score 86 // The players exploration score can't be added because there might be regions both players explored 87 if(w == 2) 88 total = g_TeamHelperData[t].percentMapExplored * 10; 89 else 90 for (let p = 0; p < g_Teams[t]; ++p) 91 total += +Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption; 57 92 58 93 Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = total; 59 94 } … … 119 154 g_OutcomeColor + (playerState.statistics.resourcesUsed[type] - playerState.statistics.resourcesSold[type]) + '[/color]'; 120 155 } 121 156 122 function calculateTotalResources(playerState , position)157 function calculateTotalResources(playerState) 123 158 { 124 159 let totalGathered = 0; 125 160 let totalUsed = 0; … … 133 168 return g_IncomeColor + totalGathered + '[/color] / ' + g_OutcomeColor + totalUsed + '[/color]'; 134 169 } 135 170 136 function calculateTreasureCollected(playerState , position)171 function calculateTreasureCollected(playerState) 137 172 { 138 173 return playerState.statistics.treasuresCollected; 139 174 } 140 175 141 function calculateLootCollected(playerState , position)176 function calculateLootCollected(playerState) 142 177 { 143 178 return playerState.statistics.lootCollected; 144 179 } 145 180 146 function calculateTributeSent(playerState , position)181 function calculateTributeSent(playerState) 147 182 { 148 183 return g_IncomeColor + playerState.statistics.tributesSent + "[/color] / " + 149 184 g_OutcomeColor + playerState.statistics.tributesReceived + "[/color]"; … … 192 227 } 193 228 } 194 229 195 function calculateResourceExchanged(playerState , position)230 function calculateResourceExchanged(playerState) 196 231 { 197 232 let type = g_ResourcesTypes[position]; 198 233 return g_IncomeColor + '+' + playerState.statistics.resourcesBought[type] + '[/color] ' + … … 199 234 g_OutcomeColor + '-' + playerState.statistics.resourcesSold[type] + '[/color]'; 200 235 } 201 236 202 function calculateBatteryEfficiency(playerState , position)237 function calculateBatteryEfficiency(playerState) 203 238 { 204 239 let totalBought = 0; 205 240 let totalSold = 0; … … 213 248 return Math.floor(totalSold > 0 ? (totalBought / totalSold) * 100 : 0) + "%"; 214 249 } 215 250 216 function calculateTradeIncome(playerState , position)251 function calculateTradeIncome(playerState) 217 252 { 218 253 return playerState.statistics.tradeIncome; 219 254 } … … 260 295 } 261 296 } 262 297 263 function calculateVegetarianRatio(playerState , position)298 function calculateVegetarianRatio(playerState) 264 299 { 265 if (!g_TeamMiscHelperData[playerState.team])266 g_TeamMiscHelperData[playerState.team] = [];267 268 if (!g_TeamMiscHelperData[playerState.team][position])269 g_TeamMiscHelperData[playerState.team][position] = { "food": 0, "vegetarianFood": 0 };270 271 300 if (playerState.statistics.resourcesGathered.vegetarianFood && playerState.statistics.resourcesGathered.food) 272 {273 g_TeamMiscHelperData[playerState.team][position].food += playerState.statistics.resourcesGathered.food;274 g_TeamMiscHelperData[playerState.team][position].vegetarianFood += playerState.statistics.resourcesGathered.vegetarianFood;275 301 return Math.floor((playerState.statistics.resourcesGathered.vegetarianFood / playerState.statistics.resourcesGathered.food) * 100) + "%"; 276 }277 302 else 278 303 return 0 + "%"; 279 304 } 280 305 281 function calculateFeminization(playerState , position)306 function calculateFeminization(playerState) 282 307 { 283 if (!g_TeamMiscHelperData[playerState.team])284 g_TeamMiscHelperData[playerState.team] = [];285 286 if (!g_TeamMiscHelperData[playerState.team][position])287 g_TeamMiscHelperData[playerState.team][position] = { "Female": 0, "Worker": 0 };288 289 308 if (playerState.statistics.unitsTrained.Worker && playerState.statistics.unitsTrained.Female) 290 {291 g_TeamMiscHelperData[playerState.team][position].Female = playerState.statistics.unitsTrained.Female;292 g_TeamMiscHelperData[playerState.team][position].Worker = playerState.statistics.unitsTrained.Worker;293 309 return Math.floor((playerState.statistics.unitsTrained.Female / playerState.statistics.unitsTrained.Worker) * 100) + "%"; 294 }295 310 else 296 311 return 0 + "%"; 297 312 } 298 313 299 function calculateKillDeathRatio(playerState , position)314 function calculateKillDeathRatio(playerState) 300 315 { 301 if (!g_TeamMiscHelperData[playerState.team])302 g_TeamMiscHelperData[playerState.team] = [];303 304 if (!g_TeamMiscHelperData[playerState.team][position])305 g_TeamMiscHelperData[playerState.team][position] = { "enemyUnitsKilled": 0, "unitsLost": 0 };306 307 g_TeamMiscHelperData[playerState.team][position].enemyUnitsKilled = playerState.statistics.enemyUnitsKilled.total;308 g_TeamMiscHelperData[playerState.team][position].unitsLost = playerState.statistics.unitsLost.total;309 310 316 if (!playerState.statistics.enemyUnitsKilled.total) 311 317 return g_DefaultDecimal; 312 318 … … 316 322 return Math.round((playerState.statistics.enemyUnitsKilled.total / playerState.statistics.unitsLost.total)*100)/100; 317 323 } 318 324 319 function calculateMapExploration(playerState , position)325 function calculateMapExploration(playerState) 320 326 { 321 if (!g_TeamMiscHelperData[playerState.team])322 g_TeamMiscHelperData[playerState.team] = [];323 324 g_TeamMiscHelperData[playerState.team][position] = playerState.statistics.teamPercentMapExplored;325 326 327 return playerState.statistics.percentMapExplored + "%"; 327 328 } 328 329 329 function calculateMapFinalControl(playerState , position)330 function calculateMapFinalControl(playerState) 330 331 { 331 if (!g_TeamMiscHelperData[playerState.team])332 g_TeamMiscHelperData[playerState.team] = [];333 334 g_TeamMiscHelperData[playerState.team][position] = playerState.statistics.teamPercentMapControlled;335 336 332 return playerState.statistics.percentMapControlled + "%"; 337 333 } 338 334 339 function calculateMapPeakControl(playerState , position)335 function calculateMapPeakControl(playerStaten) 340 336 { 341 if (!g_TeamMiscHelperData[playerState.team])342 g_TeamMiscHelperData[playerState.team] = [];343 344 g_TeamMiscHelperData[playerState.team][position] = playerState.statistics.teamPeakPercentMapControlled;345 346 337 return playerState.statistics.peakPercentMapControlled + "%"; 347 338 } 348 339 … … 358 349 let teamTotal = "undefined"; 359 350 360 351 if (w == 0) 361 teamTotal = (g_Team MiscHelperData[t][w].food == 0 ? "0" : Math.floor((g_TeamMiscHelperData[t][w].vegetarianFood / g_TeamMiscHelperData[t][w].food) * 100)) + "%";352 teamTotal = (g_TeamHelperData[t].food == 0 ? "0" : Math.floor((g_TeamHelperData[t].vegetarianFood / g_TeamHelperData[t].food) * 100)) + "%"; 362 353 else if (w == 1) 363 teamTotal = (g_Team MiscHelperData[t][w].Worker == 0 ? "0" : Math.floor((g_TeamMiscHelperData[t][w].Female / g_TeamMiscHelperData[t][w].Worker) * 100)) + "%";354 teamTotal = (g_TeamHelperData[t].worker == 0 ? "0" : Math.floor((g_TeamHelperData[t].female / g_TeamHelperData[t].worker) * 100)) + "%"; 364 355 else if (w == 2) 365 356 { 366 if (!g_Team MiscHelperData[t][w].enemyUnitsKilled)357 if (!g_TeamHelperData[t].enemyUnitsKilled) 367 358 teamTotal = g_DefaultDecimal; 368 else if (!g_Team MiscHelperData[t][w].unitsLost) // and enemyUnitsKilled.total > 0359 else if (!g_TeamHelperData[t].unitsLost) // and enemyUnitsKilled.total > 0 369 360 teamTotal = g_InfiniteSymbol; // infinity symbol 370 361 else 371 teamTotal = Math.round((g_Team MiscHelperData[t][w].enemyUnitsKilled / g_TeamMiscHelperData[t][w].unitsLost) * 100) / 100;362 teamTotal = Math.round((g_TeamHelperData[t].enemyUnitsKilled / g_TeamHelperData[t].unitsLost) * 100) / 100; 372 363 } 373 else if (w >= 3) 374 teamTotal = g_TeamMiscHelperData[t][w] + "%"; 364 else if (w == 3) 365 teamTotal = g_TeamHelperData[t].percentMapExplored + "%"; 366 else if (w == 4) 367 teamTotal = g_TeamHelperData[t].percentMapControlled + "%"; 368 else if (w == 5) 369 teamTotal = g_TeamHelperData[t].peakPercentMapControlled + "%"; 375 370 376 Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal ;371 Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal + "%"; 377 372 } 378 373 } 379 374 } -
binaries/data/mods/public/gui/summary/summary.js
119 119 120 120 // Update counters 121 121 updateCountersPlayer(playerState, panelInfo.counters, playerCounterValue); 122 123 // Calculate g_TeamHelperData 124 calculateTeamCounters(playerState); 122 125 } 123 126 // Update team counters 124 127 let teamCounterFn = panelInfo.teamCounterFn;