Dead by Daylight Wiki

LEE MÁS

Dead by Daylight Wiki
Advertisement

La documentación para este módulo puede ser creada en Módulo:DLCs/doc

local p = {}
local data = require("Module:Datatable")
local mathOps = require("Module:MathOps")
local utils = require("Module:Utils")
local c = utils -- As there is onlny one function relevant to colors I make only alias to utils Module to convenient naming "c - color"
local frame = mw.getCurrentFrame()
local bar = "|" -- code for |
local nl = "\n"
local ntl = "|-" -- new table line

fileSuffixes = {
		"", --Undefined
		"_main_header", --DLC Image
		" Theme Music" --DLC Theme music
	}

function p.getCallTable(parameter)
	return mw.dumpObject(parameter)
end

function getShortenedFileName(name)
	name = utils.RemoveSpecialCharacters(name)
	return getShortName(name)
end

function getShortName(name)
	if name:match(":") ~= nil then
		return name:match(".*: *(.+)")
	else
		return name
	end
end

function resolveDlcParameter(dlc)
	if dlc == nil then
		return getDlcByName(getShortName(mw.title.getCurrentTitle().text)) or getDlcByName(mw.title.getCurrentTitle().text)
	elseif type(dlc) == "table" then
		if dlc.args[1] == nil then 
			return getDlcByName(getShortName(mw.title.getCurrentTitle().text)) or getDlcByName(mw.title.getCurrentTitle().text) --none parameter, calling from page
		end
		if type(dlc.args[1]) == nil then 
			return getDlcByName(getShortName(mw.title.getCurrentTitle().text))
		elseif type(dlc.args[1]) == "string" then
			if tonumber(dlc.args[1]) == nil then 
				return getDlcByName(dlc.args[1])
			else 
				return getDlcById(tonumber(dlc.args[1]))
			end
		end
	elseif type(dlc) == "string" then
		return getDlcByName(dlc)
	elseif type(dlc) == "number" then
		return getDlcById(dlc)
	end
end

function getDlcByName(name)
	for _, dlcItem in ipairs(dlcs) do
		if name == dlcItem.name then return dlcItem end
	end
end

function getDlcById(id)
	for _, dlcItem in ipairs(dlcs) do
		if id == dlcItem.id then return dlcItem end
	end
end

function p.getCountOfDlcs()
	return utils.getCount("dlc")
end

function p.getCountOfChapters()
	return utils.getCount("chapter")
end

function p.getCountOfParagraphs()
	return utils.getCount("paragraph")
end

function p.getCountOfClothingDlcs()
	return utils.getCount("clothing")
end

function p.getCountOfSoundtracks()
	return utils.getCount("ost")
end

function getCountOfCosts(dlc)
	for i, _ in ipairs(dlc.cost) do end
	return i
end

function getCostTable(dlc)
	local result = ""
	
	if type(dlc.cost) == "string" then
		return "| " .. dlc.cost	
	end
	for i, cost in ipairs(dlc.cost) do
		local ccy = getCurrencyById(cost.ccy)
		
		if cost.value == 0 then
			cost.value = "-"
		end
		result = result .. "| " 
		if ccy.gc then
			result = result .. utils.commaFormat(cost.value) .. " " .. frame:expandTemplate{ title = "IconLink", args = { ccy.name  .. "s"} } -- #1: calling IconLink template #2: the 's' makes plural version of currency,
		else
			result = result .. ccy.symbol .. cost.value
		end
		if dlc.cost[i + 1] ~= nil then
			result = result .. nl .. ntl .. nl
		end
	end
	
	return result
end

function getCountDlcCosts(dlc)
	if type(dlc.cost) == "string" then return 1 end
	return #dlc.cost
end

function getCurrencyById(id)
	for _, ccyItem in ipairs(ccy) do
		if ccyItem.id == id then return ccyItem end
	end
end

function resolveCurrency(ccy)
	if ccy.gc then
		return 
	else
		
	end
end

function p.resolveThemeMusic() resolveThemeMusic(getDlcById(15)) end --dev remove

