Dead by Daylight Wiki

Current Tome: Tome VIII - Deliverance
Featuring Jake Park SurvivorJake.png and The Clown IconHelpLoading clown.png
TomeVIII Deliverance Banner.jpg

READ MORE

Dead by Daylight Wiki
Jouki (talk | contribs)
m
Jouki (talk | contribs)
m
 
(10 intermediate revisions by the same user not shown)
Line 6: Line 6:
 
local bar = "|" -- code for |
 
local bar = "|" -- code for |
 
local nl = "\n"
 
local nl = "\n"
 
local ntl = "|-"
  +
  +
strings = {
  +
file = "File",
  +
altName = "Alt. Name",
  +
gender = "Gender",
  +
role = "Role",
  +
nationality = "Nationality",
  +
dlc = "DLC",
  +
actor = "Voice Actor",
  +
uknownActor = "Undisclosed Voice Actor", --unkown/undisclosed
  +
male = "Male",
  +
female = "Female",
  +
undefined = "Undefined",
  +
}
   
 
function p.getCountOfSurvivors()
 
function p.getCountOfSurvivors()
Line 11: Line 26:
 
end
 
end
   
function getSurvivorIndexById(id)
+
function getSurvivorIndexById(id) --not used
 
for i, s in ipairs(survivors) do
 
for i, s in ipairs(survivors) do
 
if s.id == id then return i end
 
if s.id == id then return i end
Line 18: Line 33:
 
end
 
end
   
function getSurvivorIndexByName(name) --not used
+
function getSurvivorIdByName(name)
  +
for _, survivor in ipairs(survivors) do
local i = 1
 
 
if survivor.name == name then
while survivors[i] do
 
 
return survivor.id
if survivors[i].name == name then
 
return i
 
 
end
 
end
i = i + 1
 
 
end
 
end
  +
 
return 0
 
return 0
 
end
 
end
  +
  +
function p.resolveSurvivorCharTable()
  +
local survivorId = getSurvivorIdByName(mw.title.getCurrentTitle().text)
  +
local surv = utils.getCharacterById(survivorId, survivors)
  +
local result = ""
  +
  +
if type(surv) ~= "table" then return surv end
  +
  +
result =
  +
'{| class = "infoboxtable"' .. nl ..
  +
ntl ..' class = "infoboxTitle" | ' .. nl ..
  +
'! class = "center bold" colspan = 2 | ' .. (surv.shortName or surv.name) .. nl ..
  +
ntl .. nl ..
  +
'! class = "center" colspan = 2 | [[' .. strings.file .. ':' .. resolveSurvPortraitImageFileName(surv) .. '.png|150px]]' .. nl ..
  +
ntl .. nl
  +
if surv.altName ~= nil then
  +
result = result .. '| class = "titleColumn" | ' .. strings.altName .. ' || class = "valueColumn" | ' .. surv.altName .. nl .. ntl .. nl
  +
end
  +
result = result ..
  +
'| class = "titleColumn" | ' .. strings.gender .. ' || class = "valueColumn" | ' .. utils.resolveGender(surv.gender) .. nl ..
  +
ntl .. nl ..
  +
'| class = "titleColumn" | ' .. strings.role .. ' || class = "valueColumn" | ' .. surv.role .. nl ..
  +
ntl .. nl ..
  +
'| class = "titleColumn" | ' .. strings.nationality .. ' || class = "valueColumn" | ' .. surv.nationality .. nl ..
  +
ntl .. nl
  +
if surv.dlc ~= nil then
  +
result = result .. '| class = "titleColumn" | ' .. strings.dlc .. ' || class = "valueColumn" | [[' .. getDlcById(surv.dlc).name .. ']] ' .. nl .. ntl .. nl
  +
end
  +
result = result ..
  +
'| class = "titleColumn" | ' .. strings.actor .. ' || class = "valueColumn" | ' .. (surv.actor or strings.uknownActor) .. nl ..
  +
'|}'
  +
  +
  +
mw.log(result)
  +
return result
  +
  +
end
  +
   
 
function p.resolveSurvivorsTable()
 
function p.resolveSurvivorsTable()
Line 62: Line 114:
 
result = result .. "<div class=\"fplink plainlinks image\"><div class=\"box\"><div class=\"row\"><div class=\"cell\">"
 
result = result .. "<div class=\"fplink plainlinks image\"><div class=\"box\"><div class=\"row\"><div class=\"cell\">"
 
result = result .. "<div class=\"image\">[[File:" .. fileName .. ".png|link=" .. name .. "]]</div>"
 
result = result .. "<div class=\"image\">[[File:" .. fileName .. ".png|link=" .. name .. "]]</div>"
result = result .. "<div class=\"link\">[[" .. name .. "]]</div></div></div></div></div>"
+
result = result .. "<div class=\" charLink survivorLink link\">[[" .. name .. "]]</div></div></div></div></div>"
 
end
 
end
 
result = result .. "</div>"
 
result = result .. "</div>"
Line 70: Line 122:
 
end
 
end
 
 
  +
function resolveSurvPortraitImageFileName(surv)
  +
local fileConst = "_charSelect_portrait"
  +
return "S" .. string.format("%02d", surv.id) .. fileConst
  +
end
  +
 
function resolveSurvivorsPortraitFileNameById(id)
 
function resolveSurvivorsPortraitFileNameById(id)
 
local fileConst = "_charPreview_portrait"
 
local fileConst = "_charPreview_portrait"

Latest revision as of 08:48, 11 September 2021


