forked from manavortex/FurnitureCatalogue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFurCDatabaseQuery.lua
203 lines (169 loc) · 7.53 KB
/
FurCDatabaseQuery.lua
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
local FurC = FurC
local vendorColor = "d68957"
local goldColor = "e5da40"
local apColor = "25C31E"
local tvColor = "5EA4FF"
local voucherColor = "82BCFF"
local p = FurC.DebugOut -- debug function calling zo_strformat with up to 10 args
local function colorise(str, col, ret)
str = tostring(str)
if str:find("%d000$") then str = str:gsub("000$", "k") end
if ret then return str end
return string.format("|c%s%s|r", col, str)
end
local function makeAchievementLink(achievementId)
if not achievementId then return end
if tonumber(achievementId) ~= achievementId then return GetString(SI_FURC_REQUIRES_QUEST) ..achievementId end
return GetString(SI_FURC_REQUIRES_ACHIEVEMENT) .. GetAchievementLink(achievementId)
end
local function getRolisSource(recipeKey, recipeArray)
recipeArray = recipeArray or FurC.Find(recipeKey)
if not recipeArray then return end
local versionData = FurC.Rolis[recipeArray.version]
if nil ~= versionData and nil ~= versionData[recipeKey] then
local itemPrice = zo_strformat(GetString(SI_FURC_STRING_FOR_VOUCHERS), colorise(versionData[recipeKey], voucherColor))
return zo_strformat(GetString(SI_FURC_STRING_Rolis), itemPrice)
end
versionData = FurC.Faustina[recipeArray.version]
if nil ~= versionData and nil ~= versionData[recipeKey] then
local itemPrice = zo_strformat(GetString(SI_FURC_STRING_FOR_VOUCHERS), colorise(versionData[recipeKey], voucherColor))
return zo_strformat(GetString(SI_FURC_STRING_FAUSTINA), itemPrice)
end
return GetString(SI_FURC_STRING_VOUCHER_VENDOR)
end
FurC.getRolisSource = getRolisSource
local function getLuxurySource(recipeKey, recipeArray, stripColor)
recipeArray = recipeArray or FurC.Find(recipeKey)
if not recipeArray then return end
local versionData = FurC.LuxuryFurnisher[recipeArray.version]
if not versionData then return GetString(SI_FURC_STRING_FETCHER) end
local itemData = versionData[recipeKey]
if nil ~= itemData then
local weekendString = (nil == itemData.itemDate and "") or zo_strformat(GetString(SI_FURC_STRING_WEEKEND_AROUND), itemData.itemDate)
return zo_strformat(
GetString(SI_FURC_STRING_WASSOLDBY),
colorise(GetString(SI_FURC_STRING_ASSHOLE), vendorColor, stripColor),
colorise(GetString(SI_FURC_STRING_HC), vendorColor, stripColor),
colorise(itemData.itemPrice, goldColor, stripColor),
weekendString
)
end
return GetString(SI_FURC_STRING_FETCHER)
end
FurC.getLuxurySource = getLuxurySource
local function getPvpSource(recipeKey, recipeArray, stripColor)
recipeArray = recipeArray or FurC.Find(recipeKey)
if not recipeArray then return end
local versionData = FurC.PVP[recipeArray.version]
if not versionData then return "getPvpSource: nil" end
for vendorName, vendorData in pairs(versionData) do
for locationName, locationData in pairs(vendorData) do
if nil ~= locationData[recipeKey] then
return zo_strformat(
GetString(SI_FURC_STRING_VENDOR),
colorise(vendorName, vendorColor, stripColor),
colorise(locationName, vendorColor, stripColor),
colorise(locationData[recipeKey].itemPrice, apColor, stripColor),
GetString(SI_FURC_STRING_AP)
)
end
end
end
return "getPvpSource"
end
FurC.getPvpSource = getPvpSource
local typeTable = "table"
local function getAchievementVendorSource(recipeKey, recipeArray, stripColor)
recipeArray = recipeArray or FurC.Find(recipeKey)
if not recipeArray then return end
local versionData = FurC.AchievementVendors[recipeArray.version]
if not versionData then
return zo_strformat("getAchievementVendorSource: failed version lookup for ID <<1>> [<<2>>]", recipeKey, recipeArray.version)
end
local databaseEntry
for zoneName, zoneData in pairs(versionData) do
for vendorName, vendorData in pairs(zoneData) do
databaseEntry = vendorData[recipeKey]
if nil ~= databaseEntry then
return zo_strformat(
GetString(SI_FURC_STRING_VENDOR),
colorise(vendorName, vendorColor, stripColor),
colorise(zoneName, vendorColor, stripColor),
colorise(databaseEntry.itemPrice, goldColor, stripColor),
makeAchievementLink(databaseEntry.achievement)
)
end
end
end
return zo_strformat("getAchievementVendorSource, found version data but no item data for <<1>> ", recipeKey)
end
FurC.getAchievementVendorSource = getAchievementVendorSource
local function getEventDropSource(recipeKey, recipeArray, stripColor)
recipeArray = recipeArray or FurC.Find(recipeKey)
if not recipeArray then return end
local versionData = FurC.EventItems[recipeArray.version]
local itemPriceString = "getEventDropSource: couldn't find " .. tostring(recipeKey)
if not versionData then
return itemPriceString
end
for versionNumber, versionData in pairs(FurC.EventItems) do
for eventName, eventData in pairs(versionData) do
for eventItemSource, eventSourceData in pairs(eventData) do
if eventSourceData[recipeKey] then
itemPriceString = zo_strformat(
GetString(SI_FURC_FESTIVAL_DROP),
colorise(eventName, vendorColor, stripColor),
colorise(eventItemSource, vendorColor, stripColor)
)
local additionalsource = tostring(eventSourceData[recipeKey]) or ""
if #additionalsource > 4 then
itemPriceString = itemPriceString .. "\n" .. additionalsource
end
return itemPriceString
end
end
end
end
return itemPriceString
end
FurC.getEventDropSource = getEventDropSource
function FurC.GetMiscItemSource(recipeKey, recipeArray, attachItemLink)
if not recipeArray or not recipeArray.version or not recipeArray.origin then return end
if recipeArray.origin == FURC_RUMOUR then
return FurC.getRumourSource(recipeKey, recipeArray)
end
local versionFiles = FurC.MiscItemSources[recipeArray.version]
if not versionFiles then return end
local originData = versionFiles[recipeArray.origin]
if nil == originData then return end
return (not attachItemLink and originData[recipeKey]) or string.format("%s: %s", FurC.GetItemLink(recipeKey), originData[recipeKey])
end
local function getRecipeSource(recipeKey, recipeArray)
if nil == recipeKey and nil == recipeArray then return end
if nil == FurC.RecipeSources then return end
if nil ~= FurC.RecipeSources[recipeKey] then return FurC.RecipeSources[recipeKey] end
recipeArray = recipeArray or FurC.Find(recipeKey)
recipeKey = recipeArray.blueprint or recipeKey
-- d(recipeKey)
return (recipeArray.origin == FURC_RUMOUR and FurC.getRumourSource(recipeKey, recipeArray))
or FurC.RecipeSources[recipeKey]
end
FurC.getRecipeSource = getRecipeSource
function FurC.getRumourSource(recipeKey, recipeArray)
return (recipeArray.blueprint and GetString(SI_FURC_RUMOUR_SOURCE_RECIPE)) or GetString(SI_FURC_RUMOUR_SOURCE_ITEM)
end
function FurC.GetCrafterList(itemLink, recipeArray)
if nil == recipeArray and nil == itemLink then return end
recipeArray = recipeArray or FurC.Find(itemLink)
if nil == recipeArray then
return zo_strformat("FurC.GetCrafterList called for a non-craftable")
end
if nil == recipeArray.characters or NonContiguousCount(recipeArray.characters) == 0 then
return GetString(SI_FURC_STRING_CANNOT_CRAFT)
end
local ret = GetString(SI_FURC_STRING_CRAFTABLE_BY)
for characterName, characterKnowledge in pairs(recipeArray.characters) do
ret = string.format("%s %s, ", ret, characterName)
end
return ret:sub(0, -3)
end