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

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

来自少前百科GFwiki
跳转至: 导航搜索
第7行: 第7行:
 
local guntype = {'手枪(HG)', '冲锋枪(SMG)', '步枪(RF)',
 
local guntype = {'手枪(HG)', '冲锋枪(SMG)', '步枪(RF)',
 
'突击步枪(AR)', '机枪(MG)', '霰弹枪(SG)'}
 
'突击步枪(AR)', '机枪(MG)', '霰弹枪(SG)'}
local modrank = {[2] = '4', [3] = '4', [4] = '5', [5] = '6'}
+
local modrank = {'', '4', '4', '5', '6'}
 
local base_attr = {
 
local base_attr = {
 
{0.60, 0.60, 0.80, 1.20, 1.80, 0.00},
 
{0.60, 0.60, 0.80, 1.20, 1.80, 0.00},
第33行: 第33行:
 
return ceil((basic_life_armor[mindupdate][attr%4][1] +
 
return ceil((basic_life_armor[mindupdate][attr%4][1] +
 
(lv-1)*basic_life_armor[mindupdate][attr%4][2])*base_attr[guntype][attr]*ratio/100)
 
(lv-1)*basic_life_armor[mindupdate][attr%4][2])*base_attr[guntype][attr]*ratio/100)
 +
end
 +
 +
local function addImages()
 +
local skindata = mw.loadData('Module:Gun info/skin_data')
 +
local skinclassdata = mw.loadData('Module:Gun info/skinclass_data')
 +
local showcase = root:tag('div')
 +
local menu = showcase:tag('ul')
 +
local display = showcase:tag('div')
 +
for _, v in ipairs(gundata.skins) do
 +
skin = skindata[v]
 +
if skin then
 +
local item = menu:tag('li')
 +
item:tag('span'):wikitext(skin.name)
 +
item:tag('span'):wikitext(skinclassdata[skin.class])
 +
local skintype = skin['type']
 +
if skintype ~= 0 then
 +
item:attr('data-isl2d', '1')
 +
item:addClass('live2d' .. tostring(skintype))
 +
end
 +
display:tag('div'):cssText('display:none'):wikitext('[[file:pic '
 +
.. gundata.code .. tostring(v) .. ' HD.png|512px]]')
 +
end
 +
end
 +
showcase:tag('div'):attr('id', 'live2d-control'):cssText('display:none')
 
end
 
end
  
第58行: 第82行:
 
 
 
addInfobox()
 
addInfobox()
 +
addImages()
 
 
 
local templatestyles = mw.getCurrentFrame():extensionTag{
 
local templatestyles = mw.getCurrentFrame():extensionTag{

2022年5月16日 (一) 22:34的版本

模块:Gun info及其子页面是一组主要用于存放和展示战术人形相关信息的模块,其各个部分的作用见下文。

组成部分

控制代码

数据


local p = {}
local args = {}
local root
local gundata
local data = mw.loadData('Module:Gun info/data')
local infobox = require('Module:Infobox').infobox
local guntype = {'手枪(HG)', '冲锋枪(SMG)', '步枪(RF)',
	'突击步枪(AR)', '机枪(MG)', '霰弹枪(SG)'}
local modrank = {'', '4', '4', '5', '6'}
local base_attr = {
	{0.60, 0.60, 0.80, 1.20, 1.80, 0.00},
	{1.60, 0.60, 1.20, 0.30, 1.60, 0.00},
	{0.80, 2.40, 0.50, 1.60, 0.80, 0.00},
	{1.00, 1.00, 1.00, 1.00, 1.00, 0.00},
	{1.50, 1.80, 1.60, 0.60, 0.60, 0.00},
	{2.00, 0.70, 0.40, 0.30, 0.30, 1.00}}
local basic = {16, 45, 5, 5}
local basic_lifearmor = {
	{{55, 0.555}, {2, 0.161}},
	{{96.283, 0.138}, {13.979, 0.04}}}
local grow = {
	{{0.242, 0}, {0.181, 0}, {0.303, 0}, {0.303, 0}},
	{{0.06, 18.018}, {0.022, 15.741}, {0.075, 22.572}, {0.075, 22.572}}}

local function calc(lv, guntype, mindupdate, attr, ratio, growth)
	local base = basic[attr-1]*base_attr[guntype][attr]*ratio/100
	local accretion = (grow[mindupdate][attr-1][2] +
		(lv-1)*grow[mindupdate][attr-1][1])*base_attr[guntype][attr]*ratio*growth/100/100
	return ceil(base) + ceil(accretion)
end

local function calcLifeArmor(lv, guntype, mindupdate, attr, ratio)
	return ceil((basic_life_armor[mindupdate][attr%4][1] +
		(lv-1)*basic_life_armor[mindupdate][attr%4][2])*base_attr[guntype][attr]*ratio/100)
end

local function addImages()
	local skindata = mw.loadData('Module:Gun info/skin_data')
	local skinclassdata = mw.loadData('Module:Gun info/skinclass_data')
	local showcase = root:tag('div')
	local menu = showcase:tag('ul')
	local display = showcase:tag('div')
	for _, v in ipairs(gundata.skins) do
		skin = skindata[v]
		if skin then
			local item = menu:tag('li')
			item:tag('span'):wikitext(skin.name)
			item:tag('span'):wikitext(skinclassdata[skin.class])
			local skintype = skin['type']
			if skintype ~= 0 then
				item:attr('data-isl2d', '1')
				item:addClass('live2d' .. tostring(skintype))
			end
			display:tag('div'):cssText('display:none'):wikitext('[[file:pic '
				.. gundata.code .. tostring(v) .. ' HD.png|512px]]')
		end
	end
	showcase:tag('div'):attr('id', 'live2d-control'):cssText('display:none')
end

local function addInfobox()
	root:wikitext(infobox{
		above = gundata.name,
		label1 = '编号',
		data1 = gundata.id,
		label2 = '武器类型',
		data2 = guntype[gundata['type']],
		label3 = '稀有度',
		data3 = tostring(gundata.rank) ..
			(moddata and '(心智升级:' .. modrank[gundata.rank] .. ')' or '')
	})
end

local function _gunInfo()
	gundata = data[tonumber(args[1])]
	if gundata == nil then
		return '<p style="color:red">未找到编号对应的战术人形信息,请检查编号是否正确及' ..
			'<a href="/w/Module:Gun_info/data">Module:Gun info/data</a>的数据是否为最新。</p>'
	end
	moddata = data[tonumber(args[1])+20000]
	root = mw.html.create()
	
	addInfobox()
	addImages()
	
	local templatestyles = mw.getCurrentFrame():extensionTag{
		name = 'templatestyles', args = { src = 'Module:Gun info/styles.css' }
	}
	return templatestyles .. tostring(root)
end

function p.gunInfo(frame)
	if frame == mw.getCurrentFrame() then
		args = frame:getParent().args
	else
		args = frame
	end
	return _gunInfo()
end

return p