模块:SquadTables
此模块的文档可以在模块:SquadTables/doc创建
local p = {} local args local root local tableTemplate = [[ {| class="stattable cpu-table" id="table" style="text-align:center; width:100%;" | rowspan="4" | <div style="background-color:#222222;">%s</div> | 杀伤 | colspan="3" | %d |- | 破防 | colspan="3" | %d |- | 精度 | colspan="3" | %d |- | 装填 | colspan="3" | %d |- | 芯片 || 杀伤 || 破防 || 精度 || 装填 |- | 芯片1 || %s || %s || %s || %s |}]] local attris = {'杀伤', '破防', '精度', '装填'} local function addChipAttri(i) local chipRow = root:tag('tr') local chipNum = '芯片' .. tostring(i) chipRow:tag('td'):wikitext(chipNum) for a = 1, 4 do local attri = args[chipNum .. attris[a]] if attri ~= nil then local attriCell = chipRow:tag('td') attriCell:tag('span'):wikitext(math.ceil(0.6*attri)) attriCell:tag('span'):wikitext(attri) attriCell:tag('span'):wikitext(math.ceil(2.5*attri)) end end end local function sumAttri(i) local sum = 0 local attri = attris[i] for i = 1, 10 do sum = sum + tonumber(args['芯片' .. tostring(i) .. attri] or 0) end return math.ceil(2.5*sum) end function p.main(frame) args = frame:getParent().args root = mw.html.create('table'):addClass('chip-table') root:tag('tr'):tag('th'):addClass('gflabelbg'):attr('colspan', 5):wikitext('芯片') local firstRow = root:tag('tr') firstRow:tag('td'):attr('rowspan', 4):tag('div'):wikitext(args['芯片5']) local row = firstRow for i = 1, 4 do row:tag('td'):wikitext(attris[i]) row:tag('td'):attr('colspan', 3):wikitext(sumAttri(i)) row = root:tag('tr') end row:tag('td'):wikitext('芯片') for i = 1, 4 do row:tag('td'):wikitext(attris[i]) end for i = 1, 10 do addChipAttri(i) end return tostring(root) end return p