「于世界交点之处,逢似曾相识之人」

本wiki目前不支持自由编辑,如果有兴趣参与wiki内容编辑,请加入WIKI建设群904200987(游戏交流勿加会被踢)
使用wiki的数据、图片、音频资源,或者搬运页面内容时,请注明出处。具体参照CC BY-NC-SA 4.0协议
感谢Hyacinth对本wiki提供的数据支持
编辑帮助BWIKI反馈

bugfix1001.2
全站通知:

模块:来源查询

来自白荆回廊Wiki
跳到导航 跳到搜索

此模块的文档可以在模块:来源查询/doc创建

local createItemLink = require('Module:Item/Link')

local p = {}

-- 查询物品的成就来源
function p.from_achieve(key)
	--查询成就
	local dataList = require('Module:成就数据库').achieves_data
	local outputData = {}
	for _i,v in ipairs(dataList) do
		for _j,w in ipairs(v['reward_list']) do
	        if w['name'] == key then
	        	local temp = v
	        	temp["count"] = w['count']
	        	table.insert(outputData,temp)
	        end
	    end
    end
    
    if #outputData == 0 then
        return nil
    end
    
    -- 拼接展示页面
    local html = mw.html.create()
    html = html:tag('table'):cssText('margin:0;width:100%;'):addClass('wikitable')
    
    --生成表头
    html = html:tag('tr')
                    :tag('th'):wikitext('分类'):done()
                    :tag('th'):wikitext('成就'):done()
                    :tag('th'):wikitext('成就条件'):done()
                    :tag('th'):wikitext('数量'):done()
                :done()
    -- 生成表格
    for _i,v in ipairs(outputData) do
    	local class = v['class1']
    	if v['class2'] ~= '' then
    		class = class .. '·' .. v['class2']
    	end
        html = html:tag('tr')
                        :tag('td'):cssText('text-align:center;'):wikitext(class):done()
                        :tag('td'):wikitext(v['name']):done()
                        :tag('td'):wikitext(v['condition']):done()
                        :tag('td'):cssText('text-align:center;'):wikitext(v['count']):done()
                    :done()
    end
    
    html = html:done()
    
    return html
    
end

-- 查询物品的任务来源
function p.from_quest(key)
	--查询成就
	local dataList = require('Module:任务数据库').tasks_data
	local outputData = {}
	for _i,v in ipairs(dataList) do
		for _j,w in ipairs(v['reward_list']) do
	        if w['name'] == key then
	        	local temp = v
	        	temp["count"] = w['count']
	        	table.insert(outputData,temp)
	        end
	    end
    end
    
    if #outputData == 0 then
        return nil
    end
    
    -- 拼接展示页面
    local html = mw.html.create()
    html = html:tag('table'):cssText('margin:0;width:100%;'):addClass('wikitable')
    
    --生成表头
    html = html:tag('tr')
                    :tag('th'):wikitext('分类'):done()
                    :tag('th'):wikitext('成就条件'):done()
                    :tag('th'):wikitext('数量'):done()
                :done()
    -- 生成表格
    for _i,v in ipairs(outputData) do
    	local class = v['class1']
    	if v['class2'] ~= '' and  v['class2'] ~= v['class1'] then
    		class = class .. '·' .. v['class2']
    	end
        html = html:tag('tr')
                        :tag('td'):cssText('text-align:center;'):wikitext(class):done()
                        :tag('td'):wikitext(v['condition']):done()
                        :tag('td'):cssText('text-align:center;'):wikitext(v['count']):done()
                    :done()
    end
    
    html = html:done()
    
    return html
    
