模块:Shop
来自蒙纳多研究本部
此模块的文档可以在模块:Shop/doc创建
local p = {}
local post = require("Module:RequestHelper").post
local getArgs = require("Module:Arguments").getArgs
local html = require("Module:Html")
local compress = html.compress
local addlink = html.addlink
local function slot(data)
if data.itemID.uni_flag == 0 then
return "[" .. data.itemID.jwl_slot .. "]"
end
return ""
end
function p.trialShop()
local data = post("bdat_trial.trial_shop")
local result = {}
for _, row in ipairs(data) do
if row.mflg == 0 and row.item.itemType ~= "宝珠" then
local resultRow = {}
resultRow.name = addlink(row.item.itemID.name, "物品") .. slot(row.item)
resultRow.price = row.price
resultRow.itemType = row.item.itemType
table.insert(result, resultRow)
mw.smw.set {item = row.item.itemID.name .. slot(row.item)}
end
end
mw.smw.set {id = 0}
return compress(
html.wikitable(
{{label = "名称", scope = "name"}, {label = "类型", scope = "itemType"}, {label = "诺彭水晶", scope = "price"}},
result,
{class = "xbtable"}
)
)
end
function p.shop(frame)
local id = frame.args[1]
local data = post("bdat_common.shoplist", id)
local out = ""
local result = {}
for _, t in ipairs({"wpn", "head", "body", "arm", "waist", "legg", "arts"}) do
for i = 1, 12 do
local key = t .. i
if data[key] then
local resultRow = {}
resultRow.name = addlink(data[key].itemID.name, "物品") .. slot(data[key])
resultRow.price = data[key].itemID.money * 10
resultRow.itemType = data[key].itemType
table.insert(result, resultRow)
mw.smw.set {item = data[key].itemID.name .. slot(data[key])}
end
end
end
mw.smw.set {id = id}
return compress(
html.wikitable(
{{label = "名称", scope = "name"}, {label = "类型", scope = "itemType"}, {label = "价格", scope = "price"}},
result,
{class = "xbtable"}
)
)
end
return p