◆少前百科是非盈利性、非官方的少女前线维基百科。 ◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科。 ◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科 ◆To foreigners,You can use twitter to contact us. |
“模块:Gun info”的版本间的差异
小 |
小 |
||
第5行: | 第5行: | ||
local data = mw.loadData('Module:Gun info/data') | local data = mw.loadData('Module:Gun info/data') | ||
local infobox = require('Module:Infobox').infobox | local infobox = require('Module:Infobox').infobox | ||
− | local guntype = {' | + | local guntype = { {'手枪', '冲锋枪', '步枪', '突击步枪', '机枪', '霰弹枪'}, |
− | + | {'HG', 'SMG', 'RF', 'AR', 'MG', 'SG'} } | |
− | + | local base_attr | |
− | local base_attr | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
local basic = {16, 45, 5, 5} | local basic = {16, 45, 5, 5} | ||
− | local | + | local basic_lifearmors = { |
{{55, 0.555}, {2, 0.161}}, | {{55, 0.555}, {2, 0.161}}, | ||
{{96.283, 0.138}, {13.979, 0.04}}} | {{96.283, 0.138}, {13.979, 0.04}}} | ||
− | local | + | local grows = { |
{{0.242, 0}, {0.181, 0}, {0.303, 0}, {0.303, 0}}, | {{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}}} | {{0.06, 18.018}, {0.022, 15.741}, {0.075, 22.572}, {0.075, 22.572}}} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
local function addImages() | local function addImages() | ||
+ | root:wikitext('== 人形外观 ==') | ||
+ | root:newline() | ||
local guncode = string.gsub(gundata.code, ' ', '_') | local guncode = string.gsub(gundata.code, ' ', '_') | ||
local skindata = mw.loadData('Module:Gun info/skin_data') | local skindata = mw.loadData('Module:Gun info/skin_data') | ||
第65行: | 第48行: | ||
end | end | ||
showcase:tag('div'):attr('id', 'live2d-control'):cssText('display:none') | showcase:tag('div'):attr('id', 'live2d-control'):cssText('display:none') | ||
+ | root:newline() | ||
+ | end | ||
+ | |||
+ | local function getGridPositions(center, pos) | ||
+ | local self_pos = 4 - floor(self_pos / 5) + 3 * (self_pos % 5 - 2) | ||
+ | local effect_poses = {} | ||
+ | for i, v in ipairs(pos) do | ||
+ | effect_poses[i] = 3*(2 - (v - 1)%5) + floor((v - 1)/5) - 2 + self_pos | ||
+ | end | ||
+ | return self_pos, effect_poses | ||
+ | end | ||
+ | |||
+ | local function makeEffectTable(self_pos, effect_poses) | ||
+ | local effect_table = root:tag('table') | ||
+ | local index = 1 | ||
+ | for i = 0, 2 do | ||
+ | local tr = effect_table:tag('tr') | ||
+ | for j = 1, 3 do | ||
+ | local td = tr:tag('td') | ||
+ | if i*3 + j == effect_poses[index] then | ||
+ | td:addClass('effect-cell') | ||
+ | index = index + 1 | ||
+ | elseif i*3 + j == self_pos then | ||
+ | td:attr('id', 'self-cell') | ||
+ | index = index + 1 | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | |||
+ | local function addCombatInfo() | ||
+ | root:wikitext('== 战斗数据 ==') | ||
+ | root:newline() | ||
+ | local ratios = { gundata.life, gundata.power, gundata.rate, | ||
+ | gundata.hit, gundata.dodge } | ||
+ | local attrtable = root:tag('table'):attr{ | ||
+ | id = 'attr-table', | ||
+ | ['data-growing'] = table.concat(ratios, ','), | ||
+ | ['data-growth'] = gundata.growth | ||
+ | } | ||
+ | local self_pos | ||
+ | local effect_poses | ||
+ | self_pos, effect_poses = getGridPositions(gundata.grid_center or 13, gundata.grid_pos) | ||
+ | makeEffectTable(self_pos, effect_poses) | ||
+ | if moddata then | ||
+ | local ratios = { moddata.life, moddata.power, moddata.rate, | ||
+ | moddata.hit, moddata.dodge } | ||
+ | attrtable:attr{ | ||
+ | ['data-growing-mod'] = table.concat(ratios, ','), | ||
+ | ['data-growth-mod'] = moddata.growth | ||
+ | } | ||
+ | self_pos, effect_poses = getGridPositions(moddata.grid_center or 13, moddata.grid_pos) | ||
+ | makeEffectTable(self_pos, effect_poses) | ||
+ | end | ||
end | end | ||
local function addInfobox() | local function addInfobox() | ||
+ | local modrank = {'', '4', '4', '5', '6'} | ||
root:wikitext(infobox{ | root:wikitext(infobox{ | ||
above = gundata.name, | above = gundata.name, | ||
第73行: | 第111行: | ||
data1 = gundata.id, | data1 = gundata.id, | ||
label2 = '武器类型', | label2 = '武器类型', | ||
− | data2 = guntype[gundata['type']], | + | data2 = guntype[1][gundata['type']], |
label3 = '稀有度', | label3 = '稀有度', | ||
data3 = tostring(gundata.rank) .. | data3 = tostring(gundata.rank) .. | ||
(moddata and '(心智升级:' .. modrank[gundata.rank] .. ')' or '') | (moddata and '(心智升级:' .. modrank[gundata.rank] .. ')' or '') | ||
}) | }) | ||
+ | root:newline() | ||
end | end | ||
第90行: | 第129行: | ||
addInfobox() | addInfobox() | ||
+ | addCombatInfo() | ||
addImages() | addImages() | ||
2022年5月23日 (一) 23:01的版本
模块:Gun info及其子页面是一组主要用于存放和展示战术人形相关信息的模块,其各个部分的作用见下文。
组成部分
控制代码
- 主页面,实现模板:战术人形信息
- 模块:Gun info/index输出人形数据列表,供战术人形图鉴使用
- 模块:Gun info/new输出最近30天实装的人形,供首页/新增人形展示用
数据
- 人形数据
- 模块:Gun info/data存放未心智升级的普通战术人形的数据
- 模块:Gun info/data extra存放特典人形的数据
- 模块:Gun info/data mod存放战术人形心智升级后与原来不同的数据
- 模块:Gun info/ex data从人形数据中单独挑出的人形名称和专属装备编号数据,替代完整的人形数据被装备页面模板请求,以减少请求的数据体积(见模块:Equip info)
- 模块:Gun info/obtain data存放获取方式的数据,也包括装备、妖精等游戏内容的获取方式
- 模块:Gun info/org data存放战术人形和融合势力在格里芬所属部门的数据
- 模块:Gun info/skin data存放人形装扮的数据
- 模块:Gun info/skinclass data存放装扮主题的数据
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 base_attr local basic = {16, 45, 5, 5} local basic_lifearmors = { {{55, 0.555}, {2, 0.161}}, {{96.283, 0.138}, {13.979, 0.04}}} local grows = { {{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 addImages() root:wikitext('== 人形外观 ==') root:newline() local guncode = string.gsub(gundata.code, ' ', '_') local skindata = mw.loadData('Module:Gun info/skin_data') local showcase = root:tag('div'):attr('id', 'unit-image-showcase') local menu = showcase:tag('ul'):attr('id', 'unit-image-selector') showcase:tag('div'):attr('id', 'unit-image-display') showcase:tag('div'):attr('id', 'state-toggle') menu:tag('li'):attr('data-skincode', guncode):wikitext('初始形象') if moddata then local moditem = menu:tag('li') :attr('data-skincode', guncode .. 'Mod'):wikitext('心智升级') local l2dmod = {[55] = 1, [56] = 1, [57] = 1, [65] = 1, [101] = 1, [103] = 1, [122] = 1, [143] = 1} if l2dmod[gundata.id] then moditem:addClass('live2d1') end end for _, v in ipairs(gundata.skins) do skin = skindata[v] if skin then local skincode = guncode .. '_' .. tostring(v) local item = menu:tag('li') item:tag('span'):wikitext(skin.name) item:tag('span'):wikitext(skindata.skin_classes[skin.class]) local skintype = skin['type'] item:attr('data-skincode', skincode) if skintype ~= 0 then item:addClass('live2d' .. tostring(skintype)) end end end showcase:tag('div'):attr('id', 'live2d-control'):cssText('display:none') root:newline() end local function getGridPositions(center, pos) local self_pos = 4 - floor(self_pos / 5) + 3 * (self_pos % 5 - 2) local effect_poses = {} for i, v in ipairs(pos) do effect_poses[i] = 3*(2 - (v - 1)%5) + floor((v - 1)/5) - 2 + self_pos end return self_pos, effect_poses end local function makeEffectTable(self_pos, effect_poses) local effect_table = root:tag('table') local index = 1 for i = 0, 2 do local tr = effect_table:tag('tr') for j = 1, 3 do local td = tr:tag('td') if i*3 + j == effect_poses[index] then td:addClass('effect-cell') index = index + 1 elseif i*3 + j == self_pos then td:attr('id', 'self-cell') index = index + 1 end end end end local function addCombatInfo() root:wikitext('== 战斗数据 ==') root:newline() local ratios = { gundata.life, gundata.power, gundata.rate, gundata.hit, gundata.dodge } local attrtable = root:tag('table'):attr{ id = 'attr-table', ['data-growing'] = table.concat(ratios, ','), ['data-growth'] = gundata.growth } local self_pos local effect_poses self_pos, effect_poses = getGridPositions(gundata.grid_center or 13, gundata.grid_pos) makeEffectTable(self_pos, effect_poses) if moddata then local ratios = { moddata.life, moddata.power, moddata.rate, moddata.hit, moddata.dodge } attrtable:attr{ ['data-growing-mod'] = table.concat(ratios, ','), ['data-growth-mod'] = moddata.growth } self_pos, effect_poses = getGridPositions(moddata.grid_center or 13, moddata.grid_pos) makeEffectTable(self_pos, effect_poses) end end local function addInfobox() local modrank = {'', '4', '4', '5', '6'} root:wikitext(infobox{ above = gundata.name, label1 = '编号', data1 = gundata.id, label2 = '武器类型', data2 = guntype[1][gundata['type']], label3 = '稀有度', data3 = tostring(gundata.rank) .. (moddata and '(心智升级:' .. modrank[gundata.rank] .. ')' or '') }) root:newline() 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() addCombatInfo() addImages() local templatestyles = mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = '模板:战术人形信息/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