end
-- 查询物品的兑换来源
function p.from_shop(key)
	local name_table = {
		['典藏ChatMore映像·「独家幕后」']='云无月,独家幕后',
		['典藏ChatMore映像·「雪夜与赞美诗」']='明月尘,雪夜与赞美诗',
		['ChatMore映像·「海谣」']='昊苍,海谣',
		['ChatMore映像·「万里彼苍」']='乐无异,万里彼苍',
		['ChatMore映像·「第一课」']='尤尼,第一课',
		['ChatMore映像·「无栖」']='言御,无栖',
		['立绘映像·「独家幕后」']='云无月,独家幕后',
		['立绘映像·「雪夜与赞美诗」']='明月尘,雪夜与赞美诗',
		['立绘映像·「海谣」']='昊苍,海谣',
		['立绘映像·「万里彼苍」']='乐无异,万里彼苍',
		['立绘映像·「第一课」']='尤尼,第一课',
		['立绘映像·「无栖」']='言御,无栖',
	}
	--查询商店兑换
	local dataList = require('Module:商店兑换数据库').store_exchange_data
	local outputData = {}
	local item_name = key
	if name_table[key] ~= nil then
		item_name = name_table[key]
	end
	for _i,v in ipairs(dataList) do
	    if v['object_name'] == item_name and v['store_type'] == '有猫零售' then
	        table.insert(outputData,v)
	    end
    end
    
    if #outputData == 0 then
        return nil
    end

    -- 拼接展示页面
    local html = mw.html.create()
    html = html:tag('table'):cssText('margin:0;width:100%;'):addClass('wikitable')
    
    --生成表头
    html = html:tag('tr')
                    :tag('th'):wikitext('兑换商店'):done()
                    :tag('th'):wikitext('兑换数量'):done()
                       :tag('th'):wikitext('消耗材料'):done()
                       :tag('th'):wikitext('可兑换次数/周期'):done()
                :done()
    -- 生成表格
    for _i,v in ipairs(outputData) do
    	local exchange_times = v['exchange_times']
    	if v['exchange_cycle']~=nil and v['exchange_cycle']~="" then
    		exchange_times = exchange_times .. " / " ..v['exchange_cycle']
    	end
        html = html:tag('tr')
                        :tag('td'):cssText('text-align:center;'):wikitext(v['store_name']):done()
                        :tag('td'):cssText('text-align:center;'):wikitext(v['object_number']):done()
                        :tag('td'):cssText('text-align:center;'):node(createItemLink.create_link_small(v['material_name'],v['material_number'],'物品',true)):done()
                        :tag('td'):cssText('text-align:center;'):wikitext(exchange_times):done()
                    :done()
    end
    
    html = html:done()
    
    return html
    
end

-- 查询物品的抽卡来源
function p.from_draw(key)
    local html = mw.html.create()
    if string.find(key,'契文') then
        local memory_name = string.gsub(key,'契文·','')
        html = html:wikitext('在【深潜系统】中重复获得记忆烙痕[[记忆烙痕/'.. memory_name .. '|'..memory_name..']]')
    end
    if string.find(key,'叙刻回声') then
        local character_name = string.gsub(key,'叙刻回声·','')
        html = html:wikitext('在【深潜系统】中重复获得同调者[[同调者/'.. character_name .. '|'..character_name..']]')
    end
    if key=='小猫礼品卡' then
        html = html:wikitext('在【深潜系统】中用同调线索或者是闪回进行抽卡。')
    end
    if key=='大猫兑换卡' then
        html = html:wikitext('任意同调者/记忆烙痕深化达到上限后,在【深潜系统】中再次获得该同调者/记忆烙痕时会替换为大猫兑换卡')
    end
    return html
end

