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

“模块:Enemy info”的版本间的差异

来自少前百科GFwiki
跳转至: 导航搜索
第116行: 第116行:
 
function p.enemyIndex()
 
function p.enemyIndex()
 
local groupByForce = {}
 
local groupByForce = {}
for i in 0, 3 do groupByForce[i] = mw.html.create() end
+
for i = 0, 3 do groupByForce[i] = mw.html.create() end
 
for i, d in ipairs(data) do
 
for i, d in ipairs(data) do
 
if i ~= 100 then
 
if i ~= 100 then

2022年9月12日 (一) 17:53的版本

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

local p = {}
local args
local root
local uid
local udata
local node
local currentframe = mw.getCurrentFrame
local forces = {'铁血工造', '正规军', '帕拉蒂斯', [0] = '其他势力'}
local types = {'首领', '普通机械', '普通人形', '装甲机械', '装甲人形'}
local data = mw.loadData('模块:Enemy info/data')

local function addSpine()
	node:tag('div'):attr('id', 'spinebox'):addClass('spinebox'):css('min-width', args['LargeSpine'] and '900px' or '450px')
		:tag('p'):addClass('gflabelbg'):wikitext('Q版模型预览(点击切换动画)'):done()
		:tag('div'):attr{
			id = 'TDollChibiAnimation',
			['data-tdoll-id'] = udata.code,
			['data-tdoll-hidedormbutton'] = 'true'
		}:addClass('tdoll_chibi'):addClass(args['LargeSpine'] and 'bigScale' or 'gflabelbg1')
		:cssText(args['LargeSpine'] and 'height:1000px;min-width:900px' or 'height:380px;min-width:450px')
		:wikitext(' ')
end

local function addDesc()
	local chars = mw.loadData('模块:Enemy info/character data')
	for _,n in ipairs(udata.chars) do
		node:tag('tr'):tag('td'):attr('colspan', 2):wikitext(currentframe():expandTemplate{title='敌方图鉴TAG', args={chars[n][1], chars[n][2]}})
	end
	if udata.skills then
		local skills = mw.loadData('模块:Enemy info/skill data')
		for _,n in ipairs(udata.skills) do
			node:tag('tr'):tag('td'):attr('colspan', 2):wikitext(currentframe():expandTemplate{title='敌方图鉴技能', args={skills[n][1], skills[n][2]}})
		end
	end
	node:tag('tr'):tag('td'):attr('colspan', 2):wikitext(currentframe():expandTemplate{title='敌方图鉴文本内敛', args={udata.counter}})
	node = node:done()
end

local function addAttrs() 
	node = node:tag('table'):addClass('stattable'):addClass('integral-stattable')
	node:tag('tr'):tag('td'):attr('colspan', 2):addClass('gflabelbg'):wikitext('敌方图鉴信息')
	node:tag('tr'):tag('td'):wikitext('编号'):done():tag('td'):wikitext(uid)
	node:tag('tr'):tag('td'):wikitext('所属势力'):done():tag('td'):wikitext(forces[udata.force])
	node:tag('tr'):tag('td'):wikitext('单位类型'):done():tag('td'):wikitext(types[udata.utype])
	local names = {'伤害', '攻速', '命中', '护甲', '回避', '生命', '射程', '移速'}
	local files = {'Pow', 'Rate', 'Hit', 'Armor', 'Dodge', 'Life', 'Range', 'Move'}
	local attrs = {'pow', 'rate', 'hit', 'armor', 'dodge', 'life', 'range', 'speed'}
	local ranks = {'E', 'D', 'C', 'B', 'A', 'S', 'SS', [0] = 'N'}
	for i = 1,8 do
		if i % 2 == 1 then node = node:tag('tr') end
		node:tag('td'):wikitext('[[文件:Data '..files[i]..'.png|25px|link=]]'..names[i]..'&nbsp;&nbsp;&nbsp;<p class="rank'..ranks[udata[attrs[i]]]..'">&nbsp;</p>')
		if i % 2 == 0 then node = node:done() end
	end
end

local function addStats()
	local intros = mw.loadData('模块:Enemy info/intro data')
	node = node:tag('div'):addClass('TDollStattables'):tag('div'):addClass('tabber1')
	node:tag('table'):attr('id', 'introduce'):addClass('stattable')
		:tag('tr'):tag('td'):addClass('gflabelbg'):wikitext('简介'):done():done()
		:tag('tr'):tag('td'):wikitext(intros[uid])
	addAttrs()
	addDesc()
	node = node:done():done()
end

local function addPics()
	node:tag('div'):wikitext(currentframe():expandTemplate{title='立绘切换', args={
		['融合势力'] = 1, pic = 1, name1 = '初始立绘',
		pic1 = currentframe():callParserFunction('filepath', 'pic '..udata.code..' LL.png')
	}})
end

local function buildInfoWindow()
	node = root:tag('div'):css('position', 'relative')
	node = node:tag('div'):attr('id', 'TDInfWindow'):addClass('TDollInformation')
	addPics()
	addStats()
	addSpine()
	root:wikitext('[[分类:敌方单位]][[分类:'..forces[udata.force]..']][[分类:'..types[udata.utype]..']]')
end

local function addNav()
	local nav = root:tag('div'):attr('id', 'enemy-nav')
	nav:tag('div'):attr('id', 'enemy-nav-current'):wikitext('[[敌方图鉴]] > 敌方信息')
	if udata.capture == 1 then
		nav:tag('div'):attr('id', 'enemy-nav-separator')
		nav:tag('div'):attr('id', 'enemy-nav-other'):wikitext('[[/协议同归/]]')
	end
end

local function _enemyInfo()
	uid = tonumber(args[1])
	udata = data[uid]
	root = mw.html.create()
	
	addNav()
	buildInfoWindow()
	
	local templatestyle = currentframe():extensionTag{
		name = 'templatestyles', args = { src = '模板:敌方单位信息/styles.css' }
	}
	
	return templatestyle .. tostring(root)
end

function p.enemyInfo(frame)
	if frame == currentframe() then
		args = frame:getParent().args
	else
		args = frame
	end
	return _enemyInfo()
end

function p.enemyIndex()
	local groupByForce = {}
	for i = 0, 3 do groupByForce[i] = mw.html.create() end
	for i, d in ipairs(data) do
		if i ~= 100 then
			groupByForce[d.force].wikitext(currentframe():expandTemplate{
				title='UnitRevealIcon', args={d.name, i, d.utype==1 and 'BOSS单位' or ''}})
		end
	end
	root = mw.html.create()
	for _,i in ipairs{1, 2, 3, 0} do
		root:wikitext('=='..forces[i]..'==')
		root:newline()
		root:wikitext(tostring(groupByForce[i]))
		root:newline()
	end
	return tostring(root)
end

return p