◆少前百科是非盈利性、非官方的少女前线维基百科。
◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科
◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科
◆To foreigners,You can use twitter to contact us.
Icon Nyto Silver.png

模块:SquadTables

来自少前百科GFwiki
罗瓦讨论 | 贡献2024年5月4日 (六) 16:20的版本 (创建页面,内容为“local p = {} local args local root local tableTemplate = [[ {| class="stattable cpu-table" id="table" style="text-align:center; width:100%;" | rowspan="4" | <div sty…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

此模块的文档可以在模块: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