Ticket #2936: TemplateAnalyzerUpdate.patch
File TemplateAnalyzerUpdate.patch, 5.9 KB (added by , 9 years ago) |
---|
-
source/tools/templatesanalyzer/CreateRMTest.py
1 # 2 # CreateRMTest.py 3 # Released under the MIT license by Wraitii, 2014 4 # See ../LICENSES.TXT for more info 5 # 6 1 7 import xml.etree.ElementTree as ET 2 8 import os 3 9 -
source/tools/templatesanalyzer/unitTables.py
1 # 2 # unitTables.py 3 # Released under the MIT license by Wraitii, 2014 4 # See ../LICENSES.TXT for more info 5 # 6 1 7 import xml.etree.ElementTree as ET 2 8 import os 3 9 import glob … … 51 57 def htout(file, value): 52 58 file.write("<p>" + value + "</p>\n" ) 53 59 60 def NumericStatProcess(unit, newValue, templateValue): 61 if (newValue not in unit): 62 unit[newValue] = 0; # This is kind of a sanity hack. 63 if (templateValue.attrib == {}): 64 unit[newValue] = templateValue.text 65 elif (templateValue.attrib == "add"): 66 newValue += templateValue.text 67 elif (templateValue.attrib == "sub"): 68 newValue -= templateValue.text 69 elif (templateValue.attrib == "mul"): 70 newValue *= templateValue.text 71 elif (templateValue.attrib == "div"): 72 newValue /= templateValue.text 73 54 74 def CalcUnit(UnitName, existingUnit = None): 55 75 unit = { 'HP' : "0", "BuildTime" : "0", "Cost" : { 'food' : "0", "wood" : "0", "stone" : "0", "metal" : "0", "population" : "0"}, 56 76 'Attack' : { "Melee" : { "Hack" : 0, "Pierce" : 0, "Crush" : 0 }, "Ranged" : { "Hack" : 0, "Pierce" : 0, "Crush" : 0 } }, … … 69 89 unit["Parent"] = Template.getroot().get("parent") + ".xml" 70 90 71 91 if (Template.find("./Identity/Civ") != None): 72 unit['Civ'] = Template.find("./Identity/Civ").text92 NumericStatProcess(unit, 'Civ', Template.find("./Identity/Civ")) 73 93 74 94 if (Template.find("./Health/Max") != None): 75 unit['HP'] = Template.find("./Health/Max").text95 NumericStatProcess(unit, 'HP', Template.find("./Health/Max")) 76 96 77 97 if (Template.find("./Cost/BuildTime") != None): 78 unit['BuildTime'] = Template.find("./Cost/BuildTime").text98 NumericStatProcess(unit, 'BuildTime', Template.find("./Cost/BuildTime")) 79 99 80 100 if (Template.find("./Cost/Resources") != None): 81 101 for type in list(Template.find("./Cost/Resources")): 82 unit['Cost'][type.tag] = type.text102 NumericStatProcess(unit['Cost'], type.tag, type) 83 103 84 104 if (Template.find("./Attack/Melee") != None): 85 105 if (Template.find("./Attack/Melee/RepeatTime") != None): 86 unit['RepeatRate']["Melee"] = Template.find("./Attack/Melee/RepeatTime").text106 NumericStatProcess(unit['RepeatRate'], "Melee", Template.find("./Attack/Melee/RepeatTime")) 87 107 if (Template.find("./Attack/Melee/PrepareTime") != None): 88 unit['PrepRate']["Melee"] = Template.find("./Attack/Melee/PrepareTime").text108 NumericStatProcess(unit['PrepRate'], "Melee", Template.find("./Attack/Melee/PrepareTime")) 89 109 for atttype in AttackTypes: 90 110 if (Template.find("./Attack/Melee/"+atttype) != None): 91 unit['Attack']['Melee'][atttype] = Template.find("./Attack/Melee/"+atttype).text111 NumericStatProcess(unit['Attack']['Melee'], atttype, Template.find("./Attack/Melee/"+atttype)) 92 112 if (Template.find("./Attack/Melee/Bonuses") != None): 93 113 for Bonus in Template.find("./Attack/Melee/Bonuses"): 94 114 Against = [] … … 112 132 if (Template.find("./Attack/Ranged") != None): 113 133 unit['Ranged'] = "true" 114 134 if (Template.find("./Attack/Ranged/MaxRange") != None): 115 unit['Range'] = Template.find("./Attack/Ranged/MaxRange").text135 NumericStatProcess(unit, 'Range', Template.find("./Attack/Ranged/MaxRange")) 116 136 if (Template.find("./Attack/Ranged/RepeatTime") != None): 117 unit['RepeatRate']["Ranged"] = Template.find("./Attack/Ranged/RepeatTime").text137 NumericStatProcess(unit['RepeatRate'], "Ranged", Template.find("./Attack/Ranged/RepeatTime")) 118 138 if (Template.find("./Attack/Ranged/PrepareTime") != None): 119 unit['PrepRate']["Ranged"] = Template.find("./Attack/Ranged/PrepareTime").text139 NumericStatProcess(unit['PrepRate'], "Ranged", Template.find("./Attack/Ranged/PrepareTime")) 120 140 for atttype in AttackTypes: 121 141 if (Template.find("./Attack/Ranged/"+atttype) != None): 122 unit['Attack']['Ranged'][atttype] = Template.find("./Attack/Ranged/"+atttype).text142 NumericStatProcess(unit['Attack']['Ranged'], atttype, Template.find("./Attack/Ranged/"+atttype)) 123 143 if (Template.find("./Attack/Ranged/Bonuses") != None): 124 144 for Bonus in Template.find("./Attack/Ranged/Bonuses"): 125 145 Against = [] … … 142 162 if (Template.find("./Armour") != None): 143 163 for atttype in AttackTypes: 144 164 if (Template.find("./Armour/"+atttype) != None): 145 unit['Armour'][atttype] = Template.find("./Armour/"+atttype).text165 NumericStatProcess(unit['Armour'], atttype, Template.find("./Armour/"+atttype)) 146 166 147 167 if (Template.find("./UnitMotion") != None): 148 168 if (Template.find("./UnitMotion/WalkSpeed") != None): 149 unit['WalkSpeed'] = Template.find("./UnitMotion/WalkSpeed").text169 NumericStatProcess(unit, 'WalkSpeed', Template.find("./UnitMotion/WalkSpeed")) 150 170 151 171 if (Template.find("./Identity/VisibleClasses") != None): 152 172 newClasses = Template.find("./Identity/VisibleClasses").text.split(" ") … … 174 194 175 195 rstr += "<td style=\"text-align:right;\">" + Name + "</td>\n" 176 196 177 rstr += "<td>" + UnitDict["HP"]+ "</td>\n"197 rstr += "<td>" + str(UnitDict["HP"]) + "</td>\n" 178 198 179 rstr += "<td>" + UnitDict["BuildTime"]+ "</td>\n"199 rstr += "<td>" + str(UnitDict["BuildTime"]) + "</td>\n" 180 200 181 rstr += "<td>" + UnitDict["WalkSpeed"]+ "</td>\n"201 rstr += "<td>" + str(UnitDict["WalkSpeed"]) + "</td>\n" 182 202 183 203 rstr += "<td>" + UnitDict["Cost"]["food"] + "F / " + UnitDict["Cost"]["wood"] + "W / " + UnitDict["Cost"]["stone"] + "S / " + UnitDict["Cost"]["metal"] + "M</td>\n" 184 204