--Stranger Things Theme Music.ogg
function resolveThemeMusic(dlc)
	local name = "File:" .. getShortenedFileName(dlc.name) .. fileSuffixes[3] --remake it -dev TODO
	mw.log(name)
	mw.log(mw.title.new( name .. ".ogg").exists)
	if mw.title.new( name .. ".mp3").exists then return "[[" .. name .. ".mp3]]" end
	if mw.title.new( name .. ".ogg").exists then return "[[" .. name .. ".ogg]]" end
	
	for i, theme in ipairs(dlcThemes) do
		if theme.id == dlc.id then
			if mw.title.new("File:" .. theme.fileName .. ".mp3").exists then return "[[File:" .. theme.fileName .. ".mp3]]" end
			if mw.title.new("File:" .. theme.fileName .. ".ogg").exists then return "[[File:" .. theme.fileName .. ".ogg]]" end
			break
		end
	end
	return "Sin Musica especial"
end

function resolveShopLink(dlc)
	if dlc.link ~= nil then
		return "[https://store.steampowered.com/app/" .. dlc.link .. " Página de la Tienda ]"
	end
	return "Ninguna Página de la Tienda vinculada"
end

function p.getImageFileNameByDlc(id) mw.log(getImageFileNameByDlc(getDlcById(id))) end --dev remove

function getImageFileNameByDlc(dlc)
	for _, dlcImage in ipairs(dlcImages) do
		if dlc.id == dlcImage.id then
			return utils.resolveImageName(dlcImage.cover)
		end
	end
	return utils.resolveImageName(utils.resolveFileName(dlc.name) .. fileSuffixes[2])
end

function p.resolveDlcTable(dlc)
	dlc = resolveDlcParameter(dlc)
	if dlc == nil then return "'''" .. frame:expandTemplate{title = "clr", args = { "gold", "DLC wasn't found in DLC table in [[Module:datatable|Datatable Module]]"}} .. "'''" .. nl end
	local result = ""

	result = result .. "{|class=\"wikitable\" style=\"float:right;\"" .. nl
	result = result .. "|- style=\"font-size: 24px;\"" .. nl
	result = result .. "! width=\"300px\" align=\"center\" colspan=\"2\" | '''" .. dlc.name .. "'''" .. nl
	result = result .. ntl .. nl
	result = result .. "| align=\"center\" width=\"300px\" height=\"50px\" colspan=\"2\" |[[File:" .. getImageFileNameByDlc(dlc) .. "|300px]]" .. nl
	result = result .. ntl .. nl
	result = result .. "| width=\"100px\" | '''Fecha de Salida'''|| width=\"200px\" | " .. utils.resolveDateTime(dlc.rDate) .. nl
	result = result .. ntl .. nl
	result = result .. "| width=\"100px\" | '''Categoría'''|| width=\"200px\" | " .. dlcCategories[dlc.category] .. nl
	result = result .. ntl .. nl
	result = result .. "| width=\"100px\" rowspan = " .. getCountDlcCosts(dlc) .. " | '''Precio''' || width=\"200px\" " .. getCostTable(dlc) .. nl
	result = result .. ntl .. nl
	result = result .. "| width=\"100px\" | '''Tema Musical'''|| width=\"200px\" |" .. resolveThemeMusic(dlc) .. nl
	result = result .. ntl .. nl
	result = result .. "! width=\"300px\" align=\"center\" colspan=\"2\" | " .. resolveShopLink(dlc) .. nl
	result = result .. "|}"

	mw.log(mw.dumpObject(result))
	return result
end

--DEV
function try(f, catch_f)
	local status, exception = pcall(f)
	if not status then
		catch_f(exception)
	end
end

function p.getListOfDlcChapters()
	local result = "";
	local counter = 1;
	
	for _, dlcItem in ipairs(dlcs) do
		if dlcItem.category == 1 then
			result = result .. "* [[CAPÍTULO " .. ToRomanNumerals(counter) .. ": " .. dlcItem.name .. "]]" .. nl
			counter = counter + 1
		end
	end
	
	mw.log(result)
	return result
end

return p
Advertisement