◆少前百科是非盈利性、非官方的少女前线维基百科。 ◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科。 ◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科 ◆To foreigners,You can use twitter to contact us. |
“模块:SquadTables”的版本间的差异
第1行: | 第1行: | ||
local p = {} | local p = {} | ||
local args | local args | ||
− | local | + | local chipTable |
+ | local advanceTable | ||
+ | local sumTable | ||
local attris = {'杀伤', '破防', '精度', '装填'} | 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) | local function round(n) | ||
第9行: | 第41行: | ||
local function addChipAttri(i) | local function addChipAttri(i) | ||
− | local chipRow = | + | local chipRow = chipTable:tag('tr') |
local chipNum = '芯片' .. tostring(i) | local chipNum = '芯片' .. tostring(i) | ||
chipRow:tag('td'):wikitext(chipNum) | chipRow:tag('td'):wikitext(chipNum) | ||
第32行: | 第64行: | ||
end | end | ||
− | function | + | 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') | |
− | local firstRow = | ||
firstRow:tag('td'):attr('rowspan', 4):tag('div'):wikitext(args['芯片5']) | firstRow:tag('td'):attr('rowspan', 4):tag('div'):wikitext(args['芯片5']) | ||
local row = firstRow | local row = firstRow | ||
第51行: | 第82行: | ||
addChipAttri(i) | addChipAttri(i) | ||
end | end | ||
+ | end | ||
+ | |||
+ | function p.main(frame) | ||
+ | args = frame:getParent().args | ||
+ | local root = mw.html.create() | ||
+ | addChipTable() | ||
+ | addAdvanceTable() | ||
+ | --addSumTable() | ||
return tostring(root) | return tostring(root) | ||
end | end | ||
return p | return p |
2024年5月4日 (六) 17:47的版本
此模块的文档可以在模块:SquadTables/doc创建
local p = {} local args 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 = root: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 local root = mw.html.create() addChipTable() addAdvanceTable() --addSumTable() return tostring(root) end return p