-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwares_generator.py
More file actions
45 lines (41 loc) · 2.63 KB
/
wares_generator.py
File metadata and controls
45 lines (41 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import csv
csv_file = 'VROMISSILES.csv'
xml_data_final = ''
csv_data = csv.DictReader(open(csv_file), fieldnames=['name', 'macro', 'tags', 'info', 'race', 'damage', 'reload', 'amount', 'barrel', 'dps', 'alpha', 'lifetime', 'thrust', 'speed', 'travel', 'firerange', 'guided', 'retarget', 'swarm', 'locktime', 'lockrange', 'hull', 'weapon', 'resiliense', 'mass', 'inertia', 'dforward', 'dhv', 'dman', 'explosioneffect', 'launcheffect', 'engine', 'component', 'price', 'cells', 'mcs', 'sc', 'prodtime', 'tname', 'tbasename', 'tdescription'])
row_n = 0
for row in csv_data:
if row_n == 0:
print('row' + str(row_n) + ' is not printing')
row_n += 1
else:
ware_name = 'missile_' + row['name']
print(ware_name)
price_min_f = int(row['price']) - int(row['price'])*0.15
price_min = int(price_min_f)
price_max_f = int(row['price']) + int(row['price'])*0.15
price_max = int(price_max_f)
tname = '{6699, ' + row['tname'] + '}'
tbasename = '{6699, ' + row['tbasename'] + '}'
tdescription = '{6699, ' + row['tdescription'] + '}'
xml_data = '<ware id="%s" name="%s" description="%s" group="missiles" transport="equipment" volume="1" tags="equipment missile">\n<price min="%s" average="%s" max="%s" />\n<production time="%s" amount="1" method="default" name="{20206,101}">\n<primary>\n<ware ware="energycells" amount="%s" />\n<ware ware="missilecomponents" amount="%s" />]\n<ware ware="smartchips" amount="%s" />\n</primary>\n</production>\n<component ref="%s" amount="1" />\n<container ref="sm_gen_pickup_equipment_01_macro" />\n<use threshold="0"/>\n' % (ware_name, tname, tdescription, price_min, row['price'], price_max, row['prodtime'], row['cells'], row['mcs'], row['sc'], row['macro'])
if row['race'] == '0':
xml_data = xml_data + '</ware>\n\n'
xml_data_final += xml_data
row_n += 1
elif row['race'] == 'argon':
xml_data = xml_data + '<owner faction="antigone"/>\n<owner faction="argon"/>\n</ware>\n\n'
xml_data_final += xml_data
row_n += 1
elif row['race'] == 'paranid':
xml_data = xml_data + '<owner faction="holyorder"/>\n<owner faction="paranid"/>\n</ware>\n\n'
xml_data_final += xml_data
row_n += 1
elif row['race'] == 'teladi':
xml_data = xml_data + '<owner faction="teladi"/>\n<owner faction="ministry"/>\n</ware>\n\n'
xml_data_final += xml_data
row_n += 1
print(xml_data_final)
xml_file = 'generated_wares.xml'
F = open(xml_file, 'w')
F.write(xml_data_final)
F.close