◆少前百科是非盈利性、非官方的少女前线维基百科。 ◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科。 ◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科 ◆To foreigners,You can use twitter to contact us. |
“模块:SquadTables”的版本间的差异
(未显示同一用户的13个中间版本) | |||
第2行: | 第2行: | ||
local args | local args | ||
local root | local root | ||
+ | local chipTable | ||
+ | local advanceTable | ||
local attris = {'杀伤', '破防', '精度', '装填'} | local attris = {'杀伤', '破防', '精度', '装填'} | ||
+ | local chips = {} | ||
+ | local advances = {} | ||
+ | |||
+ | local function addSumTable() | ||
+ | local sumTable = root:tag('table'):addClass('stattable attr-sum-table') | ||
+ | sumTable:tag('tr') | ||
+ | :tag('th'):addClass('gflabelbg'):attr('colspan', 5):wikitext('面板数值') | ||
+ | local thead = sumTable:tag('tr') | ||
+ | thead:tag('td'):wikitext('属性') | ||
+ | thead:tag('td'):wikitext('基础数值') | ||
+ | thead:tag('td'):wikitext('芯片加成') | ||
+ | thead:tag('td'):wikitext('迭代上限') | ||
+ | thead:tag('td'):wikitext('最大数值') | ||
+ | for i = 1, 4 do | ||
+ | local attriRow = sumTable:tag('tr') | ||
+ | local attri = attris[i] | ||
+ | local baseAttri = args['基础' .. attri] | ||
+ | attriRow:tag('td'):wikitext(attri) | ||
+ | attriRow:tag('td'):wikitext(baseAttri) | ||
+ | attriRow:tag('td'):wikitext(chips[i]) | ||
+ | attriRow:tag('td'):wikitext(advances[i]) | ||
+ | attriRow:tag('td'):wikitext(baseAttri + chips[i] + advances[i]) | ||
+ | end | ||
+ | end | ||
+ | |||
+ | 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 '') | ||
+ | advances[a] = advances[a] + (attri or 0) | ||
+ | end | ||
+ | end | ||
+ | |||
+ | local function addAdvanceTable() | ||
+ | advanceTable = root:tag('table'):addClass('stattable advance-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]) | ||
+ | advances[i] = 0 | ||
+ | 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 function addChipAttri(i) | ||
− | local chipRow = | + | local chipRow = chipTable:tag('tr'):attr('id', string.format('chip-%s-%d', string.lower(args['代号']), i)) |
local chipNum = '芯片' .. tostring(i) | local chipNum = '芯片' .. tostring(i) | ||
chipRow:tag('td'):wikitext(chipNum) | chipRow:tag('td'):wikitext(chipNum) | ||
第12行: | 第74行: | ||
local attri = tonumber(args[chipNum .. attris[a]]) | local attri = tonumber(args[chipNum .. attris[a]]) | ||
if attri ~= nil then | if attri ~= nil then | ||
− | attriCell:tag('span'):wikitext( | + | attriCell:tag('span'):wikitext(round(0.6*attri)) |
attriCell:tag('span'):wikitext(attri) | attriCell:tag('span'):wikitext(attri) | ||
− | attriCell:tag('span'):wikitext( | + | local maxValue = round(2.5*attri) |
+ | attriCell:tag('span'):wikitext(maxValue) | ||
+ | chips[a] = chips[a] + maxValue | ||
end | end | ||
end | end | ||
end | end | ||
− | local function | + | local function addChipTable() |
− | local | + | local cpuTable = root:tag('table'):addClass('stattable cpu-table') |
− | + | cpuTable:tag('tr') | |
− | + | :tag('th'):addClass('gflabelbg'):attr('colspan', 5):wikitext('芯片') | |
− | + | local cpuRow = cpuTable:tag('tr') | |
− | + | cpuRow:tag('td'):addClass('cpu-cell'):attr('rowspan', 4) | |
− | + | :tag('div'):addClass('cpu-center'):wikitext(args['芯片5']) | |
− | + | local row = cpuRow | |
− | + | local sums = {} | |
− | |||
− | |||
− | |||
− | |||
− | local | ||
− | |||
− | local row = | ||
for i = 1, 4 do | for i = 1, 4 do | ||
row:tag('td'):wikitext(attris[i]) | row:tag('td'):wikitext(attris[i]) | ||
− | row:tag('td'):attr('colspan', | + | chips[i] = 0 |
− | + | sums[i] = row:tag('td'):attr('colspan', 2) | |
+ | if i < 4 then | ||
+ | row = cpuTable:tag('tr') | ||
+ | end | ||
end | end | ||
+ | chipTable = root:tag('table'):addClass('stattable chip-table') | ||
+ | row = chipTable:tag('tr') | ||
row:tag('th'):wikitext('芯片') | row:tag('th'):wikitext('芯片') | ||
+ | for i = 1, 10 do | ||
+ | addChipAttri(i) | ||
+ | end | ||
for i = 1, 4 do | for i = 1, 4 do | ||
row:tag('th'):wikitext(attris[i]) | row:tag('th'):wikitext(attris[i]) | ||
+ | sums[i]:wikitext(chips[i]) | ||
end | end | ||
− | + | end | |
− | + | ||
− | + | function p.main(frame) | |
+ | args = frame:getParent().args | ||
+ | root = mw.html.create() | ||
+ | addChipTable() | ||
+ | addAdvanceTable() | ||
+ | addSumTable() | ||
return tostring(root) | return tostring(root) | ||
end | end | ||
return p | return p |
2024年5月5日 (日) 12:09的最新版本
此模块的文档可以在模块:SquadTables/doc创建
local p = {} local args local root local chipTable local advanceTable local attris = {'杀伤', '破防', '精度', '装填'} local chips = {} local advances = {} local function addSumTable() local sumTable = root:tag('table'):addClass('stattable attr-sum-table') sumTable:tag('tr') :tag('th'):addClass('gflabelbg'):attr('colspan', 5):wikitext('面板数值') local thead = sumTable:tag('tr') thead:tag('td'):wikitext('属性') thead:tag('td'):wikitext('基础数值') thead:tag('td'):wikitext('芯片加成') thead:tag('td'):wikitext('迭代上限') thead:tag('td'):wikitext('最大数值') for i = 1, 4 do local attriRow = sumTable:tag('tr') local attri = attris[i] local baseAttri = args['基础' .. attri] attriRow:tag('td'):wikitext(attri) attriRow:tag('td'):wikitext(baseAttri) attriRow:tag('td'):wikitext(chips[i]) attriRow:tag('td'):wikitext(advances[i]) attriRow:tag('td'):wikitext(baseAttri + chips[i] + advances[i]) end end 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 '') advances[a] = advances[a] + (attri or 0) end end local function addAdvanceTable() advanceTable = root:tag('table'):addClass('stattable advance-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]) advances[i] = 0 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'):attr('id', string.format('chip-%s-%d', string.lower(args['代号']), i)) 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) local maxValue = round(2.5*attri) attriCell:tag('span'):wikitext(maxValue) chips[a] = chips[a] + maxValue end end end local function addChipTable() local cpuTable = root:tag('table'):addClass('stattable cpu-table') cpuTable:tag('tr') :tag('th'):addClass('gflabelbg'):attr('colspan', 5):wikitext('芯片') local cpuRow = cpuTable:tag('tr') cpuRow:tag('td'):addClass('cpu-cell'):attr('rowspan', 4) :tag('div'):addClass('cpu-center'):wikitext(args['芯片5']) local row = cpuRow local sums = {} for i = 1, 4 do row:tag('td'):wikitext(attris[i]) chips[i] = 0 sums[i] = row:tag('td'):attr('colspan', 2) if i < 4 then row = cpuTable:tag('tr') end end chipTable = root:tag('table'):addClass('stattable chip-table') row = chipTable:tag('tr') row:tag('th'):wikitext('芯片') for i = 1, 10 do addChipAttri(i) end for i = 1, 4 do row:tag('th'):wikitext(attris[i]) sums[i]:wikitext(chips[i]) end end function p.main(frame) args = frame:getParent().args root = mw.html.create() addChipTable() addAdvanceTable() addSumTable() return tostring(root) end return p