Wiki Genshin Impact

Chào mừng bạn đến với Wiki Genshin Impact!
Bọn mình đang rất cần thêm biên tập viên! Nếu bạn có hứng thú với biên tập wiki hoặc muốn báo cáo lỗi sai trong bài viết, hãy tham gia Discord của bọn mình!
Bạn cũng có thể tham gia Discord để thảo luận và trò chuyện về game nữa đó!

READ MORE

Wiki Genshin Impact
Wiki Genshin Impact
Biểu tượng tài liệu Tài liệu mô đun

This module implements {{Drops}}.

Dữ liệu lưu trữ trong Module:Drops/data.

local p = {}
local Card = require('Module:Card')._main
local search =  require('Module:TableTools').includes
local namespace = require('Module:Namespace detect').main

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame, {
		parentFirst = true,
		wrapper = { 'Template:Drops' }
	})
	return p._main(args)
end

function p._main(args)
	local info = mw.loadData('Module:Drops/data')
	local name = args[1] or mw.title.getCurrentTitle().rootText
	local output = mw.html.create()
	local categories = mw.html.create()
	if info['Custom_Enemies'][name] then
		for k,v in ipairs(info['Custom_Enemies'][name].CardOrder) do
			output:wikitext(tostring(Card{v:gsub('­',''),info['Custom_Enemies'][name][v],caption=v}))
			categories:wikitext('[[Thể loại:Rơi ',v:gsub('­',''),']]')
		end
		return tostring(output) .. namespace{main = tostring(categories)}
	else
		local y = 1
		while info['Enemies'][y] do
			if search(info['Enemies'][y].members,name) then
				if tostring(args.all) == '0' then
				else
					--Mora
					if search(info['Base_Info']['type-1'].members,name) then
						output:wikitext(tostring(Card{'Mora',info['Base_Info']['type-1'].Mora,caption='Mora'}))
					elseif search(info['Base_Info']['type-2'].members,name) then
						output:wikitext(tostring(Card{'Mora',info['Base_Info']['type-2'].Mora,caption='Mora'}))
					elseif search(info['Base_Info']['type-3'].members,name) then
						output:wikitext(tostring(Card{'Mora',info['Base_Info']['type-3'].Mora,caption='Mora'}))
					else
						output:wikitext(tostring(Card{'Mora','—',caption='Mora'}))
					end
					categories:wikitext('[[Thể loại:Rơi Mora]]')
					
					--EXP
					output:wikitext(tostring(Card{'EXP Nhân Vật','—',caption='EXP Nhân Vật'}))
					categories:wikitext('[[Thể loại:Rơi EXP Nhân Vật]]')
				end
				
				--Material Sets
				local i = 1
				while info['Enemies'][y]['MatSet' .. i] do
					p.MatSetParse(info['Enemies'][y]['MatSet' .. i],output,categories)
					i = i + 1
				end
				
				--Artifacts
				if (info['Enemies'][y].artifacts and args.all ~= '0') then
					output:wikitext(tostring(Card{'Thầy Thuốc','Bộ',show_caption=1,set=1,rarity='1-3'}))
					output:wikitext(tostring(Card{'Cuồng Chiến','Bộ',show_caption=1,set=1,rarity='3-4'}))
					output:wikitext(tostring(Card{'Giáo Quan','Bộ',show_caption=1,set=1,rarity='3-4'}))
					output:wikitext(tostring(Card{'Kẻ Lưu Đày','Bộ',show_caption=1,set=1,rarity='3-4'}))
				end
				
				--Conditional Material Sets
				local i = 1
				while info['Enemies'][y]['SpecMatSet' .. i] do
					if i == 1 then output = mw.html.create():wikitext(';Thường'):newline():node(output) end
					output:newline():wikitext(';',info['Enemies'][y]['SpecMatSet' .. i].condition):newline()
					p.MatSetParse(info['Enemies'][y]['SpecMatSet' .. i],output,categories)
					i = i + 1
				end
				if tostring(args.all) == '0' then
					return tostring(output)
				else
					return tostring(output) .. namespace{main = tostring(categories)}
				end
			end
			y = y + 1
		end
	end
	return 'Không có thông tin liên quan, hãy cập nhật [[Mô đun:Drops/data|kho dữ liệu]].'
end

function p.MatSetParse(list,output,categories)
	output:wikitext(tostring(Card{list[1]:gsub('­',''),'Lv. 1+',caption=list[1]}))
	output:wikitext(tostring(Card{list[2]:gsub('­',''),'Lv. 40+',caption=list[2]}))
	output:wikitext(tostring(Card{list[3]:gsub('­',''),'Lv. 60+',caption=list[3]}))
	categories:wikitext('[[Thể loại:Rơi ' .. list[1]:gsub('­','') .. ']]')
	categories:wikitext('[[Thể loại:Rơi ' .. list[2]:gsub('­','') .. ']]')
	categories:wikitext('[[Thể loại:Rơi ' .. list[3]:gsub('­','') .. ']]')
end

return p