◆42Lab是非盈利性、非官方的云图计划维基百科。
◆诚邀指挥官们加入编辑部共同建设wiki。点这里加入42Lab
如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!
◆有任何意见、建议、纠错,欢迎在任意评论区评论
◆编辑讨论QQ群741423564 微博@GFwiki少前百科 欢迎您

模块:HeroState

来自42LAB

可在模块:HeroState/doc创建此模块的帮助文档

local p = {}
local careers = {['守卫'] = '1', ['射手'] = '2', ['战士'] = '3', ['特种'] = '4', ['医师'] = '5'}
local args
local root

local function createItem(npic, name, theme, model, l2d, dyn, voice, anim)
	local item = mw.html.create('div'):attr('data-npic', npic)
	if model then item:tag('div'):addClass('model'):wikitext('模型') end
	if l2d then item:tag('div'):addClass('l2d'):wikitext('Live2D')
		elseif dyn then item:tag('div'):addClass('dyn'):wikitext('动态立绘') end
	if voice then item:tag('div'):addClass('voice'):wikitext('语音') end
	if anim then item:tag('div'):addClass('anim'):wikitext('动画') end
	local features = item:tag('div')
	item:tag('div'):wikitext(string.format('<b>%s</b><span>%s</span>', name, theme))
	return tostring(item)
end

local function addFixedInfo()
	local fixedInfo = root:tag('div'):addClass('fixed-info')
	fixedInfo:tag('div'):wikitext('[[文件:Career_' .. careers[args.Class] .. '.png|link=]]')
	fixedInfo:tag('div'):attr('data-name', args['人形名CN']):wikitext(args['人形名CN'])
	local rarity = string.rep('s', tonumber(args['初始星级']) - 1) .. 'r'
	fixedInfo:tag('div'):addClass(rarity):wikitext(string.upper(args['人形名EN']))
	local tags = fixedInfo:tag('div'):addClass('tags')
	for i = 1, 4 do
		if args['TAG' .. tostring(i)] then
			tags:tag('div'):wikitext(args['TAG' .. tostring(i)])
		end
	end
end

local function heroState()
	local code = args['立绘文件名'] or args['人形名EN']
	local isAgent = args['智能体'] ~= nil
	local isEntropy = args['熵'] ~= nil
        local isOutside = args['联动'] ~= nil
	local introTpl, introTpl2 = '<br>“%s”', '<br>“%s”'
	if isAgent then
		introTpl = '麦戈拉智能体平时最常穿着的服饰,最为熟悉也最为舒适。' .. introTpl
		introTpl2 = '麦戈拉智能体的心智演化到一定程度后,投影出的衣着与环境,映照着其诞生的本源。' .. introTpl2
	elseif isEntropy then
		introTpl = '异化后的人形心智呈现出的崭新姿态,但仍残留着一丝熟悉的气息。' .. introTpl
		introTpl2 = '异化后的人形心智演进到一定程度后,由投影展现出的模样,无声地诠释着某种可能。' .. introTpl2
	elseif isOutside then
		introTpl = '角色抵达麦戈拉后所穿着的服饰。最为熟悉也最为舒适。' .. introTpl
		introTpl2 = '角色抵达麦戈拉后所穿着的服饰与呈现出的独特环境,映照着现实世界中的生活。' .. introTpl2
        else
		introTpl = '人形抵达麦戈拉后,由心智所投影而出的衣着。最为熟悉也最为舒适。' .. introTpl
		introTpl2 = '人形抵达麦戈拉后,由心智投影出的衣着与环境,映照着现实世界中的生活。' .. introTpl2
	end
	root = mw.html.create('div'):addClass('hero-state')
	root:tag('div'):addClass('camp'):attr('data-camp', args['所属'])
	local skin = root:tag('div'):addClass('skin')
	addFixedInfo()
	root:wikitext('[[文件:角色详情_皮肤按钮.png|link=|class=btn-skin]]')
	root:tag('div'):addClass('btn-examine')
	local skinList = root:tag('div'):addClass('skin-list')
	local skinIntro = root:tag('div'):addClass('skin-intro')
		:tag('div'):wikitext(string.format(introTpl, args['默认投影描述'])):done()
		:tag('div'):wikitext(string.format(introTpl, args['默认投影描述'])):done()
		:tag('div'):wikitext(string.format(introTpl2, args['完形投影描述'])):done()
	skin:wikitext('[[文件:Lpic_' .. code .. '.png|link=]]')
	local npics = {'Npic_' .. code .. '.png'}
	local lbase, nbase = '[[文件:Lpic_' .. code .. '_%s.png|link=]]', 'Npic_' .. code .. '_%s.png'
	for i = 2, 3 do
		local suf = 'p' .. tostring(i)
		skin:wikitext(string.format(lbase, suf))
		table.insert(npics, string.format(nbase, suf))
	end
	local names = {args['默认投影'], args['默认投影'], args['完形投影']}
	local themes = {'默认投影', '扩容投影', '完形投影'}
	local l2ds = {args['默认投影L2D'], args['扩容投影L2D'], args['完形投影L2D']}
	for i = 1, 20 do
		local n = tostring(i)
		if args['心智投影主题' .. n] then
			skin:wikitext(string.format(lbase, args['心智投影主题' .. n]))
			table.insert(npics, string.format(nbase, args['心智投影主题' .. n]))
			table.insert(names, args['心智投影' .. n])
			table.insert(themes, args['投影系列' .. n])
			table.insert(l2ds, args['L2D' .. n])
			skinIntro:tag('div'):wikitext(args['投影描述' .. n])
		end
	end
	local items = skinList:tag('div')
	for i, v in ipairs(npics) do
		local n = tostring(i-3)
		items:wikitext(createItem(v, names[i], themes[i],
			args['模型' .. n], l2ds[i], args['动态' .. n], args['语音' .. n], args['动画' .. n]))
	end
	return tostring(root)
end

function p.heroState(frame)
	args = frame == mw.getCurrentFrame() and frame:getParent().args or frame
	return heroState()
end
return p