缺氧 wiki 编辑团队提示:注册账号并登录后体验更佳,且可通过参数设置定制优化您的浏览体验!
该站点为镜像站点,如果你想帮助这个由玩家志愿编辑的 wiki 站点,请前往原站点参与编辑,
同时欢迎加入编辑讨论群 851803695 与其他编辑者一起参与建设!
全站通知:
模块:技术信息框
刷
历
编
跳到导航
跳到搜索
local p = {}
local fstr = mw.ustring.format
local utils = require("Module:Utils")
local po = require([[Module:Po]]).po
local i18ncr = require([[Module:I18n]]).loadMessages([[Module:I18n/Research]])
local infobox = require([[Module:信息框/技术]])
local getArgs = require("Module:Dev/Arguments").getArgs
local fDataPath = [[Module:Data/Techs]]
local fData = mw.loadData(fDataPath)
local DLCS = utils.DLCS
local exception = {
}
local function containDlc(dlcIds, dlc)
for _, v in ipairs(dlcIds) do
if dlc == v then
return true
end
end
end
function p._main(techData, techCode, dlc)
local out = {}
out["ID"] = fstr("<code>%s</code>", techData.Id)
out["名称"] = po(techCode)
out["图片说明"] = po(techCode:sub(1, -6) .. ".DESC")
if techData.unlockedItems ~= nil then
local frame = mw.getCurrentFrame()
out["图片"] = {}
for _, unlockItem in ipairs(techData.unlockedItems) do
if containDlc(unlockItem.dlcIds, dlc) then
local photo = po("STRINGS.BUILDINGS.PREFABS."..unlockItem.Id:upper()..".NAME")
table.insert(out['图片'], tostring(frame:expandTemplate{ title = '图', args = {'64x64px', photo}}))
end
end
out['图片'] = #out["图片"] ~= 0 and table.concat(out["图片"]) or nil
end
if techData.category ~= nil then
out["类型"] = po("STRINGS.RESEARCH.TREES.TITLE"..techData.category:upper())
end
if techData.tier ~= nil then
out["等级"] = utils.float2str(techData.tier)
end
if techData.costsByResearchTypeID ~= nil then
local costs = techData.costsByResearchTypeID
if costs.basic ~= nil then
out["基础研究"] = utils.float2str(costs.basic)
end
if costs.advanced ~= nil then
out["高级研究"] = utils.float2str(costs.advanced)
end
if costs.nuclear ~= nil then
out["应用科学研究"] = utils.float2str(costs.nuclear)
end
if costs.orbital ~= nil then
out["星际研究"] = utils.float2str(costs.orbital)
elseif costs.space ~= nil then
out["星际研究"] = utils.float2str(costs.space)
end
end
if techData.requiredTechIDs ~= nil then
out["前置技术"] = {}
for _, preTech in ipairs(techData.requiredTechIDs) do
table.insert(out["前置技术"], fstr("[[技术/%s]]", po("STRINGS.RESEARCH.TECHS."..preTech:upper()..".NAME")))
end
out['前置技术'] = #out["前置技术"] ~= 0 and table.concat(out["前置技术"], "<br/>") or nil
end
if techData.unlockedTechIDs ~= nil then
out["可解锁技术"] = {}
for _, unlockTech in ipairs(techData.unlockedTechIDs) do
table.insert(out["可解锁技术"], fstr("[[技术/%s]]", po("STRINGS.RESEARCH.TECHS."..unlockTech:upper()..".NAME")))
end
out['可解锁技术'] = #out["可解锁技术"] ~= 0 and table.concat(out["可解锁技术"], "<br/>") or nil
end
return out
end
-- test by: = p.main(require("Module:debug").frame({},{debug=1, pagename="技术/基础耕种"}))
-- test by: = p.main(require("Module:debug").frame({},{debug=1, pagename="技术/敏感微成像"}))
-- test by: = p.main(require("Module:debug").frame({},{debug=1, pagename="技术/超热锻造"}))
function p.main(frame)
local args = getArgs(frame)
local infos = {}
local techs = {}
if args[1] ~= nil or args.multipage ~= nil then
local pagename_array = {}
pagename_array = args[1] ~= nil and {args[1]} or nil
if pagename_array == nil then
pagename_array = args.multipage ~= nil and mw.text.split(args.multipage, ",") or {}
end
for _, techId in ipairs(pagename_array) do
local _, _, techCode = utils.getEntry(techId)
if techCode == nil then
return {
["名称"] = fstr("找不到技术 '%s',请使用参数1或检查 [[%s]]。", techId, fDataPath)
}
end
table.insert(techs, {
id = techId,
code = techCode
})
end
else
args.pagename = args.pagename:gsub("技术/", "")
local techCode = i18ncr:msgRev({
key = args.pagename,
args = {
prefix = "STRINGS.RESEARCH.TECHS."
}
} or "")
if techCode == nil then
return {
["名称"] = fstr("找不到技术 '%s',请使用参数1或检查 [[%s]]。", args.pagename,
fDataPath)
}
end
local techId = techCode:match("([%u_]+).NAME$")
table.insert(techs, {
id = techId,
code = techCode
})
end
for _, tech in pairs(techs) do
tech.id = exception[tech.id] ~= nil and exception[tech.id] or tech.id
for k, pack in pairs(fData) do
for dlc, v in pairs(pack) do
if k:upper() == tech.id:upper() then
local curr = p._main(v, tech.code, dlc)
table.insert(infos, {
label = po(DLCS[dlc] or ""),
data = curr
})
end
end
end
end
if args.debug then
mw.logObject(infos)
end
return infobox.main(args.pagename, infos)
end
return p