Dead by Daylight Wiki

Current Tome: Tome IX - Crescendo

Featuring Yun-Jin Lee SurvivorYun-Jin.png and The Trickster IconHelpLoading trickster.png

TomeIX Crescendo Banner.jpg

READ MORE

Dead by Daylight Wiki
Jouki (talk | contribs)
m
Jouki (talk | contribs)
m
 
(38 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
local mathOps = require("Module:MathOps")
 
local mathOps = require("Module:MathOps")
 
local utils = require("Module:Utils")
 
local utils = require("Module:Utils")
  +
local prkz = require("Module:Datatable/Perks")
  +
local perkImg = require("Module:PerkImage")
  +
local str = require("Module:Strings")
 
local frame = mw.getCurrentFrame()
 
local frame = mw.getCurrentFrame()
  +
local bar = "|" -- code for |
 
  +
local nl = "\n"
 
  +
strings = {
  +
the = "The",
  +
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 27:
 
end
 
end
   
function getSurvivorIndexById(id)
+
function getSurvivorNameById(id) --not used
for i, s in ipairs(survivors) do
+
for _, s in ipairs(survivors) do
if s.id == id then return i end
+
if s.id == id then return s.name end
 
end
 
end
 
return 0
 
return 0
 
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 getSurvivorById(id)
 
for _, survivor in ipairs(survivors) do
 
if survivor.id == id then return survivor end
 
end
 
return nil
 
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 | [[' .. cstr.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 34: Line 94:
 
local fileName
 
local fileName
   
result = result .. "<div style=\"color: #fff;\">"
+
result = result .. '<div style = "color: #fff;">'
  +
maxId = utils.getMaxId(survivors)
 
for i, survivor in ipairs(survivors) do
 
for i, survivor in ipairs(survivors) do
  +
fileName = utils.resolveCharacterPortraitFileName(survivor, maxId)
 
 
  +
result = result ..
fileName = resolveSurvivorsPortraitFileNameById(survivor.id)
 
 
'<div style = "display: inline-block; text-align:center; margin: 10px">' .. link(survivor.name) ..
 
 
link(cstr.file .. fileName .. '.png|center|frameless|link=' .. survivor.name) .. '</div>'
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
 
end
result = result .. "</div>"
+
result = result .. '</div>'
   
 
return result
 
return result
Line 49: Line 109:
   
 
function p.resolveSurvivorsTableMainPage()
 
function p.resolveSurvivorsTableMainPage()
local result = ""
+
local result = cstr.empty
 
local name
 
local name
 
local fileName
 
local fileName
   
result = result .. "<div class=\"fpbox\" id=\"fpsurvivors\" style=\"text-align: center;\">"
+
result = result ..
  +
'<div class = "fpbox" id = "fpsurvivors" style = "text-align: center;">' ..
result = result .. "<div class=\"heading\">The [[Survivors]] [[File:IconHelpLoading survivor.png|32px]]</div>"
+
'<div class = "heading">' .. strings.the .. space .. '[[Survivors]] [[' .. cstr.file .. 'IconHelpLoading survivor.png|32px]]</div>' ..
result = result .. "<div class=\"fplinks\">"
 
  +
'<div class = "fplinks charSection">'
  +
utils.sortTableById(survivors)
 
local maxId = utils.getMaxId(survivors)
 
for i, survivor in ipairs(survivors) do
 
for i, survivor in ipairs(survivors) do
 
name = survivor.shortName or survivor.name
 
name = survivor.shortName or survivor.name
fileName = resolveSurvivorsPortraitFileNameById(survivor.id)
+
fileName = utils.resolveCharacterPortraitFileName(survivor, maxId)
 
 
  +
result = result ..
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>"
+
'<div class = "fplink charMainPageBox plainlinks image"><div class = "box"><div class = "row"><div class = "cell">' ..
result = result .. "<div class=\"link\">[[" .. name .. "]]</div></div></div></div></div>"
+
'<div class = "image">[[' .. cstr.file .. fileName .. '.png|link=' .. name .. ']]</div>' ..
  +
'<div class = "charLink survivorLink link">[[' .. name .. ']]</div>' ..
  +
'<div class = "charPerkBox">' .. resolveCharPerksMainPage(survivor) .. '</div>' ..
  +
'</div></div></div></div>'
 
end
 
end
result = result .. "</div>"
+
result = result ..
  +
'</div>' ..
result = result .. "</div>"
 
  +
'</div>'
   
 
return result
 
return result
 
end
 
end
  +
  +
function resolveCharPerksMainPage(character)
  +
local mPerks = require("Module:Perks")
 
local result = ''
  +
local perkList = mPerks.getPerksByCharacter(character)
 
 
  +
utils.sortPerksByLevel(perkList)
function resolveSurvivorsPortraitFileNameById(id)
 
  +
for _, perk in ipairs(perkList) do
local fileConst = "_charPreview_portrait"
 
  +
result = result .. '[[' .. cstr.file .. mPerks.getTeachablePerkIcon(perk) .. '|link=' .. perk.name .. '|42px]]'
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
 
end
 
 
 
return result
mw.log(fileName)
 
 
end
return fileName
 
  +
  +
function resolveSurvPortraitImageFileName(surv)
 
local fileConst = "_charSelect_portrait"
 
return "S" .. string.format("%02d", surv.id) .. fileConst
 
end
 
end
   
function getFileNameFromTableById(id)
+
function getDlcById(id)
  +
for _, dlc in ipairs(dlcs) do
mw.log(id)
 
 
if dlc.id == id then return dlc end
for j, sImage in ipairs(survivorImages) do
 
if sImage.id == id then
 
return sImage.preview
 
end
 
 
end
 
end
return ""
 
 
end
 
end
   
function resolveNewInitialsByIndex(i)
+
function getSurvivorListWithPerks()
  +
local perkTable = {}
if survivors[i] == nil then
 
  +
for _,perk in ipairs(perks) do
return ""
 
 
if perk.character ~= nil and perk.charType == 'S' then
end
 
  +
if perkTable[perk.character] == nil then
local s = survivors
 
  +
perkTable[perk.character] = {}
local initials = getSurvivorsInitialsByIndex(i)
 
  +
end
local dlcCodeName =""
 
  +
perkTable[perk.character].id = perk.character
if s[i].dlc ~= nil and dlcs[s[i].dlc] ~= nil then
 
  +
perkTable[perk.character][#perkTable[perk.character]+1] = perk
dlcCodeName = getDlcById(s[i].dlc).codeName
 
  +
end
 
end
 
end
 
 
  +
return perkTable
local dlcInitial = dlcCodeName:match("^(%S).*$") or "A" --A is for characters from original game as they don't have any DLC code Name nor DLC id
 
 
mw.log(dlcInitial .. "S " .. initials)
 
return dlcInitial .. "S " .. initials
 
 
end
 
end
   
function getSurvivorsInitialsByIndex(i)
+
function p.resolveSurvivorsEntries()
  +
local perkTable = getSurvivorListWithPerks()
if survivors[i] == nil then
 
 
local result = ""
return ""
 
end
 
 
 
  +
result = result .. '<div style="display: flex; flex-flow: row wrap; justify-content:center;">' .. nl
local firstLetter, lastLetter
 
 
 
  +
for _, trio in ipairs(perkTable) do
firstLetter, lastLetter = survivors[i].name:match("^(%S).+ (%S).-$")
 
  +
result = result .. '<div class = "entryTable">' .. nl ..
  +
'{| class = "wikitable"' .. nl
 
  +
survivor = getSurvivorById(trio.id)
  +
result = result .. '|+ ' .. survivor.name .. nl ..
  +
ntl .. nl ..
  +
'| rowspan = 3 | [[' .. cstr.file .. resolveSurvPortraitImageFileName(survivor) .. '.png|99px|link=' .. survivor.name .. ']]' .. nl
  +
utils.sortPerksByLevel(trio)
  +
for i, perk in ipairs(trio) do
  +
result = result .. '! [[' .. cstr.file .. perkImg.main(perk.techName or perk.name) .. '|33px]]' .. nl ..
  +
'! [[' .. perk.name .. ']]' .. nl ..
  +
'| ' .. utils.clr(perk.level, 6) .. nl
  +
if i < #trio then
  +
result = result .. ntl .. nl
  +
end
  +
end
  +
result = result .. '|}' .. nl ..
  +
'</div>' .. nl
  +
end
 
 
  +
result = result .. '</div>' .. nl
return firstLetter .. lastLetter
 
  +
end
 
 
mw.log(result)
 
  +
--mw.log(mw.dumpObject(perkTable))
function getDlcById(id)
 
 
return result
for _, dlc in ipairs(dlcs) do
 
if dlc.id == id then return dlc end
 
end
 
 
end
 
end
   

Latest revision as of 12:57, 2 December 2021


local p = {}
local data = require("Module:Datatable")
local mathOps = require("Module:MathOps")
local utils = require("Module:Utils")
local prkz = require("Module:Datatable/Perks")
local perkImg = require("Module:PerkImage")
local str = require("Module:Strings")
local frame = mw.getCurrentFrame()


strings = {
	the = "The",
	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 getSurvivorNameById(id) --not used
	for _, s in ipairs(survivors) do
		if s.id == id then return s.name 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 getSurvivorById(id)
	for _, survivor in ipairs(survivors) do
		if survivor.id == id then return survivor end
	end
	return nil
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 | [[' .. cstr.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;">'
	maxId = utils.getMaxId(survivors)
	for i, survivor in ipairs(survivors) do
		fileName = utils.resolveCharacterPortraitFileName(survivor, maxId)
		
		result = result .. 
			'<div style = "display: inline-block; text-align:center; margin: 10px">' .. link(survivor.name) ..
			link(cstr.file .. fileName .. '.png|center|frameless|link=' .. survivor.name) .. '</div>'
	end
	result = result .. '</div>'

	return result
end

function p.resolveSurvivorsTableMainPage()
	local result = cstr.empty
	local name
	local fileName

	result = result ..
		'<div class = "fpbox" id = "fpsurvivors" style = "text-align: center;">' ..
		'<div class = "heading">' .. strings.the .. space .. '[[Survivors]] [[' .. cstr.file .. 'IconHelpLoading survivor.png|32px]]</div>' ..
		'<div class = "fplinks charSection">'
	utils.sortTableById(survivors)
	local maxId = utils.getMaxId(survivors)
	for i, survivor in ipairs(survivors) do
		name = survivor.shortName or survivor.name
		fileName = utils.resolveCharacterPortraitFileName(survivor, maxId)
		
		result = result .. 
			'<div class = "fplink charMainPageBox plainlinks image"><div class = "box"><div class = "row"><div class = "cell">' ..
				'<div class = "image">[[' .. cstr.file .. fileName .. '.png|link=' .. name .. ']]</div>' ..
				'<div class = "charLink survivorLink link">[[' .. name .. ']]</div>' ..
				'<div class = "charPerkBox">' .. resolveCharPerksMainPage(survivor) .. '</div>' ..
			'</div></div></div></div>'
	end
	result = result ..
		'</div>' ..
		'</div>'

	return result
end

function resolveCharPerksMainPage(character)
	local mPerks = require("Module:Perks")
	local result = ''
	local perkList = mPerks.getPerksByCharacter(character)
	
	utils.sortPerksByLevel(perkList)
	for _, perk in ipairs(perkList) do
		result = result .. '[[' .. cstr.file .. mPerks.getTeachablePerkIcon(perk) .. '|link=' .. perk.name .. '|42px]]'
	end
	
	return result
end
	
function resolveSurvPortraitImageFileName(surv)
	local fileConst = "_charSelect_portrait"
	return "S" .. string.format("%02d", surv.id) .. fileConst
end

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

function getSurvivorListWithPerks()
	local perkTable = {}
	for _,perk in ipairs(perks) do
		if perk.character ~= nil and perk.charType == 'S' then
			if perkTable[perk.character] == nil then
				perkTable[perk.character] = {}
			end
			perkTable[perk.character].id = perk.character
			perkTable[perk.character][#perkTable[perk.character]+1] = perk
		end
	end
	
	return perkTable
end

function p.resolveSurvivorsEntries()
	local perkTable = getSurvivorListWithPerks()
	local result = ""
	
	result = result .. '<div style="display: flex; flex-flow: row wrap; justify-content:center;">' .. nl
	
	for _, trio in ipairs(perkTable) do
		result = result .. '<div class = "entryTable">' .. nl ..
		'{| class = "wikitable"' .. nl
		
		survivor = getSurvivorById(trio.id)
		result = result .. '|+ ' .. survivor.name .. nl ..
		ntl .. nl ..
		'| rowspan = 3 | [[' .. cstr.file .. resolveSurvPortraitImageFileName(survivor) .. '.png|99px|link=' .. survivor.name .. ']]' .. nl
		utils.sortPerksByLevel(trio)
		for i, perk in ipairs(trio) do
			result = result .. '! [[' .. cstr.file .. perkImg.main(perk.techName or perk.name) .. '|33px]]' .. nl ..
			'! [[' .. perk.name .. ']]' .. nl ..
			'| ' .. utils.clr(perk.level, 6) .. nl
			if i < #trio then
				result = result .. ntl .. nl
			end
		end
		result = result .. '|}' .. nl ..
		'</div>' .. nl
	end
	
	result = result .. '</div>' .. nl
	
	mw.log(result)
	--mw.log(mw.dumpObject(perkTable))
	return result
end

return p