Module:碧蓝航线Equips
跳到导航
跳到搜索
-- Module:碧蓝航线Equips -- Made with ♥ by User:Leranjun -- This module implements {{tl|碧蓝航线装备links}}. -- Please refrain from invoking this module directly. local p = {} local getArgs = require("Module:Arguments").getArgs local DATA = mw.loadData("Module:碧蓝航线Equips/data") local COLORS = { [1] = "#999", [2] = "#999", [3] = "#33f", [4] = "#c3c", [5] = "#c90", [6] = "#f39" } local function throwError(message) return '[[Category:碧蓝航线需要修正装备链接的页面]]<strong class="error">错误:' .. message .. '</strong>' end function p.main(frame) return p._main(getArgs(frame)) end function p._main(args) local pre = args.outerprefix or "" local suf = args.outersuffix or "" local r = "" local i = 1 while (args[i]) do if (i ~= 1) then r = r .. " • " end r = r .. pre local t = mw.text.split(args[i], "T") if (not args.notech) and (#t < 2 or (not tonumber(t[#t]))) then r = r .. throwError('装备"' .. args[i] .. '"不包含tech值') else local tech = (not args.notech) and tonumber(t[#t]) -- Tech will be false if args.notech is true local beau = args.notech and args[i] or mw.ustring.gsub(args[i], "T%d-$", "") -- Beautified name (w/o tech) if (not DATA[beau]) then r = r .. throwError('装备"' .. args[i] .. '"不存在') elseif (tech and (not DATA[beau][tech])) then r = r .. throwError('装备"' .. beau .. '"的tech值' .. tech .. "不存在") else local link = args["link" .. args[i]] or DATA[beau].link or beau local rare = DATA[beau][tech] or -1 if (args.notech) then for k, v in pairs(DATA[beau]) do if (tonumber(k)) then rare = math.max(rare, v) -- Use max rarity from table end end end r = r .. "[[碧蓝航线:" .. link .. '|<span style="color:' .. COLORS[rare] .. ';">' .. (args.notech and beau or args[i]) .. "</span>]]" end r = r .. suf end i = i + 1 end return r end return p