置顶公告:【置顶】关于临时开启评论区所有功能的公告(2022.10.22) | 【置顶】关于本站Widget恢复使用的公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:Sandbox/公的驱逐舰/BACharinfo

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
Template-info.svg 模块文档  [创建] [刷新]
-- this is a pre-alpha demo.

local p = {}

local getArgs = require ( 'Module:Arguments' ).getArgs
	local wrapperArray = { 'User:公的驱逐舰/basandbox/char', 'Template:沙盒' }
local ruby = require('Module:Ruby')._ruby
-- REMEMBER TO CHANGE THESE WHEN LUM IS DEPLOYED!!!!!
local lum = require('Module:Sandbox/公的驱逐舰/LUM')

--lookup tables
local dataNameTable = {
	'最大体力', '攻击力', '防御力', '治愈力', '命中数值', '回避数值', '一般攻击射程',
	'暴击数值', '暴击伤害', '群控强化力', '群控抵抗力', '弹药数量', '弹药消耗', '稳定数值'
}
local blockLabelCodeLookup = {
	['?'] = 'type0', ['一般'] = 'type0',
	['爆炸'] = 'type1', ['轻'] = 'type1', 
	['贯穿'] = 'type2', ['重'] = 'type2',
	['神秘'] = 'type3', ['特殊'] = 'type3',
	['攻城'] = 'type4', ['结构物'] = 'type4'
}
--[[local schoolNameTable = {
	['阿拜多斯']= '阿拜多斯',
	['格黑娜']	= '格黑娜',
	['千年']	= '千年',
	['三一']	= '三一',
	['百鬼夜行']= '百鬼夜行',
	['山海经']	= '山海经',
	['赤冬']	= '赤冬'
}]]
local schoolGradientTable = {
	['阿拜多斯']= '#57B5F5,#4C79B4',
	['格黑娜']	= '#1B284B,#655A85',
	['千年']	= '#DDEEFF,#889FC0',
	['三一']	= '#88D0FF,#4FAFC7',
	['百鬼夜行']= '#E7A0D7,#9EB3E9',
	['山海经']	= '#ED8FA9,#B7B7F7',
	['赤冬']	= '#DDDDEE,#7F7080'
}

local autolink = function ( args )
	if args[2] then
		if args[2] == 'FORCENOLINK' then return args[1] end
		return '[[' .. table.concat ( args, '|' ) .. ']]'
	else
		return '[['..o..']]'
	end
end
local noSelect = function ( s ) return '<span class="ba-noselect">'..s..'</span>' end

p._main = function ( args )
	local d = {}
	-- data name
	local dataName = lum.gneafa ( args, {"数据名", "data-name"} )
	-- table-y data
	d.name = lum.parseArray { lum.gafa ( args, {"中文名", "name"}, ''), flatten = true }
	d.janame = lum.parseArray { lum.gafa ( args, {"日文名", "ja-name"}, ''), flatten = true }
	-- tachie
	if dataName then
		local tachieOffset = lum.parseArray { lum.gafa ( args, {"立绘偏移", "tachie-offset"}, '' ), flatten = true }
		for i=0, tonumber( lum.gneafa ( args, {"立绘数", "tachie-count"}, 0 ) ) do
			d.tachie[i][1] = lum.gneafa ( args, {("立绘"..i),("tachie-"..i)}, ('BA_'..dataName..( i > 0 and ('_'..i) or '' ) ) )
		end
	end
	-- stringy data
	d.NAME = lum.gafa ( args, {} )
	
	
	
	return p._genwikitext ( d )
end

