Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 78 additions & 1 deletion src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,82 @@ function ImportTabClass:DownloadItems()
end)
end

function ImportTabClass:ImportQuestRewardConfig(questStats)
local configTab = self.build.configTab
local statLines = {}
for _, stat in ipairs(questStats) do
t_insert(statLines, escapeGGGString(stat):lower())
end

local function splitLine(text)
local out = {}
for line in text:gmatch("[^\r\n]+") do
line = line:gsub("^%s+", ""):lower()
t_insert(out, line)
end
return out
end

-- Ensure all required lines exist, then remove them so they can't match again
local function matchQuest(requiredLines)
local indices = {}
for _, needed in ipairs(requiredLines) do
local found
for idx, line in ipairs(statLines) do
if line == needed then
found = idx
break
end
end
if not found then
return false
end
t_insert(indices, found)
end
table.sort(indices, function(a, b) return a > b end)
for _, idx in ipairs(indices) do
t_remove(statLines, idx)
end
return true
end

local updated = false
for _, quest in ipairs(data.questRewards) do
if #statLines == 0 then
break
end
if quest.useConfig == true then
local var = "quest" .. quest.Description .. quest.Area .. quest.Info
if quest.Stat then
local matches = matchQuest(splitLine(quest.Stat))
if configTab.input[var] ~= matches then
configTab.input[var] = matches
updated = true
end
elseif quest.Options then
local selected = configTab.defaultState[var] or "None"
for _, option in ipairs(quest.Options) do
if matchQuest(splitLine(option)) then
selected = option
break
end
end
if configTab.input[var] ~= selected then
configTab.input[var] = selected
updated = true
end
end
end
end

if updated then
configTab:BuildModList()
configTab:UpdateControls()
configTab.modFlag = true
self.build.buildFlag = true
end
end

function ImportTabClass:ImportPassiveTreeAndJewels(charData)
local charPassiveData = charData.passives
self.charImportStatus = colorCodes.POSITIVE.."Passive tree and jewels successfully imported."
Expand Down Expand Up @@ -639,6 +715,7 @@ function ImportTabClass:ImportPassiveTreeAndJewels(charData)
end

self.build.spec:AddUndoState()
self:ImportQuestRewardConfig(charPassiveData.quest_stats)
self.build.characterLevel = charData.level
self.build.characterLevelAutoMode = false
self.build.configTab:UpdateLevel()
Expand Down Expand Up @@ -1138,4 +1215,4 @@ function UrlDecode(url)
url = url:gsub("+", " ")
url = url:gsub("%%(%x%x)", HexToChar)
return url
end
end
Loading