欢迎大家来到沙石镇时光中文维基!本站编辑权限开放,欢迎加入中文维基 QQ 群「沙海时光」:372816689
目前正在进行全站数据更新,期间可能会存在显示异常的问题。
全站通知:
模块:Refiner
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:Refiner/doc创建
local Helper = require("Module:Helper")
local AttrGrowth = Helper.LazyLoad("Module:AssetItemAttrGrowthDataAttrGrowth")
local Equipment = Helper.LoadAsset("Module:AssetEquipmentProtoEquipment")
local ItemPrototype = Helper.LazyLoad("Module:AssetItemPrototypeItem")
local Machine = Helper.LazyLoad("Module:AssetMachineConfigMachine")
local Refine = Helper.LazyLoad("Module:AssetRefineConfigRefine")
local ItemHelper = require("Module:ItemHelper")
local KEY_PREFIX = "Module:Refiner"
local EXP_TIME = 172800
local cache = require "mw.ext.LuaCache"
local tagToType = {
[0] = "assembly",
["Creation"] = "assembly",
[1] = "tool",
["Equipment"] = "tool",
[2] = "Consumables",
["Food"] = "Consumables",
[3] = "furniture",
["Furniture"] = "furniture",
[4] = "material",
["Material"] = "material",
[5] = "material",
["HiddenHandBook"] = "material",
[6] = "Refine",
["Refine"] = "Refine",
[7] = "MachinePlugin",
["MachinePlugin"] = "MachinePlugin",
[8] = "Weapon",
["Weapon"] = "Weapon",
[9] = "Seasoning",
["Seasoning"] = "Seasoning",
[10] = "Ingredient",
["Ingredient"] = "Ingredient",
[11] = "ExperimentCore",
["ExperimentCore"] = "ExperimentCore",
[12] = "Max",
["Max"] = "Max"
}
local p = {}
p.TableContent = function(frame)
local template = frame.args.row
local itemType = frame.args.type
local cacheKey = KEY_PREFIX .. "|TableContent|" .. template .. "|" .. itemType
local result = cache.get(cacheKey)
if (result) then
return result
end
local rowArgs = {}
for _, refine in pairs(Refine) do
if ItemHelper.isImplemented(refine.id) then
if detectItemType(refine.id) == itemType then
local args = {
item_id = refine.id,
item = ItemHelper.addIconAndLink(refine.id),
type = itemType,
material = ItemHelper.addIconAndLink(refine.matsGradeUp[1].id),
quality_up = refine.matsGradeUp[1].count,
level_up = refine.matsLevelUp[1].count
}
if AttrGrowth[refine.id] ~= nil then
args.item_level = AttrGrowth[refine.id].itemLevel
args.max_item_level = args.item_level + refine.maxRefineLevel
end
table.insert(rowArgs, args)
end
end
end
table.sort(rowArgs, function(a, b)
local keyA = ItemPrototype[a.item_id].orderIndex
local keyB = ItemPrototype[b.item_id].orderIndex
if keyA ~= keyB then
return keyA < keyB
end
return a.item_id < b.item_id
end)
local rows = Helper.Map(rowArgs, function(args)
return Helper.ExpandTemplate(template, args)
end)
result = table.concat(rows, "\n|-\n")
cache.set(cacheKey, result, EXP_TIME)
return result
end
function detectItemType(itemId)
if Equipment[itemId] ~= nil then
if Equipment[itemId].equipPart == 16 then
return "accessory"
else
return "clothing"
end
end
if Machine[itemId] ~= nil then
return "station"
end
local tag = ItemPrototype[itemId].tags[1]
if tagToType[tag] == nil then
error("Cannot detect item type: " .. itemId)
end
return tagToType[tag]
end
p.debug = function()
Helper.ExpandTemplate = Helper.ExpandTemplateDebug
local args = {
row = "R",
type = "tool"
}
local frame = {
args = args
}
local r = p.TableContent(frame)
mw.log(r)
end
return p

沪公网安备 31011002002714 号