-
Notifications
You must be signed in to change notification settings - Fork 0
/
items.py
170 lines (164 loc) · 7.44 KB
/
items.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import csv
import sys
import os
print("FFXIV Item Database Generator")
print("Written by Catuse167 of FFWiki - Ver. 1.2")
file = raw_input("What is the name of the CSV file? ")
with open('LuaData/meta.lua','ab') as f:
patch = raw_input("What patch of FFXIV is this? ")
print("Reporting metadata to LuaData/meta.lua...")
f.write("\titemPatch = " + patch + ",\n")
icons = ""
with open(file, 'rb') as csvfile:
print("Reading from " + file + ".")
reader = csv.DictReader(csvfile)
typeset = [""]
for i in xrange(0,94):
typeset.append("")
print("Printing item data to LuaData/*.lua.")
for row in reader:
if row['name']:
#print(row['name']) For debugging
typeset[int(row['itemUIindex'])] += row['name'] + "; "
icon = row['iconID']
src = ""
if int(icon) < 10:
src = "ui/icon/00000" + icon + ".tex.png"
elif int(icon) < 100:
src = "ui/icon/0000" + icon + ".tex.png"
elif int(icon) < 1000:
src = "ui/icon/000" + icon + ".tex.png"
elif int(icon) < 10000:
src = "ui/icon/00" + icon + ".tex.png"
print("So far so good.")
elif int(icon) < 100000:
src = "ui/icon/0" + icon + ".tex.png"
elif int(icon) < 1000000:
src = "ui/icon/" + icon + ".tex.png"
else:
print("No icon for " + row['name'] + "!")
with open('logs/error.log','ab') as errlog:
errlog.write("No icon for " + row['name'] + "!")
if src:
try:
os.rename(src, "filesToUpload/FFXIV " + row['name'] + " Icon.png")
icons += "[" + icon + "]=\""File:FFXIV " + row['Name'] + " Icon.png"\","
except WindowsError:
with open('error.log','ab') as errlog:
errlog.write("No icon for " + row['name'] + "!")
written = "[\"" + row['name'] + "\"]={"
written += "id=" + row['itemID'] + ","
written += "typ=" + row['itemUIindex'] + ","
written += "ico=" + icon + ","
if row['equipcategory'] and row['equipcategory'] != "0":
written += "job=" + row['equipcategory'] + ","
if row['characterlevel'] and row['characterlevel'] != "0":
written += "lv=" + row['characterlevel'] + ","
if row['itemlevel'] and row['itemlevel'] != "0":
written += "ilv=" + row['itemlevel'] + ","
if row['flavortext']:
written += "flv=\"" + row['flavortext'] + "\","
if row['r88GC'] and row['r88GC'] != "0":
written += "gc=" + row['r88GC'] + ","
if row['male'] == "false" and row['female'] != "false":
written += "gen=2,"
if row['female'] == "false" and row['male'] != "false":
written += "gen=1,"
if row['hyur'] == "true" and row['elezen'] == "false":
written += "race=1,"
elif row['elezen'] == "true" and row['hyur'] == "false":
written += "race=2,"
elif row['miqote'] == "true" and row['hyur'] == "false":
written += "race=3,"
elif row['roe'] == "true" and row['hyur'] == "false":
written += "race=4,"
elif row['aura'] == "true" and row['hyur'] == "false":
written += "race=5,"
if row['PhysicalDamage'] and row['PhysicalDamage'] != "0":
written += "pdm=" + row['PhysicalDamage'] + ","
if row['MagicalDamage'] and row['MagicalDamage'] != "0":
written += "mdm=" + row['MagicalDamage'] + ","
if row['autoattackdelay(ms)'] and row['autoattackdelay(ms)'] != "0":
written += "aad=" + row['autoattackdelay(ms)'] + ","
if row['blockrate'] and row['blockrate'] != "0":
written += "blkr=" + row['blockrate'] + ","
if row['block'] and row['block'] != "0":
written += "blks=" + row['block'] + ","
if row['pdef'] and row['pdef'] != "0":
written += "pdf=" + row['pdef'] + ","
if row['mdef'] and row['mdef'] != "0":
written += "mdf=" + row['mdef'] + ","
if row['cooldown'] and row['cooldown'] != "0":
written += "cld=" + row['cooldown'] + ","
if row['PvPrank'] and row['PvPrank'] != "0":
written += "pvp=" + row['PvPrank'] + ","
if row['statname1'] and row['statname1'] != "0":
written += "s={"
written += "[" + row['statname1'] + "]=" + row['statvalue1'] + ","
if row['statname2'] and row['statname2'] != "0":
written += "[" + row['statname2'] + "]=" + row['statvalue2'] + ","
if row['statname3'] and row['statname3'] != "0":
written += "[" + row['statname3'] + "]=" + row['statvalue3'] + ","
if row['statname4'] and row['statname4'] != "0":
written += "[" + row['statname4'] + "]=" + row['statvalue4'] + ","
if row['statname5'] and row['statname5'] != "0":
written += "[" + row['statname5'] + "]=" + row['statvalue5'] + ","
if row['statname6'] and row['statname6'] != "0":
written += "[" + row['statname6'] + "]=" + row['statvalue6'] + ","
written += "},"
hqtest = int(row['HQstatbonus1']) + int(row['HQstatbonus2']) + int(row['HQstatbonus3']) + int(row['HQstatbonus4']) + int(row['primehqaddition2']) + int(row['primehqaddition4'])
if hqtest > 0:
written += "hq={"
if row['HQstatbonus1'] != "0":
written += "[" + row['HQstatbonus2'] + "]=" + row['HQstatbonus2'] + ","
if row['HQstat2'] != "0":
written += "[" + row['HQstatbonus2'] + "]=" + row['HQstatbonus2'] + ","
if row['HQstat3'] != "0":
written += "[" + row['HQstatbonus3'] + "]=" + row['HQstatbonus3'] + ","
if row['HQstat4'] != "0":
written += "[" + row['HQstatbonus4'] + "]=" + row['HQstatbonus4'] + ","
if row['primehqaddition2'] != "0":
written += "[" + row['primehqaddition1'] + "]=" + row['primehqaddition2'] + ","
if row['primehqaddition4'] != "0":
written += "[" + row['primehqaddition3'] + "]=" + row['primehqaddition4'] + ","
written += "},"
if row['nondisposable'] and row['nondisposable'] == "true":
written += "ndis=1,"
if row['unique'] and row['unique'] == "true":
written += "uniq=1,"
if row['untradable'] and row['untradable'] == "true":
written += "untr=1,"
if row['candye'] and row['candye'] == "true":
written += "dye=1,"
if row['cancrest'] and row['cancrest'] == "true":
written += "crs=1,"
if row['stainindex'] and row['stainindex'] != "0":
written += "stn=" + row['stainindex'] + ","
if row['repairjob'] and row['repairjob'] != "0":
written += "rjob=" + row['repairjob'] + ","
if row['repairdarkmatter'] and row['repairjob'] != "0":
written += "dmat=" + row['repairdarkmatter'] + ","
if row['desynth'] and row['desynth'] != "0":
written += "dsyn=" + row['desynth'] + ","
if row['collectible'] and row['collectible'] != "0":
written += "col=" + row['collectible'] + ","
written += "},\n"
typ = int(row['itemUIindex'])
if (typ > 0 and typ < 11) or (typ == 84) or (typ > 86 and typ < 90):
with open('LuaData/arms.lua','ab') as f: f.write(written)
elif typ > 11 and typ < 33:
with open('LuaData/tools.lua','ab') as f: f.write(written)
elif typ == 11 or (typ > 33 and typ < 40):
with open('LuaData/armor.lua','ab') as f: f.write(written)
elif typ == 62 or (typ > 39 and typ < 44):
with open('LuaData/accessories.lua','ab') as f: f.write(written)
elif typ == 44 or typ == 46:
with open('LuaData/medicinesandmeals.lua','ab') as f: f.write(written)
elif typ == 45 or (typ > 46 and typ < 57):
with open('LuaData/materials.lua','ab') as f: f.write(written)
else:
with open('LuaData/other.lua','ab') as f: f.write(written)
print("Printing item sets to Wikitext/itemsets.py.")
with open('Wikitext/itemsets.py','ab') as f: f.write(str(typeset))
print("Printing icon list to sets to LuaData/icons.lua")
with open('LuaData/icons.lua','ab') as f: f.write(icons)