◆少前百科是非盈利性、非官方的少女前线维基百科。 ◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科。 ◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科 ◆To foreigners,You can use twitter to contact us. |
“模块:SquadTables”的版本间的差异
第74行: | 第74行: | ||
row:tag('td'):wikitext(attris[i]) | row:tag('td'):wikitext(attris[i]) | ||
row:tag('td'):attr('colspan', 3):wikitext(sumAttri(i)) | row:tag('td'):attr('colspan', 3):wikitext(sumAttri(i)) | ||
− | row = | + | row = chipTable:tag('tr') |
end | end | ||
row:tag('th'):wikitext('芯片') | row:tag('th'):wikitext('芯片') |
2024年5月4日 (六) 17:51的版本
此模块的文档可以在模块:SquadTables/doc创建
local p = {} local args local root local chipTable local advanceTable local sumTable local attris = {'杀伤', '破防', '精度', '装填'} local sums = {} local function addAdvanceAttri(i) local advanceRow = advanceTable:tag('tr') advanceRow:tag('td'):wikitext('LV.', i) local starCell = advanceRow:tag('td') local q = math.floor(i / 2) local r = i % 2 local span = starCell:tag('span'):addClass('orange-star') span:wikitext(mw.ustring.rep('★', q), mw.ustring.rep('☆', r)) starCell:tag('span'):wikitext(mw.ustring.rep('★', 5 - q - r)) for a = 1, 4 do local attri = tonumber(args['迭代' .. tostring(i) .. attris[a]]) advanceRow:tag('td'):wikitext(attri or '') end end local function addAdvanceTable() advanceTable = root:tag('table') advanceTable:tag('tr'):tag('th'):addClass('gflabelbg'):attr('colspan', 6):wikitext('迭代') local thead = advanceTable:tag('tr') thead:tag('td'):wikitext('对应等级') thead:tag('td'):wikitext('星级') for i = 1, 4 do thead:tag('td'):wikitext(attris[i]) end for i = 1, 10 do addAdvanceAttri(i) end end local function round(n) return math.floor(n + 0.5) end local function addChipAttri(i) local chipRow = chipTable:tag('tr') local chipNum = '芯片' .. tostring(i) chipRow:tag('td'):wikitext(chipNum) for a = 1, 4 do local attriCell = chipRow:tag('td') local attri = tonumber(args[chipNum .. attris[a]]) if attri ~= nil then attriCell:tag('span'):wikitext(round(0.6*attri)) attriCell:tag('span'):wikitext(attri) attriCell:tag('span'):wikitext(round(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 round(2.5*sum) end local function addChipTable() chipTable = root:tag('table'):addClass('stattable chip-table') chipTable:tag('tr'):tag('th'):addClass('gflabelbg'):attr('colspan', 5):wikitext('芯片') local firstRow = chipTable: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 = chipTable:tag('tr') end row:tag('th'):wikitext('芯片') for i = 1, 4 do row:tag('th'):wikitext(attris[i]) end for i = 1, 10 do addChipAttri(i) end end function p.main(frame) args = frame:getParent().args root = mw.html.create() addChipTable() addAdvanceTable() --addSumTable() return tostring(root) end return p