Module:表格/太空矿带
跳转到导航
跳转到搜索
可在Module:表格/太空矿带/doc创建此模块的帮助文档
-- Module:表格/太空地点
local p = {}
local fstr = mw.ustring.format -- shortcut for formattig a string
local getArgs = require('Dev:Arguments').getArgs
local tb = require([[Module:表格]])
local po = require([[Module:Po]]).po
local utils = require([[Module:Utils]])
local poiData = mw.loadData([[Module:Data/HarvestablePOI]])
function p._main(hType, aType)
local out = {}
-- 名称
local name = po("STRINGS.UI.SPACEDESTINATIONS.HARVESTABLE_POI." .. hType.id:upper() .. ".NAME")
table.insert(out, fstr("{{图|48|%s}} %s", name, name))
-- 资源
if hType.harvestableElements ~= nil then
local sumWeight = 0
for el, weight in pairs(hType.harvestableElements) do
sumWeight = sumWeight + weight
end
local elements = {}
for el, weight in pairs(hType.harvestableElements) do
local elName = po("STRINGS.ELEMENTS." .. el:upper() .. ".NAME")
local elPercent = weight / sumWeight * 100
table.insert(elements, fstr("<span style='white-space: nowrap'>{{物品|%s}} %s%%</span>", elName,
utils.float2str(elPercent, 2)))
end
local elItems = table.concat(elements, "<br/>")
table.insert(out, elItems)
else
table.insert(out, "")
end
-- 资源容量
table.insert(out, fstr("%s ↔ %s", utils.kg2str(hType.poiCapacityMin), utils.kg2str(hType.poiCapacityMax)))
-- 完全恢复时间
table.insert(out, fstr("%s ↔ %s", hType.poiRechargeMin / 600, hType.poiRechargeMax / 600))
-- 工艺品
if hType.canProvideArtifacts == true and aType ~= nil then
if aType.harvestableArtifactID ~= nil then
local artifactId = aType.harvestableArtifactID:gsub("^artifact_", "")
local artifactCode = "STRINGS.UI.SPACEARTIFACTS." .. artifactId:upper() .. ".NAME"
table.insert(out, fstr("{{物品|%s}}", po(artifactCode)))
else
table.insert(out, fstr("%s %s", "[[File:图标 工艺品.png|x24px|class=dark-invert]]", "[[工艺品]]"))
end
else
table.insert(out, "")
end
-- 描述
local desc = "STRINGS.UI.SPACEDESTINATIONS.HARVESTABLE_POI." .. hType.id:upper() .. ".DESC"
table.insert(out, po(desc))
-- DLC
if hType.dlcID ~= nil then
table.insert(out, utils.DLC_ICONS[hType.dlcID])
else
table.insert(out, "")
end
return out
end
-- test by: = p.main({})
function p.main(frame)
local args = getArgs(frame)
local infos = {}
for k, v in pairs(poiData) do
local hType = v.harvestablePOIType
if hType ~= nil then
local aType = v.artifactPOIType
local info = p._main(hType, aType)
table.insert(infos, info)
end
end
-- mw.logObject(infos)
return tb.table(infos, args)
end
return p