-- 查询物品的白荆穹顶来源
function p.from_home(key)
    local html = mw.html.create()
    --白荆穹顶-研发室
    if key=='多维拉练器' or key=='实战BOXER·Ω型' then
    	html = html:wikitext('白荆穹顶-初级研发室')
    end
    if key=='重组蛋白' or key=='神经活性剂' then
    	html = html:wikitext('白荆穹顶-高级研发室')
    end
    --白荆穹顶-加工中心
    if key=='熵化合金' then
    	html = html:wikitext('白荆穹顶-加工中心:')
    	    	    :tag('div'):cssText('display:flex;gap:6px;align-items:center;')
						:node(createItemLink.create_link_medium('熵化合金',1,nil))
	    	    		:wikitext(' = ')
						:node(createItemLink.create_link_medium('稳态合金',2,nil))
	    	    		:wikitext(' + ')
						:node(createItemLink.create_link_medium('多矩推进器',1,nil))
	    	    		:wikitext(' + ')
						:node(createItemLink.create_link_medium('复合磁导插件',1,nil))
					:done()
    end
    if key=='极叠磁导插件' then
    	html = html:wikitext('白荆穹顶-加工中心:')
    	    	    :tag('div'):cssText('display:flex;gap:6px;align-items:center;')
						:node(createItemLink.create_link_medium('极叠磁导插件',1,nil))
	    	    		:wikitext(' = ')
						:node(createItemLink.create_link_medium('复合磁导插件',2,nil))
	    	    		:wikitext(' + ')
						:node(createItemLink.create_link_medium('光子质',1,nil))
	    	    		:wikitext(' + ')
						:node(createItemLink.create_link_medium('稳态合金',1,nil))
					:done()
    end
    if key=='“乌云盖雪”' then
    	html = html:wikitext('白荆穹顶-加工中心:')
    	    	    :tag('div'):cssText('display:flex;gap:6px;align-items:center;')
						:node(createItemLink.create_link_medium('“乌云盖雪”',1,nil))
	    	    		:wikitext(' = ')
						:node(createItemLink.create_link_medium('多矩推进器',2,nil))
	    	    		:wikitext(' + ')
						:node(createItemLink.create_link_medium('稳态合金',1,nil))
	    	    		:wikitext(' + ')
						:node(createItemLink.create_link_medium('复合磁导插件',1,nil))
					:done()
    end
    if key=='万顷岩' then
    	html = html:wikitext('白荆穹顶-加工中心:')
    	    	    :tag('div'):cssText('display:flex;gap:6px;align-items:center;')
						:node(createItemLink.create_link_medium('万顷岩',1,nil))
	    	    		:wikitext(' = ')
						:node(createItemLink.create_link_medium('卷礁',2,nil))
	    	    		:wikitext(' + ')
						:node(createItemLink.create_link_medium('黛晶',1,nil))
	    	    		:wikitext(' + ')
						:node(createItemLink.create_link_medium('多矩推进器',1,nil))
					:done()
    end
    if key=='相位链' then
    	html = html:wikitext('白荆穹顶-加工中心:')
    	    	    :tag('div'):cssText('display:flex;gap:6px;align-items:center;')
						:node(createItemLink.create_link_medium('相位链',1,nil))
	    	    		:wikitext(' = ')
						:node(createItemLink.create_link_medium('光子质',2,nil))
	    	    		:wikitext(' + ')
						:node(createItemLink.create_link_medium('黛晶',1,nil))
	    	    		:wikitext(' + ')
						:node(createItemLink.create_link_medium('卷礁',1,nil))
					:done()
    end
    if key=='乌珀' then
    	html = html:wikitext('白荆穹顶-加工中心:')
    	    	    :tag('div'):cssText('display:flex;gap:6px;align-items:center;')
						:node(createItemLink.create_link_medium('乌珀',1,nil))
	    	    		:wikitext(' = ')
						:node(createItemLink.create_link_medium('黛晶',2,nil))
	    	    		:wikitext(' + ')
						:node(createItemLink.create_link_medium('光子质',1,nil))
	    	    		:wikitext(' + ')
						:node(createItemLink.create_link_medium('卷礁',1,nil))
					:done()
    end
    return html
end

-- 查询物品的掉落来源
function p.from_dungoen(key)
	--查询关卡掉落
	local dataList = require('Module:关卡掉落数据库').dungoen_drop_data
	local outputData_temp = {}
	for _i,v in ipairs(dataList) do
	    if v['material_name'] == key then
	    	local temp = v['dungoen']..'_'..v['dungoen_type']..v['drop_type']
	    	if outputData_temp[temp] == nil then 
	    		outputData_temp[temp] = {v}
	    	else
	    		table.insert(outputData_temp[temp],v)
	    	end
	    end
    end

    if outputData_temp == {} then
        return '数据缺失'
    end

	--整理输出数据并按关卡名重新排序
	local outputData = {}
	for _i, v in pairs(outputData_temp) do
		local temp = {
			dungoen_type = v[1]['dungoen_type'],
			dungoen = v[1]['dungoen'],
			drop_type = v[1]['drop_type'],
			ap = v[1]['ap'],
			material_number = '',
			ap_count_temp = 0
		}
    	for _j, w in ipairs(v) do
    		temp['material_number'] = temp['material_number'] .. '<br>' .. w['material_number'] .. " / 概率" .. (w['droprate'] * 100) .. "%";
    		temp['ap_count_temp'] = temp['ap_count_temp'] + w['material_number'] * w['droprate']
    	end
    	temp['material_number'] = mw.ustring.sub( temp['material_number'], 5 )
    	table.insert(outputData,temp)
    end
	table.sort(outputData, p.sort_table_by_dungoen)

    -- 拼接展示页面
    local html = mw.html.create()

    html = html:tag('table'):cssText('margin:0;width:100%;'):addClass('wikitable')
    
    --生成表头
    html = html:tag('tr')
                :tag('th'):wikitext('关卡类型'):done()
                :tag('th'):wikitext('关卡'):done()
                :tag('th'):wikitext('掉落条件'):done()
                :tag('th'):wikitext('AP'):done()
                :tag('th'):wikitext('掉落数量'):done()
                :tag('th'):wikitext('AP/个'):done()
            :done()
    -- 生成表格

    for _i, v in ipairs(outputData) do
        html = html:tag('tr')                
                    :tag('td'):cssText('text-align:center;'):wikitext(v['dungoen_type']):done()
                    :tag('td'):cssText('text-align:center;'):wikitext(v['dungoen']):done()
                    :tag('td'):cssText('text-align:center;'):wikitext(v['drop_type']):done()
                    :tag('td'):cssText('text-align:center;'):wikitext(v['ap']):done()
                    :tag('td'):cssText('text-align:center;'):wikitext(v['material_number']):done()
                    :tag('td'):cssText('text-align:center;'):wikitext(string.format("%.2f", v['ap'] / v['ap_count_temp'])):done()
                :done()
    end
    
    html = html:done()
    
    return html