p._genwikitext = function ( d )
	if d.janame and d.janame[1] and lum.isEmpty ( d.janame[3] ) then d.janame = table.concat ( d.janame, noSelect( '&emsp;' ) ) end
	if d.name and d.name[1] then d.name = table.concat ( d.name, noSelect( '&emsp;' ) ) end
	d.tachie = d.tachie or ''
	d.data = d.data or {}
	d.attackType = d.attackType or '?'
	d.defenseType = d.defenseType or '?'
	d.terrain = d.terrain or {}
	local outTable = { 
		'<div class="bacharinfo"',
		(d.school and ('style="background:linear-gradient( to bottom, '..schoolGradientTable[d.school]..'90% )" ') or ''),
		'>\n<div class="name-container">\n<div class="school label skew"><span>',
		( d.school or '未知校园' ),
		'</span><br /><span>',
		( d.club or '未知社团' ),
		'</span></div>\n<div class="name-ja" lang="ja" xml:lang="ja">',
		( d.janame and ( d.janame[3] and ( ruby { rbtext=d.janame[1], rttext=d.janame[3], rtsize='' } .. noSelect( '&ensp;' ) .. d.janame[2] ) or d.janame ) or '???' ),
		'</div>\n<div class="name" style="text-decoration:underline 5px #FF0;text-underline-offset:5px">',
		( d.name or '???' ),
		'</div>\n</div>\n<div class="tabs-container">\n<div class="illust-cv"><span class="label">画/</span>',
		( d.illustrator and autolink ( d.illustrator ) or '???' ),
		'<br /><span class="label">音/</span>',
		( d.cv and autolink ( d.cv ) or '???' ),
		'</div>\n<div class="label sabun-label">表情差分</div>\n<div class="school-logo">',
		(d.school and ( '[[File:BA_School_' .. d.school .. '.png|100px]]' ) or '' ),
		'</div>\n<div class="rarity">',
		(d.rarity and string.rep( '★', d.rarity ) or '?'),
		'</div>\n<div class="Tabs" data-label-side="left" data-divider-size="0" data-default-tab="1"  data-label-color="#3DF" data-text-border-color="transparent" data-text-padding="0" data-label-background-color="#0F2233" data-text-background-color="transparent">\n'
	}
	local count = #outTable
	-- tabs generation
	if d.tachie[1] then 
		for i = 0, #d.tachie do
			d.tachie[i][2] = lum.isEmpty ( d.tachie[i][2] ) and '50%' or d.tachie[i][2]
			outTable[count+2*i-1] = '<div class="Tab"><div class="TabLabelText">' .. ( i > 0 and i  or 'M' ) .. '</div><div class="TabContentText"><div class="img" style="left:'
			outTable[count+2*i] = d.tachie[i][2]..';transform:translateX(-'..d.tachie[i][2]..')">[[File:BA_' .. d.tachie[i][1] .. '|x700px]]</div></div></div>\n'
		end
	else
		outTable[count+1] = '<div class="Tab"><div class="TabLabelText">?</div><div class="TabContentText"><div class="notachie img" style="top:50%;left:50%;transform:translate(-50%,-50%);">?</div></div></div>\n'
	end
	count = #outTable + 1
	outTable[count] = '</div>\n</div>\n<div class="data-container">\n<div>\n'
	-- data setup
	for i = 1, 7 do
		outTable[count+i] = '<div class="label">' .. dataNameTable[i] .. '</div><div>' .. ( d.data[dataNameTable[i]] or '?' ) .. '</div>\n'
	end
	outTable[count+8] = '</div>\n<div>\n'
	for i = 8,14 do
		outTable[count+i+1] = '<div class="label">' .. dataNameTable[i] .. '</div><div>' .. ( d.data[dataNameTable[i]] or '?' ) .. '</div>\n'
	end
	count = count + 15
	outTable[count+ 1] = '</div>\n</div>\n<div class="misc-container">\n<div class="profession skew"><div class="profession-icon">' .. ( d.profession and '[[File:BA_Prof_' .. d.profession .. '|80px]]' or '<div role="img" alt="未知">?</div>' )
	outTable[count+ 2] = '</div><div><span title="职业">' .. ( d.profession or '未知' ) .. '</span>·<span class="profession-type" title="战术作用">' .. ( d.professionType or 'UNKNOWN' )
	outTable[count+ 3] = '</span></div></div>\n<div class="attack-info">\n<div class="label">攻击类型</div><div class="block-label ' .. blockLabelCodeLookup[d.attackType] .. '">' ..  d.attackType
	outTable[count+ 4] = '</div>\n<div class="label">防御类型</div><div class="block-label ' .. blockLabelCodeLookup[d.defenseType] .. '">' .. d.defenseType
	outTable[count+ 5] = '</div>\n<div class="label">站位范围</div><div class="pos-weapon">' ..  ( d.position or '?' )
	outTable[count+ 6] = '</div>\n<div class="label">使用武器</div><div class="pos-weapon">' ..  ( d.weapon or '?' )
	outTable[count+ 7] = '</div>\n</div>\n<div class="terrain-ratings">\n<div class="terrain-icon">[[File:BA_Terrain_Outdoor.png|50px|城镇战]</div><div class="terrain-rating-text ' .. ( d.terrain[1] or 'unknown' ) .. '">' .. ( d.terrain[1] or '?' )
	outTable[count+ 8] = '</div><div class="terrain-rating-icon">[[File:BA_TerRat_Outdoor' .. ( d.terrain[1] or 'U' ) .. '.png|50px|' .. ( d.terrain[1] or '未知' ) 
	outTable[count+ 9] = ']]</div>\n<div class="terrain-icon">[[File:BA_Terrain_Desert.png|50px|野战]]</div><div class="terrain-rating-text ' .. ( d.terrain[2] or 'unknown' ) .. '">' .. ( d.terrain[2] or '?' ) 
	outTable[count+10] = '</div><div class="terrain-rating-icon">[[File:BA_TerRat_' .. ( d.terrain[2] or 'U' ) .. '.png|50px|' .. ( d.terrain[2] or '未知' ) 
	outTable[count+11] = ']]</div>\n<div class="terrain-icon">[[File:BA_Terrain_Indoor.png|50px|室内战]]</div><div class="terrain-rating-text ' .. ( d.terrain[3] or 'unknown' ) .. '">' .. ( d.terrain[3] or '?' ) 
	outTable[count+12] = '</div><div class="terrain-rating-icon">[[File:BA_TerRat_' .. ( d.terrain[3] or 'U' ) .. '.png|50px|' .. ( d.terrain[3] or '未知' ) 
	outTable[count+13] = ']]</div>\n</div>\n</div>\n</div>'
	return table.concat ( outTable )
end

p.test = function ( frame )
	args = getArgs ( frame, { wrappers = wrapperArray	} )
	args.janame = lum.parseArray ( args.janame, true )
	args.tachie = lum.parseArray ( args.tachie )
	args.data = lum.parseArray ( args.data, true )
	args.terrain = lum.parseArray ( args.terrain, true )
	return p.genwikitext ( args )
end

return p