local p = {}
local data = require("Module:Datatable")
local mathOps = require("Module:MathOps")
local utils = require("Module:Utils")
local frame = mw.getCurrentFrame()
local bar = "&#124;" -- code for |
local nl = "\n"
local ntl = "|-"

strings = {
	file = "File",
	altName = "Alt. Name",
	gender = "Gender",
	role = "Role",
	nationality = "Nationality",
	dlc  = "DLC",
	actor = "Voice Actor",
	uknownActor = "Undisclosed Voice Actor", --unkown/undisclosed
	male = "Male",
	female = "Female",
	undefined = "Undefined",
}

function p.getCountOfSurvivors()
	return utils.getCount("survivor")
end

function getSurvivorIndexById(id) --not used
	for i, s in ipairs(survivors) do
		if s.id == id then return i end
	end
	return 0
end

function getSurvivorIdByName(name)
	for _, survivor in ipairs(survivors) do
		if survivor.name == name then
			return survivor.id
		end
	end
	
	return 0
end

function p.resolveSurvivorCharTable()
	local survivorId = getSurvivorIdByName(mw.title.getCurrentTitle().text)
	local surv = utils.getCharacterById(survivorId, survivors)
	local result = ""
	
	if type(surv) ~= "table" then return surv end
	
	result = 
	'{| class = "infoboxtable"' .. nl ..
	ntl ..' class = "infoboxTitle" | ' .. nl ..
	'! class = "center bold" colspan = 2 | ' .. (surv.shortName or surv.name) .. nl ..
	ntl .. nl ..
	'! class = "center" colspan = 2 | [[' .. strings.file .. ':' .. resolveSurvPortraitImageFileName(surv) .. '.png|150px]]' .. nl ..
	ntl .. nl
	if surv.altName ~= nil then
		result = result .. '| class = "titleColumn" | ' .. strings.altName .. ' || class = "valueColumn" | ' .. surv.altName .. nl .. ntl .. nl
	end
	result = result ..
	'| class = "titleColumn" | ' .. strings.gender .. ' || class = "valueColumn" | ' .. utils.resolveGender(surv.gender) .. nl ..
	ntl .. nl ..
	'| class = "titleColumn" | ' .. strings.role .. ' || class = "valueColumn" | ' .. surv.role .. nl ..
	ntl .. nl ..
	'| class = "titleColumn" | ' .. strings.nationality .. ' || class = "valueColumn" | ' .. surv.nationality .. nl ..
	ntl .. nl
	if surv.dlc ~= nil then
		result = result .. '| class = "titleColumn" | ' .. strings.dlc .. ' || class = "valueColumn" | [[' .. getDlcById(surv.dlc).name .. ']] ' .. nl .. ntl .. nl
	end
	result = result ..
	'| class = "titleColumn" | ' .. strings.actor .. ' || class = "valueColumn" | ' .. (surv.actor or strings.uknownActor) .. nl ..
	'|}'
	
	
	mw.log(result)
	return result	

end
	

function p.resolveSurvivorsTable()
	local result = ""
	local name
	local fileName

	result = result .. "<div style=\"color: #fff;\">"
	for i, survivor in ipairs(survivors) do
		
		fileName = resolveSurvivorsPortraitFileNameById(survivor.id)
		
		result = result .. "<div style=\"display: inline-block; text-align:center; margin: 10px\">[[" .. survivor.name .. "]]"
		result = result .. "[[File:" .. fileName .. ".png|center|frameless|link=" .. survivor.name .. "]]</div>"

	end
	result = result .. "</div>"

	return result
end

function p.resolveSurvivorsTableMainPage()
	local result = ""
	local name
	local fileName

	result = result .. "<div class=\"fpbox\" id=\"fpsurvivors\" style=\"text-align: center;\">"
	result = result .. "<div class=\"heading\">The [[Survivors]] [[File:IconHelpLoading survivor.png|32px]]</div>"
	result = result .. "<div class=\"fplinks\">"
	for i, survivor in ipairs(survivors) do
		name = survivor.shortName or survivor.name
		fileName = resolveSurvivorsPortraitFileNameById(survivor.id)
		
		result = result .. "<div class=\"fplink plainlinks image\"><div class=\"box\"><div class=\"row\"><div class=\"cell\">"
		result = result .. "<div class=\"image\">[[File:" .. fileName .. ".png|link=" .. name .. "]]</div>"
		result = result .. "<div class=\" charLink survivorLink link\">[[" .. name .. "]]</div></div></div></div></div>"
	end
	result = result .. "</div>"
	result = result .. "</div>"

	return result
end
	
function resolveSurvPortraitImageFileName(surv)
	local fileConst = "_charSelect_portrait"
	return "S" .. string.format("%02d", surv.id) .. fileConst
end

function resolveSurvivorsPortraitFileNameById(id)
	local fileConst = "_charPreview_portrait"
	local fileName
	
	fileName = getFileNameFromTableById(id)
	if not utils.isValidFileName(fileName) then --S{ID}_charPreview_portrait
		fileName = "S" .. string.format("%02d", id) .. fileConst
	end
	if not utils.isValidFileName(fileName) then --File not Found
		fileName = "UnknownSurvivor" .. fileConst
	end
	
	mw.log(fileName)
	return fileName
end

function getFileNameFromTableById(id)
	mw.log(id)
	for j, sImage in ipairs(survivorImages) do
		if sImage.id == id then
			return sImage.preview
		end
	end
	return ""
end

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

return p