end

function p.sort_table_by_dungoen(a, b)
  return (a['dungoen'] < b['dungoen'])
end

-- 查询物品的活动来源
function p.from_activity(key,other_str)
	--查询活动商店部分
	local dataList = require('Module:商店兑换数据库').store_exchange_data
	local outputData = {}
	local outputData_reopen = {}
	for _i,v in ipairs(dataList) do
	    if v['object_name'] == key and v['store_type'] == '活动商店' then
	        table.insert(outputData,v)
	    end
	    if v['object_name'] == key and v['store_type'] == '活动常驻商店' then
	        table.insert(outputData_reopen,v)
	    end
    end
    
    local html = mw.html.create()
    if #outputData == 0 then
    else
	    -- 拼接展示页面
	    html = html:tag('table'):cssText('margin:0;width:100%;'):addClass('wikitable mw-collapsible mw-made-collapsible')
	    
	    --生成表头
	    html = html:tag('tr')
	                    :tag('th'):attr('colspan',5):wikitext('活动商店'):done()
	                :done()
	                :tag('tr')
	                    :tag('th'):wikitext('兑换商店'):done()
	                    :tag('th'):wikitext('兑换数量'):done()
	                       :tag('th'):wikitext('消耗材料'):done()
	                       :tag('th'):wikitext('可兑换次数'):done()
	                :done()
	    -- 生成表格
	    for _i,v in ipairs(outputData) do
	        html = html:tag('tr')
	                        :tag('td'):cssText('text-align:center;'):wikitext(v['store_name']):done()
	                        :tag('td'):cssText('text-align:center;'):wikitext(v['object_number']):done()
	                        :tag('td'):cssText('text-align:center;'):node(createItemLink.create_link_small(v['material_name'],v['material_number'],'物品',true)):done()
	                        :tag('td'):cssText('text-align:center;'):wikitext(v['exchange_times']):done()
	                    :done()
	    end
    end
    if #outputData_reopen == 0 then
    else
	    -- 拼接展示页面
	    html = html:tag('table'):cssText('margin:0;width:100%;'):addClass('wikitable mw-collapsible mw-made-collapsible')
	    
	    --生成表头
	    html = html:tag('tr')
	                    :tag('th'):attr('colspan',5):wikitext('活动商店(常驻新增)'):done()
	                :done()
	                :tag('tr')
	                    :tag('th'):wikitext('兑换商店'):done()
	                    :tag('th'):wikitext('兑换数量'):done()
	                       :tag('th'):wikitext('消耗材料'):done()
	                       :tag('th'):wikitext('可兑换次数'):done()
	                :done()
	    -- 生成表格
	    for _i,v in ipairs(outputData_reopen) do
	        html = html:tag('tr')
	                        :tag('td'):cssText('text-align:center;'):wikitext(v['store_name']):done()
	                        :tag('td'):cssText('text-align:center;'):wikitext(v['object_number']):done()
	                        :tag('td'):cssText('text-align:center;'):node(createItemLink.create_link_small(v['material_name'],v['material_number'],'物品',true)):done()
	                        :tag('td'):cssText('text-align:center;'):wikitext(v['exchange_times']):done()
	                    :done()
	    end
    end
    --查询活动任务成就
	local tasksData = require('Module:活动任务数据库').tasks_data
	local outputData2 = {}
	for _i,v in ipairs(tasksData) do
		for _j,w in ipairs(v['reward_list']) do
	        if w['name'] == key and string.find(v['activity'],'分进合击战')==nil then
	        	local temp = v
	        	temp["count"] = w['count']
	        	table.insert(outputData2,temp)
	        end
	    end
    end
    
    if #outputData2 == 0 then
    else
	    -- 拼接展示页面
	    html = html:tag('table'):cssText('margin:0;width:100%;'):addClass('wikitable mw-collapsible mw-made-collapsible')
	    
	    --生成表头
	    html = html:tag('tr')
	                    :tag('th'):attr('colspan',4):wikitext('活动任务/成就/等级/积分'):done()
	                :done()
	                :tag('tr')
	                    :tag('th'):wikitext('活动'):done()
	                    :tag('th'):wikitext('类型'):done()
	                    :tag('th'):wikitext('名称'):done()
	                    :tag('th'):wikitext('数量'):done()
	                :done()
	    -- 生成表格
	    for _i,v in ipairs(outputData2) do
	    	local class = v['class1']
	    	if v['class2'] ~= '' and v['class2'] ~= nil then
	    		class = class .. '·' .. v['class2']
	    	end
	    	local title = v['title']
	    	if title == '' or v['class1']=='等级' or v['class1']=='积分' then
	    		title = v['desc']
	    	end
	    	local activity = v['activity']
	    	local ind = string.find(activity,' - ')
	    	if ind then
	    		activity = string.sub(activity, 1, ind - 1)
	    	end
	        html = html:tag('tr')
	                        :tag('td'):cssText('text-align:center;'):wikitext('[['..activity..'|'..v['activity']..']]'):done()
	                        :tag('td'):cssText('text-align:center;'):wikitext(class):done()
	                        :tag('td'):wikitext(title):done()
	                        :tag('td'):cssText('text-align:center;'):wikitext(v['count']):done()
	                    :done()
	    end
    end
    
        
    if #outputData == 0 and #outputData2 == 0 and #outputData_reopen == 0 then
        html = html:wikitext(other_str)
    end
    
    if key == '记忆之契·SSR' then
        html = html:wikitext('分进合击战累积分奖励')
    end
    if key == '记忆之契·SR' then
        html = html:wikitext('分进合击战累积分奖励')
    end


    html = html:done()
    
    return html
    
