>OmegaK2 |
|
(44 intermediate revisions by 4 users not shown) |
Line 1: |
Line 1: |
| local p = {}
| | -- This is not an actual module. Do not add code. |
| local g_frame
| |
| local getArgs = require('Module:Arguments').getArgs
| |
| | |
| -- local quest_data = mw.loadData('Module:QuestReward/data') | |
| local quest_data = require('Module:QuestReward/data')
| |
| | |
| local poe_classes = {'Marauder', 'Templar', 'Witch', 'Shadow', 'Ranger', 'Duelist', 'Scion'}
| |
| local poe_difficulties = {'Normal', 'Cruel', 'Merciless'}
| |
| local data_keys = {'reward', 'type', 'class', 'difficulty', 'quest', 'quest_id', 'act', 'itemlevel', 'rarity', 'sockets', 'page_link'}
| |
| local supported_compares = {'eq', 'neq', 'lt', 'gt', 'le', 'ge'}
| |
| | |
| function p.table(frame)
| |
| --if not getArgs then
| |
| -- getArgs = require('Module:Arguments').getArgs
| |
| --end
| |
| -- TODO: Remove
| |
| if frame == nil then
| |
| frame = mw.getCurrentFrame()
| |
| end
| |
|
| |
| local args = getArgs(frame, {
| |
| parentFirst = true
| |
| })
| |
| g_frame = frame
| |
|
| |
| args.filter_by_difficulty = args.filter_by_difficulty or 1
| |
| --args.filter_by_act = args.filter_by_act or 1
| |
| --args.filter_by_quest_id = args.quest_id or 1
| |
| args.display_style = args.display_style or args.displayStyle or args.DisplayStyle or 'full'
| |
|
| |
| args.order_by_difficulty = args.order_by_difficulty or 'le'
| |
| args.order_by_act = args.order_by_act or 'le'
| |
| args.order_by_quest_id = args.order_by_quest_id or 'le'
| |
|
| |
| local out = ''
| |
|
| |
| if args.order_priority == nil then
| |
| args.order_priority = {'difficulty', 'act', 'quest_id'}
| |
| else
| |
| local temp = split(args.order_priority)
| |
| local out = {}
| |
| for _, key1 in ipairs(temp) do
| |
| if in_array(data_keys, key1) then
| |
| table.insert(out, key1)
| |
| else
| |
| error("Invalid key in order priority" .. key1)
| |
| end
| |
| end
| |
| args.order_priority = out
| |
| end
| |
|
| |
| local filter_keys = {}
| |
| local search_keys = {}
| |
|
| |
| for _, key in ipairs(data_keys) do
| |
| out = out .. ' ' .. (args['filter_by_' .. key])
| |
| if args['filter_by_' .. key] ~= nil then
| |
| filter_keys[key] = args['filter_by_' .. key]
| |
| end
| |
| if args['order_by_' .. key] ~= nil then
| |
| comp = args['order_by_' .. key]
| |
| if in_array(supported_compares, comp) then
| |
| table.insert(search_keys, {key=key, cmp=comp})
| |
| else
| |
| error("Invalid compare: " .. comp)
| |
| end
| |
| end
| |
| end
| |
|
| |
| return out
| |
| end
| |
|
| |
| function in_array(array, key)
| |
| for _, v in ipairs(array) do
| |
| if v == key then return true end
| |
| end
| |
| return false
| |
| end
| |
|
| |
| return p
| |