-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiltering.lua
More file actions
67 lines (49 loc) · 2.37 KB
/
filtering.lua
File metadata and controls
67 lines (49 loc) · 2.37 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require "lib/lib_Tabs"
require "./lib/lib_SimpleDialog";
Filtering = {}
-- Previously LootFiltering()
function Filtering.Filter(loot, moduleOptions)
-- Vars
local categoryKey = nil
local rarityKey = nil
moduleOptions = moduleOptions['Filtering'] -- Note: this is gonna bite me in the ass someday
-- Determine keys
categoryKey, rarityKey = Filtering.GetFilteringOptionsKeys(loot, moduleOptions)
-- Verify that type passes filter
if moduleOptions[categoryKey]['Enabled'] then
-- Verify that rarity passes filter
-- Simple Mode: Rarity of Loot must be at or above Rarity Threshold
if (rarityKey == 'Simple' and Loot.GetRarityIndex(loot:GetRarity()) >= Loot.GetRarityIndex(moduleOptions[categoryKey][rarityKey]['RarityThreshold']))
-- Advanced Mode: The specific Rarity of the Loot must be Enabled
or (rarityKey ~= 'Simple' and moduleOptions[categoryKey][rarityKey]['Enabled']) then
-- Determine ItemLevel Threshold
local itemLevelThreshold = tonumber(moduleOptions[categoryKey][rarityKey]['ItemLevelThreshold'])
-- Determine RequiredLevel Threshold
local requiredLevelThreshold = tonumber(moduleOptions[categoryKey][rarityKey]['RequiredLevelThreshold'])
-- Verify that loot passes level thresholds
if loot:GetItemLevel() >= itemLevelThreshold and loot:GetRequiredLevel() >= requiredLevelThreshold then
-- Passed all filters
return true
end
end
elseif not moduleOptions[categoryKey] then
Debug.Table('LootFiltering for ' .. loot:ToString() .. ' ran aground because there weren\'t any options for its categoryKey ' .. tostring(categoryKey) .. ' in the module options that were provided (no name to log here, so dumping table.): ', moduleOptions)
end
return false
end
-- Previously Filtering.GetFilteringOptionsKeys()
function Filtering.GetFilteringOptionsKeys(loot, moduleOptions)
-- Vars
local categoryKey = nil
local rarityKey = nil
-- Determine typeKey
categoryKey = loot:GetCategory()
-- Determine rarityKey
if moduleOptions[categoryKey]['Mode'] == TriggerModeOptions.Simple then
rarityKey = 'Simple'
else -- TriggerModeOptions.Advanced
rarityKey = loot:GetRarity()
end
-- Return
return categoryKey, rarityKey
end