Ticket #3518: ticket3518_summarystyle_3.diff

File ticket3518_summarystyle_3.diff, 9.1 KB (added by bb, 8 years ago)

deprecate the for each to for in and treat "resourcestotal" the same as "unitstotal" and "buildingstotal"

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

     
    1818function calculateEconomyScore(playerState, position)
    1919{
    2020    let total = 0;
    21     for each (let res in playerState.statistics.resourcesGathered)
    22         total += res;
     21    for (let type in playerState.statistics.resourcesGathered)
     22        total += playerState.statistics.resourcesGathered[type];
    2323
    2424    return Math.round(total / 10);
    2525}
     
    119119        g_OutcomeColor + (playerState.statistics.resourcesUsed[type] - playerState.statistics.resourcesSold[type]) + '[/color]';
    120120}
    121121
    122 function calculateTotalResources(playerState, position)
    123 {
    124     let totalGathered = 0;
    125     let totalUsed = 0;
    126 
    127     for each (let type in g_ResourcesTypes)
    128     {
    129         totalGathered += playerState.statistics.resourcesGathered[type];
    130         totalUsed += playerState.statistics.resourcesUsed[type] - playerState.statistics.resourcesSold[type];
    131     }
    132 
    133     return g_IncomeColor + totalGathered + '[/color] / ' + g_OutcomeColor + totalUsed + '[/color]';
    134 }
    135 
    136122function calculateTreasureCollected(playerState, position)
    137123{
    138124    return playerState.statistics.treasuresCollected;
     
    202188function calculateBatteryEfficiency(playerState, position)
    203189{
    204190    let totalBought = 0;
    205     for each (let boughtAmount in playerState.statistics.resourcesBought)
    206         totalBought += boughtAmount;
    207191    let totalSold = 0;
    208     for each (let soldAmount in playerState.statistics.resourcesSold)
    209         totalSold += soldAmount;
     192    for (let boughtAmount in playerState.statistics.resourcesBought)
     193        totalBought += playerState.statistics.resourcesBought[boughtAmount];
     194    for (let soldAmount in playerState.statistics.resourcesSold)
     195        totalSold += playerState.statistics.resourcesSold[soldAmount];
    210196
    211197    return Math.floor(totalSold > 0 ? (totalBought / totalSold) * 100 : 0) + "%";
    212198}
     
    366352                else if (!g_TeamMiscHelperData[t][w].unitsLost) // and enemyUnitsKilled.total > 0
    367353                    teamTotal = g_InfiniteSymbol; // infinity symbol
    368354                else
    369                     teamTotal = Math.round((g_TeamMiscHelperData[t][w].enemyUnitsKilled / g_TeamMiscHelperData[t][w].unitsLost)*100)/100;
     355                    teamTotal = Math.round((g_TeamMiscHelperData[t][w].enemyUnitsKilled / g_TeamMiscHelperData[t][w].unitsLost) * 100) / 100;
    370356            }
    371357            else if (w >= 3)
    372358                teamTotal = g_TeamMiscHelperData[t][w] + "%";
  • binaries/data/mods/public/gui/summary/layout.js

     
    9090            { "width": 100, "fn": calculateResources },
    9191            { "width": 100, "fn": calculateResources },
    9292            { "width": 100, "fn": calculateResources },
    93             { "width": 110, "fn": calculateTotalResources },
     93            { "width": 110, "fn": calculateResources },
    9494            { "width": 121, "fn": calculateTributeSent },
    9595            { "width": 100, "fn": calculateTreasureCollected },
    9696            { "width": 100, "fn": calculateLootCollected }
  • binaries/data/mods/public/gui/summary/summary.js

     
    1919
    2020const g_BuildingsTypes = [ "total", "House", "Economic", "Outpost", "Military", "Fortress", "CivCentre", "Wonder" ];
    2121const g_UnitsTypes = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship", "Trader" ];
    22 const g_ResourcesTypes = [ "food", "wood", "stone", "metal" ];
     22const g_ResourcesTypes = [ "food", "wood", "stone", "metal", "total" ];
    2323
    2424// Colors used for gathered and traded resources
    2525const g_IncomeColor = '[color="201 255 200"]';
  • binaries/data/mods/public/simulation/components/StatisticsTracker.js

     Engine.RegisterComponentType(IID_Repairable, "Repairable", Repairable);
     
    9999        "wood": 0,
    100100        "metal": 0,
    101101        "stone": 0,
     102        "total": 0,
    102103        "vegetarianFood": 0
    103104    };
    104105    this.resourcesUsed = {
     
    105106        "food": 0,
    106107        "wood": 0,
    107108        "metal": 0,
    108         "stone": 0
     109        "stone": 0,
     110        "total": 0
    109111    };
    110112    this.resourcesSold = {
    111113        "food": 0,
    112114        "wood": 0,
    113115        "metal": 0,
    114         "stone": 0
     116        "stone": 0,
     117        "total": 0
    115118    };
    116119    this.resourcesBought = {
    117120        "food": 0,
     
    314317StatisticsTracker.prototype.IncreaseResourceGatheredCounter = function(type, amount, specificType)
    315318{
    316319    this.resourcesGathered[type] += amount;
     320    this.resourcesGathered.total += amount;
    317321   
    318322    if (type == "food" && (specificType == "fruit" || specificType == "grain"))
    319323        this.resourcesGathered.vegetarianFood += amount;
     
    326330StatisticsTracker.prototype.IncreaseResourceUsedCounter = function(type, amount)
    327331{
    328332    this.resourcesUsed[type] += amount;
     333    this.resourcesUsed.total += amount;
    329334};
    330335
    331336StatisticsTracker.prototype.IncreaseTreasuresCollectedCounter = function()
  • binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js

     
    109109            "resourcesGathered": {
    110110                "food": 100,   
    111111                "wood": 0, 
    112                 "metal": 0,
    113112                "stone": 0,
     113                "metal": 0,
     114                "total": 0,
    114115                "vegetarianFood": 0,
    115116            },
    116117            "percentMapExplored": 10
     
    126127            "resourcesGathered": {
    127128                "food": 100,   
    128129                "wood": 0, 
    129                 "metal": 0,
    130130                "stone": 0,
     131                "metal": 0,
     132                "total": 0,
    131133                "vegetarianFood": 0,
    132134            },
    133135            "treasuresCollected": 0,
     
    189191            "resourcesGathered": {
    190192                "food": 100,   
    191193                "wood": 0, 
     194                "stone": 0,
    192195                "metal": 0,
    193                 "stone": 0,
     196                "total": 0,
    194197                "vegetarianFood": 0,
    195198            },
    196199            "percentMapExplored": 10
     
    206209            "resourcesGathered": {
    207210                "food": 100,   
    208211                "wood": 0, 
    209                 "metal": 0,
    210212                "stone": 0,
     213                "metal": 0,
     214                "total": 0,
    211215                "vegetarianFood": 0,
    212216            },
    213217            "treasuresCollected": 0,
     
    262266                resourcesGathered: {
    263267                    food: 100,
    264268                    wood: 0,
     269                    stone: 0,
    265270                    metal: 0,
    266                     stone: 0,
     271                    total: 0,
    267272                    vegetarianFood: 0,
    268273                },
    269274                percentMapExplored: 10
     
    301306                resourcesGathered: {
    302307                    food: 100,
    303308                    wood: 0,
     309                    stone: 0,
    304310                    metal: 0,
    305                     stone: 0,
     311                    total: 0,
    306312                    vegetarianFood: 0,
    307313                },
    308314                percentMapExplored: 10
     
    354360                resourcesGathered: {
    355361                    food: 100,
    356362                    wood: 0,
     363                    stone: 0,
    357364                    metal: 0,
    358                     stone: 0,
     365                    total: 0,
    359366                    vegetarianFood: 0,
    360367                },
    361368                treasuresCollected: 0,
     
    405412                resourcesGathered: {
    406413                    food: 100,
    407414                    wood: 0,
     415                    stone: 0,
    408416                    metal: 0,
    409                     stone: 0,
     417                    total: 0,
    410418                    vegetarianFood: 0,
    411419                },
    412420                treasuresCollected: 0,
  • source/tools/XpartaMuPP/LobbyRanking.py

     
    11#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    3 """Copyright (C) 2013 Wildfire Games.
     3"""Copyright (C) 2015 Wildfire Games.
    44 * This file is part of 0 A.D.
    55 *
    66 * 0 A.D. is free software: you can redistribute it and/or modify
     
    5959    stoneUsed = Column(Integer)
    6060    metalGathered = Column(Integer)
    6161    metalUsed = Column(Integer)
     62    totalGathered = Column(Integer)
     63    totalUsed = Column(Integer)
    6264    vegetarianFoodGathered = Column(Integer)
    6365    treasuresCollected = Column(Integer)
    6466    lootCollected = Column(Integer)
  • source/tools/XpartaMuPP/XpartaMuPP.py

     
    11#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    3 """Copyright (C) 2014 Wildfire Games.
     3"""Copyright (C) 2015 Wildfire Games.
    44 * This file is part of 0 A.D.
    55 *
    66 * 0 A.D. is free software: you can redistribute it and/or modify
     
    121121    singleStats = {'timeElapsed', 'mapName', 'teamsLocked', 'matchID'}
    122122    totalScoreStats = {'economyScore', 'militaryScore', 'totalScore'}
    123123    resourceStats = {'foodGathered', 'foodUsed', 'woodGathered', 'woodUsed',
    124             'stoneGathered', 'stoneUsed', 'metalGathered', 'metalUsed', 'vegetarianFoodGathered',
     124            'stoneGathered', 'stoneUsed', 'metalGathered', 'metalUsed', 'totalGathered', 'totalUsed', 'vegetarianFoodGathered',
    125125            'treasuresCollected', 'lootCollected', 'tributesSent', 'tributesReceived'}
    126126    unitsStats = {'totalUnitsTrained', 'totalUnitsLost', 'enemytotalUnitsKilled', 'infantryUnitsTrained',
    127127            'infantryUnitsLost', 'enemyInfantryUnitsKilled', 'workerUnitsTrained', 'workerUnitsLost',