Ticket #2936: TemplateAnalyzerUpdate_fixed_typo_license.patch
File TemplateAnalyzerUpdate_fixed_typo_license.patch, 7.6 KB (added by , 9 years ago) |
---|
-
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 1 21 import xml.etree.ElementTree as ET 2 22 import os 3 23 -
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 1 21 import xml.etree.ElementTree as ET 2 22 import os 3 23 import glob … … 51 71 def htout(file, value): 52 72 file.write("<p>" + value + "</p>\n" ) 53 73 74 def 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 54 88 def CalcUnit(UnitName, existingUnit = None): 55 89 unit = { 'HP' : "0", "BuildTime" : "0", "Cost" : { 'food' : "0", "wood" : "0", "stone" : "0", "metal" : "0", "population" : "0"}, 56 90 'Attack' : { "Melee" : { "Hack" : 0, "Pierce" : 0, "Crush" : 0 }, "Ranged" : { "Hack" : 0, "Pierce" : 0, "Crush" : 0 } }, … … 69 103 unit["Parent"] = Template.getroot().get("parent") + ".xml" 70 104 71 105 if (Template.find("./Identity/Civ") != None): 72 unit['Civ'] = Template.find("./Identity/Civ").text106 NumericStatProcess(unit, 'Civ', Template.find("./Identity/Civ")) 73 107 74 108 if (Template.find("./Health/Max") != None): 75 unit['HP'] = Template.find("./Health/Max").text109 NumericStatProcess(unit, 'HP', Template.find("./Health/Max")) 76 110 77 111 if (Template.find("./Cost/BuildTime") != None): 78 unit['BuildTime'] = Template.find("./Cost/BuildTime").text112 NumericStatProcess(unit, 'BuildTime', Template.find("./Cost/BuildTime")) 79 113 80 114 if (Template.find("./Cost/Resources") != None): 81 115 for type in list(Template.find("./Cost/Resources")): 82 unit['Cost'][type.tag] = type.text116 NumericStatProcess(unit['Cost'], type.tag, type) 83 117 84 118 if (Template.find("./Attack/Melee") != None): 85 119 if (Template.find("./Attack/Melee/RepeatTime") != None): 86 unit['RepeatRate']["Melee"] = Template.find("./Attack/Melee/RepeatTime").text120 NumericStatProcess(unit['RepeatRate'], "Melee", Template.find("./Attack/Melee/RepeatTime")) 87 121 if (Template.find("./Attack/Melee/PrepareTime") != None): 88 unit['PrepRate']["Melee"] = Template.find("./Attack/Melee/PrepareTime").text122 NumericStatProcess(unit['PrepRate'], "Melee", Template.find("./Attack/Melee/PrepareTime")) 89 123 for atttype in AttackTypes: 90 124 if (Template.find("./Attack/Melee/"+atttype) != None): 91 unit['Attack']['Melee'][atttype] = Template.find("./Attack/Melee/"+atttype).text125 NumericStatProcess(unit['Attack']['Melee'], atttype, Template.find("./Attack/Melee/"+atttype)) 92 126 if (Template.find("./Attack/Melee/Bonuses") != None): 93 127 for Bonus in Template.find("./Attack/Melee/Bonuses"): 94 128 Against = [] … … 112 146 if (Template.find("./Attack/Ranged") != None): 113 147 unit['Ranged'] = "true" 114 148 if (Template.find("./Attack/Ranged/MaxRange") != None): 115 unit['Range'] = Template.find("./Attack/Ranged/MaxRange").text149 NumericStatProcess(unit, 'Range', Template.find("./Attack/Ranged/MaxRange")) 116 150 if (Template.find("./Attack/Ranged/RepeatTime") != None): 117 unit['RepeatRate']["Ranged"] = Template.find("./Attack/Ranged/RepeatTime").text151 NumericStatProcess(unit['RepeatRate'], "Ranged", Template.find("./Attack/Ranged/RepeatTime")) 118 152 if (Template.find("./Attack/Ranged/PrepareTime") != None): 119 unit['PrepRate']["Ranged"] = Template.find("./Attack/Ranged/PrepareTime").text153 NumericStatProcess(unit['PrepRate'], "Ranged", Template.find("./Attack/Ranged/PrepareTime")) 120 154 for atttype in AttackTypes: 121 155 if (Template.find("./Attack/Ranged/"+atttype) != None): 122 unit['Attack']['Ranged'][atttype] = Template.find("./Attack/Ranged/"+atttype).text156 NumericStatProcess(unit['Attack']['Ranged'], atttype, Template.find("./Attack/Ranged/"+atttype)) 123 157 if (Template.find("./Attack/Ranged/Bonuses") != None): 124 158 for Bonus in Template.find("./Attack/Ranged/Bonuses"): 125 159 Against = [] … … 142 176 if (Template.find("./Armour") != None): 143 177 for atttype in AttackTypes: 144 178 if (Template.find("./Armour/"+atttype) != None): 145 unit['Armour'][atttype] = Template.find("./Armour/"+atttype).text179 NumericStatProcess(unit['Armour'], atttype, Template.find("./Armour/"+atttype)) 146 180 147 181 if (Template.find("./UnitMotion") != None): 148 182 if (Template.find("./UnitMotion/WalkSpeed") != None): 149 unit['WalkSpeed'] = Template.find("./UnitMotion/WalkSpeed").text183 NumericStatProcess(unit, 'WalkSpeed', Template.find("./UnitMotion/WalkSpeed")) 150 184 151 185 if (Template.find("./Identity/VisibleClasses") != None): 152 186 newClasses = Template.find("./Identity/VisibleClasses").text.split(" ") … … 174 208 175 209 rstr += "<td style=\"text-align:right;\">" + Name + "</td>\n" 176 210 177 rstr += "<td>" + UnitDict["HP"]+ "</td>\n"211 rstr += "<td>" + str(UnitDict["HP"]) + "</td>\n" 178 212 179 rstr += "<td>" + UnitDict["BuildTime"]+ "</td>\n"213 rstr += "<td>" + str(UnitDict["BuildTime"]) + "</td>\n" 180 214 181 rstr += "<td>" + UnitDict["WalkSpeed"]+ "</td>\n"215 rstr += "<td>" + str(UnitDict["WalkSpeed"]) + "</td>\n" 182 216 183 217 rstr += "<td>" + UnitDict["Cost"]["food"] + "F / " + UnitDict["Cost"]["wood"] + "W / " + UnitDict["Cost"]["stone"] + "S / " + UnitDict["Cost"]["metal"] + "M</td>\n" 184 218 185 if UnitDict["Ranged"] == " True":219 if UnitDict["Ranged"] == "true": 186 220 rstr += "<td>" + str(UnitDict["Attack"]["Ranged"]["Hack"]) + " / " + str(UnitDict["Attack"]["Ranged"]["Pierce"]) + " / " + str(UnitDict["Attack"]["Ranged"]["Crush"]) + "</td>\n" 187 221 else: 188 222 rstr += "<td>" + str(UnitDict["Attack"]["Melee"]["Hack"]) + " / " + str(UnitDict["Attack"]["Melee"]["Pierce"]) + " / " + str(UnitDict["Attack"]["Melee"]["Crush"]) + "</td>\n"