模块:Tbox:修订间差异
来自乐园数据管理室
无编辑摘要 |
areas全部转小写 |
||
| (未显示同一用户的4个中间版本) | |||
| 第19行: | 第19行: | ||
} | } | ||
) | ) | ||
local numString = "" | |||
if args["itm" .. i .. "Num"] ~= "1" then | |||
numString = " ×" .. args["itm" .. i .. "Num"] | |||
end | |||
mw.smw.set { | mw.smw.set { | ||
tboxPop = {tostring(itemTitle)}, | |||
tboxPopDisplay = {itemName .. numString}, | |||
tboxPopLinkDisplay = {"[[" .. itemTitle.fullText .. "|" .. itemTitle.text .. "]]" .. numString}, | |||
[tostring(itemTitle) .. "PopNum"] = {args["itm" .. i .. "Num"]} | [tostring(itemTitle) .. "PopNum"] = {args["itm" .. i .. "Num"]} | ||
} | } | ||
| 第34行: | 第41行: | ||
local fs = fsidMap[tonumber(fsid)] | local fs = fsidMap[tonumber(fsid)] | ||
local firstSkill = fs | local firstSkill = fs.FieldSkillID1 .. "Lv" .. fs.FieldSkillLevel1 | ||
local secondSkill | local secondSkill | ||
if fs | if fs.FieldSkillLevel2 == 0 then | ||
secondSkill = "-" | secondSkill = "-" | ||
else | else | ||
secondSkill = fs | secondSkill = fs.FieldSkillID2 .. "Lv" .. fs.FieldSkillLevel2 | ||
end | end | ||
| 第50行: | 第57行: | ||
| %s | | %s | ||
]], | ]], | ||
fs | fs.Name, | ||
firstSkill, | firstSkill, | ||
secondSkill | secondSkill | ||
| 第61行: | 第68行: | ||
end | end | ||
mw.smw.set { | mw.smw.set { | ||
FieldSkill = {firstSkill .. secondSkill} | |||
} | } | ||
end | end | ||
| 第81行: | 第88行: | ||
function p.popTable(frame) | function p.popTable(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local gmk_tbox = loadJson("Gmk/tbox") | |||
for i, v in ipairs(gmk_tbox) do | |||
if args.name == v.Name then | |||
local areas = {} | |||
for _, v in ipairs(v.areas) do | |||
table.insert(areas, mw.ustring.lower(v)) | |||
end | |||
local mapinfo = loadJson("Mapinfo/" .. areas[1]) | |||
mw.smw.set { | |||
PosX = v.PosX, | |||
PosY = v.PosY, | |||
PosZ = v.PosZ, | |||
Areas = areas, | |||
["地域"] = mapinfo.mapName, | |||
zoneDisplay = mapinfo.mapName .. "・" .. mapinfo.menuGroup | |||
} | |||
end | |||
end | |||
local goldRow | local goldRow | ||
if args | if args.goldMin == "0" then | ||
goldRow = "" | goldRow = "" | ||
elseif args | elseif args.goldMin == args.goldMax then | ||
goldRow = mw.ustring.format([[ | goldRow = mw.ustring.format([[ | ||
|- | |- | ||
! 金币 | ! 金币 | ||
| %s G | | %s G | ||
]], args | ]], args.goldMin) | ||
mw.smw.set { | mw.smw.set { | ||
gold = {args.goldMin} | |||
} | } | ||
else | else | ||
goldRow = | goldRow = mw.ustring.format([[ | ||
|- | |- | ||
! 金币 | ! 金币 | ||
| %s G | | %s G | ||
]], args | ]], args.goldMin .. " ~ " .. args.goldMax) | ||
mw.smw.set { | mw.smw.set { | ||
gold = {args.goldMin .. " ~ " .. args.goldMax} | |||
} | } | ||
end | end | ||
| 第129行: | 第154行: | ||
local output = "" | local output = "" | ||
output = output .. fsRow(args | output = output .. fsRow(args.FSID2) | ||
output = output .. fsRow(args | output = output .. fsRow(args.FSID) | ||
return #output > 0 and [[{| class="wikitable" | return #output > 0 and [[{| class="wikitable" | ||
2020年2月1日 (六) 23:21的最新版本
此模块的文档可以在模块:Tbox/doc创建
local p = {}
local getArgs = require("Module:Arguments").getArgs
local loadJson = require("Module:JSON").loadJson
local fsidMap = loadJson("FSID")
function itemList(args)
local items = {}
for i = 1, 6 do
if args["itm" .. i .. "ID"] then -- filter nil
local itemName = args["itm" .. i .. "ID"]
local itemTitle = getItemTitle(itemName)
local itemPage = "[[" .. tostring(itemTitle) .. "|" .. itemName .. "]]"
table.insert(
items,
{
itemPage,
args["itm" .. i .. "Num"]
}
)
local numString = ""
if args["itm" .. i .. "Num"] ~= "1" then
numString = " ×" .. args["itm" .. i .. "Num"]
end
mw.smw.set {
tboxPop = {tostring(itemTitle)},
tboxPopDisplay = {itemName .. numString},
tboxPopLinkDisplay = {"[[" .. itemTitle.fullText .. "|" .. itemTitle.text .. "]]" .. numString},
[tostring(itemTitle) .. "PopNum"] = {args["itm" .. i .. "Num"]}
}
end
end
return items
end
function fsRow(fsid)
local output = ""
if fsid then
local fs = fsidMap[tonumber(fsid)]
local firstSkill = fs.FieldSkillID1 .. "Lv" .. fs.FieldSkillLevel1
local secondSkill
if fs.FieldSkillLevel2 == 0 then
secondSkill = "-"
else
secondSkill = fs.FieldSkillID2 .. "Lv" .. fs.FieldSkillLevel2
end
output =
mw.ustring.format(
[[|-
| rowspan="2" | %s
| %s
|-
| %s
]],
fs.Name,
firstSkill,
secondSkill
)
if secondSkill == "-" then
secondSkill = ""
else
secondSkill = " + " .. secondSkill
end
mw.smw.set {
FieldSkill = {firstSkill .. secondSkill}
}
end
return output
end
function getItemTitle(itemName)
local itemTitle
if mw.title.new(itemName, "物品").exists then
itemTitle = mw.title.new(itemName, "物品")
elseif mw.title.new(itemName, "黄金之国物品").exists then
itemTitle = mw.title.new(itemName, "黄金之国物品")
else
itemTitle = mw.title.new(itemName, "物品")
end
return itemTitle
end
function p.popTable(frame)
local args = getArgs(frame)
local gmk_tbox = loadJson("Gmk/tbox")
for i, v in ipairs(gmk_tbox) do
if args.name == v.Name then
local areas = {}
for _, v in ipairs(v.areas) do
table.insert(areas, mw.ustring.lower(v))
end
local mapinfo = loadJson("Mapinfo/" .. areas[1])
mw.smw.set {
PosX = v.PosX,
PosY = v.PosY,
PosZ = v.PosZ,
Areas = areas,
["地域"] = mapinfo.mapName,
zoneDisplay = mapinfo.mapName .. "・" .. mapinfo.menuGroup
}
end
end
local goldRow
if args.goldMin == "0" then
goldRow = ""
elseif args.goldMin == args.goldMax then
goldRow = mw.ustring.format([[
|-
! 金币
| %s G
]], args.goldMin)
mw.smw.set {
gold = {args.goldMin}
}
else
goldRow = mw.ustring.format([[
|-
! 金币
| %s G
]], args.goldMin .. " ~ " .. args.goldMax)
mw.smw.set {
gold = {args.goldMin .. " ~ " .. args.goldMax}
}
end
local itemRow = ""
local itemPopList = itemList(args)
if #itemPopList > 0 then
local items = {}
for i, v in ipairs(itemPopList) do
table.insert(items, v[2] == "1" and v[1] or v[1] .. " ×" .. v[2])
end
itemRow = mw.ustring.format([[|-
! 物品
| %s
]], table.concat(items, "<br>"))
end
return [[{| class="wikitable"
! colspan="2" |宝箱内容
]] .. goldRow .. itemRow .. [[|}]]
end
function p.fsInfo(frame)
local args = getArgs(frame)
local output = ""
output = output .. fsRow(args.FSID2)
output = output .. fsRow(args.FSID)
return #output > 0 and [[{| class="wikitable"
! colspan="2" |所需场景技能
]] .. output .. "|}" or ""
end
function p.appearCondition(frame)
local args = getArgs(frame)
local output = ""
if args["出现条件"] then
output = mw.ustring.format([[{| class="wikitable"
! 出现条件
|-
| %s
|}
]], args["出现条件"])
end
return output
end
return p