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

模块:Sangvis info/index

来自少前百科GFwiki
跳转至: 导航搜索

此模块的文档可以在模块:Sangvis info/index/doc创建

local p = {}
local root
local data = mw.loadData('Module:Sangvis info/data')
local edata = mw.loadData('Module:Enemy info/data')
local forces = {'铁血工造', '正规军', '帕拉蒂斯', '其他势力'}
local chartype = {'有甲', '无甲', '机械', '人形', '近战', '远程'}
local type_coef = {
	{4.79, 3.67, 0.46, 0.55, 0.75, 0.18},
	{3.84, 2.94, 0.42, 0.44, 0.60, 0.15},
	{3.60, 2.76, 0.42, 0.42, 0.57, 0.14}}

local function calcGroup(attr, utype, ratio, grow, res)
	local form = attr == 2 and 1 or 5
	local base = type_coef[utype][attr] * ratio * grow * 6 * form / 6.25e3
	local accretion = type_coef[utype][attr] * ratio * 297 * grow * form / 1.25e5
	return math.ceil(base + accretion) + (attr == 1 and form or 1)*res
end

local function calcSole(attr, utype, ratio, grow, res)
	local base = type_coef[utype][attr] * ratio * grow * 3 / 6.25e2
	local accretion = type_coef[utype][attr] * ratio * 297 * grow / 2.5e4
	return math.ceil(base + accretion) + res
end

local function createDataRow(unitdata)
	local attrs = unitdata.attrs
	local utype = unitdata['type']
	local url = unitdata.name .. '/协议同归' 
	if utype == 1 and not edata[unitdata.illu_id].skills then url = unitdata.name end
	local row = mw.html.create('div'):addClass('sfdata'):cssText('display:all'):attr{
		['data-id'] = unitdata.illu_id,
		['data-avatar'] = mw.getCurrentFrame():callParserFunction('filepath',
			'Icon_fusion_' .. unitdata.illu_id .. '.png'),
		['data-name-ingame'] = unitdata.name,
		['data-url'] = '/w/' .. mw.uri.encode(url, 'WIKI'),
		['data-from'] = forces[unitdata.force],
		['data-class'] = utype == 1 and 'BOSS单位' or '常规单位',
		['data-star'] = 4 - utype,
		['data-sf-ampierce'] = attrs[7],
		['data-sf-criper'] = tostring(attrs[8]) .. '%',
		['data-sf-crirate'] = tostring(attrs[9]) .. '%',
		['data-sf-move'] = attrs[10],
		['data-cost'] = unitdata.cost,
		['data-tag1'] = chartype[unitdata['char'][1]],
		['data-tag2'] = chartype[unitdata['char'][2]],
		['data-tag3'] = chartype[unitdata['char'][3]]
	}
	local maxform = 5
	local id = unitdata.id
	if id < 2000 or id == 2006 or id == 3010 then maxform = 1 end
	local calcAttr = maxform == 5 and calcGroup or calcSole
	local res = mw.text.split(
		mw.text.split(unitdata.resolution, ';', true)[6-maxform], ',', true)
	local grow = unitdata.grow
	row:attr{
		['data-sf-life'] = calcAttr(1, utype, attrs[1], grow, res[1]),
		['data-sf-atk'] = calcAttr(2, utype, attrs[2], grow, res[2]),
		['data-sf-rate'] = calcAttr(3, utype, attrs[3], grow, res[3]),
		['data-sf-acc'] = calcAttr(4, utype, attrs[4], grow, res[4]),
		['data-sf-dodge'] = calcAttr(5, utype, attrs[5], grow, res[5]),
		['data-sf-armor'] = calcAttr(6, utype, attrs[6], grow, res[6])
	}
	return tostring(row)
end

function p.sangvisIndex(frame)
	assert(mw.title.new('纱那/协议同归').exists)
	root = mw.html.create()
	for typeid = 1, 3 do
		for id = 1, 999 do
			local unitid = typeid*1000 + id
			local unitdata = data[unitid]
			if unitdata then
				root:wikitext(createDataRow(unitdata))
			elseif unitid ~= 2007 then break end
		end
	end
	return tostring(root)
end

return p