Ticket #2936: TemplateAnalyzerUpdate_fixed_typo_license.patch

File TemplateAnalyzerUpdate_fixed_typo_license.patch, 7.6 KB (added by elexis, 9 years ago)

Fixes the typo and license in wraitii's TemplateAnalyzerUpdate.patch​. To prove that the patch is identical otherwise, do a diff against his patch.

  • source/tools/templatesanalyzer/CreateRMTest.py

     
     1'''
     2 * CreateRMTest.py
     3 *
     4 * Copyright (C) 2015 Wildfire Games.
     5 * This file is part of 0 A.D.
     6 *
     7 * 0 A.D. is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 2 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * 0 A.D. is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
     19'''
     20
    121import xml.etree.ElementTree as ET
    222import os
    323
  • source/tools/templatesanalyzer/unitTables.py

     
     1'''
     2 * unitTables.py
     3 *
     4 * Copyright (C) 2015 Wildfire Games.
     5 * This file is part of 0 A.D.
     6 *
     7 * 0 A.D. is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 2 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * 0 A.D. is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
     19'''
     20
    121import xml.etree.ElementTree as ET
    222import os
    323import glob
     
    5171def htout(file, value):
    5272    file.write("<p>" + value + "</p>\n" )
    5373
     74def NumericStatProcess(unit, newValue, templateValue):
     75    if (newValue not in unit):
     76        unit[newValue] = 0; # This is kind of a sanity hack.
     77    if (templateValue.attrib == {}):
     78        unit[newValue] = templateValue.text
     79    elif (templateValue.attrib == "add"):
     80        newValue += templateValue.text
     81    elif (templateValue.attrib == "sub"):
     82        newValue -= templateValue.text
     83    elif (templateValue.attrib == "mul"):
     84        newValue *= templateValue.text
     85    elif (templateValue.attrib == "div"):
     86        newValue /= templateValue.text
     87
    5488def CalcUnit(UnitName, existingUnit = None):
    5589    unit = { 'HP' : "0", "BuildTime" : "0", "Cost" : { 'food' : "0", "wood" : "0", "stone" : "0", "metal" : "0", "population" : "0"},
    5690    'Attack' : { "Melee" : { "Hack" : 0, "Pierce" : 0, "Crush" : 0 }, "Ranged" : { "Hack" : 0, "Pierce" : 0, "Crush" : 0 } },
     
    69103        unit["Parent"] = Template.getroot().get("parent") + ".xml"
    70104
    71105    if (Template.find("./Identity/Civ") != None):
    72         unit['Civ'] = Template.find("./Identity/Civ").text
     106        NumericStatProcess(unit, 'Civ', Template.find("./Identity/Civ"))
    73107
    74108    if (Template.find("./Health/Max") != None):
    75         unit['HP'] = Template.find("./Health/Max").text
     109        NumericStatProcess(unit, 'HP', Template.find("./Health/Max"))
    76110
    77111    if (Template.find("./Cost/BuildTime") != None):
    78         unit['BuildTime'] = Template.find("./Cost/BuildTime").text
     112        NumericStatProcess(unit, 'BuildTime', Template.find("./Cost/BuildTime"))
    79113   
    80114    if (Template.find("./Cost/Resources") != None):
    81115        for type in list(Template.find("./Cost/Resources")):
    82             unit['Cost'][type.tag] = type.text
     116            NumericStatProcess(unit['Cost'], type.tag, type)
    83117
    84118    if (Template.find("./Attack/Melee") != None):
    85119        if (Template.find("./Attack/Melee/RepeatTime") != None):
    86             unit['RepeatRate']["Melee"] = Template.find("./Attack/Melee/RepeatTime").text
     120            NumericStatProcess(unit['RepeatRate'], "Melee", Template.find("./Attack/Melee/RepeatTime"))
    87121        if (Template.find("./Attack/Melee/PrepareTime") != None):
    88             unit['PrepRate']["Melee"] = Template.find("./Attack/Melee/PrepareTime").text
     122            NumericStatProcess(unit['PrepRate'], "Melee", Template.find("./Attack/Melee/PrepareTime"))
    89123        for atttype in AttackTypes:
    90124            if (Template.find("./Attack/Melee/"+atttype) != None):
    91                 unit['Attack']['Melee'][atttype] = Template.find("./Attack/Melee/"+atttype).text
     125                NumericStatProcess(unit['Attack']['Melee'], atttype, Template.find("./Attack/Melee/"+atttype))
    92126        if (Template.find("./Attack/Melee/Bonuses") != None):
    93127            for Bonus in Template.find("./Attack/Melee/Bonuses"):
    94128                Against = []
     
    112146    if (Template.find("./Attack/Ranged") != None):
    113147        unit['Ranged'] = "true"
    114148        if (Template.find("./Attack/Ranged/MaxRange") != None):
    115             unit['Range'] = Template.find("./Attack/Ranged/MaxRange").text
     149            NumericStatProcess(unit, 'Range', Template.find("./Attack/Ranged/MaxRange"))
    116150        if (Template.find("./Attack/Ranged/RepeatTime") != None):
    117             unit['RepeatRate']["Ranged"] = Template.find("./Attack/Ranged/RepeatTime").text
     151            NumericStatProcess(unit['RepeatRate'], "Ranged", Template.find("./Attack/Ranged/RepeatTime"))
    118152        if (Template.find("./Attack/Ranged/PrepareTime") != None):
    119             unit['PrepRate']["Ranged"] = Template.find("./Attack/Ranged/PrepareTime").text
     153            NumericStatProcess(unit['PrepRate'], "Ranged", Template.find("./Attack/Ranged/PrepareTime"))
    120154        for atttype in AttackTypes:
    121155            if (Template.find("./Attack/Ranged/"+atttype) != None):
    122                 unit['Attack']['Ranged'][atttype] = Template.find("./Attack/Ranged/"+atttype).text
     156                NumericStatProcess(unit['Attack']['Ranged'], atttype, Template.find("./Attack/Ranged/"+atttype))
    123157        if (Template.find("./Attack/Ranged/Bonuses") != None):
    124158            for Bonus in Template.find("./Attack/Ranged/Bonuses"):
    125159                Against = []
     
    142176    if (Template.find("./Armour") != None):
    143177        for atttype in AttackTypes:
    144178            if (Template.find("./Armour/"+atttype) != None):
    145                 unit['Armour'][atttype] = Template.find("./Armour/"+atttype).text
     179                NumericStatProcess(unit['Armour'], atttype, Template.find("./Armour/"+atttype))
    146180
    147181    if (Template.find("./UnitMotion") != None):
    148182        if (Template.find("./UnitMotion/WalkSpeed") != None):
    149                 unit['WalkSpeed'] = Template.find("./UnitMotion/WalkSpeed").text
     183                NumericStatProcess(unit, 'WalkSpeed', Template.find("./UnitMotion/WalkSpeed"))
    150184
    151185    if (Template.find("./Identity/VisibleClasses") != None):
    152186        newClasses = Template.find("./Identity/VisibleClasses").text.split(" ")
     
    174208
    175209    rstr += "<td style=\"text-align:right;\">" + Name + "</td>\n"
    176210   
    177     rstr += "<td>" + UnitDict["HP"] + "</td>\n"
     211    rstr += "<td>" + str(UnitDict["HP"]) + "</td>\n"
    178212
    179     rstr += "<td>" + UnitDict["BuildTime"] + "</td>\n"
     213    rstr += "<td>" + str(UnitDict["BuildTime"]) + "</td>\n"
    180214
    181     rstr += "<td>" + UnitDict["WalkSpeed"] + "</td>\n"
     215    rstr += "<td>" + str(UnitDict["WalkSpeed"]) + "</td>\n"
    182216   
    183217    rstr += "<td>" + UnitDict["Cost"]["food"] + "F / " + UnitDict["Cost"]["wood"] + "W / " + UnitDict["Cost"]["stone"] + "S / " + UnitDict["Cost"]["metal"] + "M</td>\n"
    184218
    185     if UnitDict["Ranged"] == "True":
     219    if UnitDict["Ranged"] == "true":
    186220        rstr += "<td>" + str(UnitDict["Attack"]["Ranged"]["Hack"]) + " / " + str(UnitDict["Attack"]["Ranged"]["Pierce"]) + " / " + str(UnitDict["Attack"]["Ranged"]["Crush"]) + "</td>\n"
    187221    else:
    188222        rstr += "<td>" + str(UnitDict["Attack"]["Melee"]["Hack"]) + " / " + str(UnitDict["Attack"]["Melee"]["Pierce"]) + " / " + str(UnitDict["Attack"]["Melee"]["Crush"]) + "</td>\n"