end

-- 查询物品的分进合击来源
function p.from_raid(key)
    local html = mw.html.create()
    --查询活动任务成就
	local tasksData = require('Module:活动任务数据库').tasks_data
	local outputData2 = {}
	for _i,v in ipairs(tasksData) do
		for _j,w in ipairs(v['reward_list']) do
	        if w['name'] == key and string.find(v['activity'],'分进合击战') then
	        	local temp = v
	        	temp["count"] = w['count']
	        	table.insert(outputData2,temp)
	        end
	    end
    end
    
    if #outputData2 == 0 then
    else
	    -- 拼接展示页面
	    html = html:tag('table'):cssText('margin:0;width:100%;'):addClass('wikitable mw-collapsible mw-made-collapsible')
	    
	    --生成表头
	    html = html:tag('tr')
	                    :tag('th'):attr('colspan',4):wikitext('积分奖励'):done()
	                :done()
	                :tag('tr')
	                    :tag('th'):wikitext('活动'):done()
	                    :tag('th'):wikitext('类型'):done()
	                    :tag('th'):wikitext('名称'):done()
	                    :tag('th'):wikitext('数量'):done()
	                :done()
	    -- 生成表格
	    for _i,v in ipairs(outputData2) do
	    	local class = v['class1']
	    	if v['class2'] ~= '' and v['class2'] ~= nil then
	    		class = class .. '·' .. v['class2']
	    	end
	    	local title = v['desc']
	        html = html:tag('tr')
	                        :tag('td'):cssText('text-align:center;'):wikitext('[['..v['activity']..']]'):done()
	                        :tag('td'):cssText('text-align:center;'):wikitext(class):done()
	                        :tag('td'):wikitext(title):done()
	                        :tag('td'):cssText('text-align:center;'):wikitext(v['count']):done()
	                    :done()
	    end
    end
   
    html = html:done()
    
    return html
    
end
return p