Dead by Daylight Wiki
 
(Nie pokazano 7 pośrednich wersji utworzonych przez tego samego użytkownika)
Linia 3: Linia 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 defaultSpeed = 4 --m/s | 100%
 
local defaultSpeed = 4 --m/s | 100%
local bar = "|" -- code for |
 
local nl = "\n"
 
local pg = "<p>" --paragraph
 
local ntl = "|-"
 
   
 
local strings = {
 
local strings = {
 
file = "Plik",
 
file = "Plik",
 
killers = "Zabójcy",
 
killers = "Zabójcy",
the = "",
+
the = "test",
 
unknownKiller = "UnknownKiller",
 
unknownKiller = "UnknownKiller",
 
realName = "Nazwa",
 
realName = "Nazwa",
Linia 52: Linia 51:
 
end
 
end
   
function getKillerIndexById(id) --not used
+
function p.getKillerById(id)
for i, s in ipairs(killers) do
+
for _, killer in ipairs(killers) do
if s.id == id then return i end
+
if killer.id == id then return killer end
 
end
 
end
return 0
+
return nil
 
end
 
end
   
 
function getKillerIdByName(name)
 
function getKillerIdByName(name)
 
for _, killer in ipairs(killers) do
 
for _, killer in ipairs(killers) do
if killer.realName ~= nil then
+
if killer.shortName == name or killer.realName == name or killer.name == name or cstr.the .. space .. killer.name == name then
if killer.realName == name then
+
return killer.id
return killer.id
 
end
 
else
 
if killer.name == name then -- ex.Demogorgon without a real name
 
return killer.id
 
end
 
 
end
 
end
 
end
 
end
 
 
 
return 0
 
return 0
  +
end
  +
  +
function p.getKillerNicknameByRealName(args, articleless)
  +
articleless = utils.bool(utils.resolveParameter(args, "articleless", true))
  +
name = utils.resolveParameter(args)
  +
for _, killer in ipairs(killers) do
  +
if killer.shortName == name or killer.realName == name or killer.name == name then
  +
return ((not articleless and strings.the .. space) or cstr.empty) .. killer.name
  +
end
  +
end
  +
return strings.unkwnKiller
 
end
 
end
   
 
function p.resolveKillerCharTable(name)
 
function p.resolveKillerCharTable(name)
  +
local dlcs = require("Module:DLCs")
 
name = utils.resolveParameter(name)
 
name = utils.resolveParameter(name)
 
killerId = getKillerIdByName(name)
 
killerId = getKillerIdByName(name)
Linia 86: Linia 91:
 
'{| class = "infoboxtable"' .. nl ..
 
'{| class = "infoboxtable"' .. nl ..
 
ntl ..' class = "infoboxTitle" | ' .. nl ..
 
ntl ..' class = "infoboxTitle" | ' .. nl ..
'! class = "center bold" colspan = 2 | ' .. strings.the .. killer.name .. nl .. --changed, because in polish we don't use determiners -Yupi
+
'! class = "center bold" colspan = 2 | ' .. killer.name .. nl .. ntl .. nl ..
ntl .. nl ..
 
 
 
 
-- '<tabber>' ..
 
-- '<tabber>' ..
Linia 98: Linia 102:
 
-- '</tabber>' ..
 
-- '</tabber>' ..
   
'! class = "center" colspan = 2 | [[' .. strings.file .. ':' .. resolveKillerPortraitImageFileName(killer) .. '.png|150px]]' .. nl ..
+
'! class = "center" colspan = 2 | ' .. link(cstr.file .. resolveKillerPortraitImageFileName(killer) .. '.png|150px') .. nl ..
 
ntl .. nl
 
ntl .. nl
 
if killer.realName ~= nil then
 
if killer.realName ~= nil then
result = result .. '| class = "titleColumn" | ' .. strings.realName .. ' || class = "valueColumn" | ' .. (killer.realName or strings.noName) .. nl .. ntl .. nl
+
result = result .. '| class = "titleColumn" | ' .. strings.realName .. ' || class = "valueColumn" | ' .. (killer.shortName or killer.realName or strings.noName) .. nl .. ntl .. nl
 
end
 
end
 
if killer.altName ~= nil then
 
if killer.altName ~= nil then
Linia 107: Linia 111:
 
end
 
end
 
result = result ..
 
result = result ..
'| class = "titleColumn" | ' .. strings.gender .. ' || class = "valueColumn" | ' .. utils.resolveGender(killer.gender) .. nl ..
+
'| class = "titleColumn" | ' .. strings.gender .. ' || class = "valueColumn" | ' .. utils.resolveGender(killer.gender) .. nl .. ntl .. nl ..
  +
'| class = "titleColumn" | ' .. strings.nationality .. ' || class = "valueColumn" | ' .. killer.nationality .. nl .. ntl .. nl
ntl .. nl ..
 
'| class = "titleColumn" | ' .. strings.nationality .. ' || class = "valueColumn" | ' .. killer.nationality .. nl ..
 
ntl .. nl
 
 
if killer.realm ~= nil or killer.dlc ~= nil then
 
if killer.realm ~= nil or killer.dlc ~= nil then
 
local killerRealm = resolveKillerRealm(killer)
 
local killerRealm = resolveKillerRealm(killer)
 
if killerRealm ~= 0 then
 
if killerRealm ~= 0 then
result = result .. '| class = "titleColumn" | ' .. strings.realm .. ' || class = "valueColumn" | [[' .. killerRealm .. ']] ' .. nl .. ntl .. nl
+
result = result .. '| class = "titleColumn" | ' .. link(strings.realm) .. ' || class = "valueColumn" | [[' .. killerRealm .. ']] ' .. nl .. ntl .. nl
 
end
 
end
 
end
 
end
 
result = result ..
 
result = result ..
'| class = "titleColumn" | ' .. strings.power .. ' || class = "valueColumn" | [[' .. killer.power .. ']]' .. nl ..
+
'| class = "titleColumn" | ' .. link(strings.power) .. ' || class = "valueColumn" | ' .. link(killer.power) .. nl .. ntl .. nl
ntl .. nl
 
 
if killer.specialAttack ~= nil then
 
if killer.specialAttack ~= nil then
 
result = result .. '| class = "titleColumn" | ' .. strings.powerType .. ' || class = "valueColumn" | ' .. resolvePowerAttack(killer) .. nl .. ntl .. nl
 
result = result .. '| class = "titleColumn" | ' .. strings.powerType .. ' || class = "valueColumn" | ' .. resolvePowerAttack(killer) .. nl .. ntl .. nl
 
end
 
end
 
result = result ..
 
result = result ..
'| class = "titleColumn" | ' .. strings.weapon .. ' || class = "valueColumn" | [[' .. killer.weapon .. ']]' .. nl ..
+
'| class = "titleColumn" | ' .. link(strings.weapon) .. ' || class = "valueColumn" | ' .. link(strings.weapons .. '#' .. killer.name .. tl .. killer.weapon) .. nl .. ntl .. nl ..
  +
'| class = "titleColumn" | ' .. utils.IconLink(strings.speed) .. ' || class = "valueColumn" | ' .. resolveKillerSpeed(killer) .. nl .. ntl .. nl
ntl .. nl ..
 
'| class = "titleColumn" | ' .. strings.speed .. ' || class = "valueColumn" | ' .. resolveKillerSpeed(killer) .. nl ..
 
ntl .. nl
 
 
if killer.altSpeed ~= nil then
 
if killer.altSpeed ~= nil then
 
result = result .. '| class = "titleColumn" | ' .. strings.altSpeed .. ' || class = "valueColumn" | ' .. resolveAltSpeed(killer) .. nl .. ntl .. nl
 
result = result .. '| class = "titleColumn" | ' .. strings.altSpeed .. ' || class = "valueColumn" | ' .. resolveAltSpeed(killer) .. nl .. ntl .. nl
 
end
 
end
 
result = result ..
 
result = result ..
'| class = "titleColumn" | ' .. strings.terror .. ' || class = "valueColumn" | ' .. resolveTerrorRadius(killer) .. nl ..
+
'| class = "titleColumn" | ' .. utils.IconLink(strings.terror) .. ' || class = "valueColumn" | ' .. resolveTerrorRadius(killer) .. nl .. ntl .. nl
  +
local altTerror = resolveAltTerrorRadius(killer)
ntl .. nl ..
 
  +
if altTerror then
'| class = "titleColumn" | ' .. strings.height .. ' || class = "valueColumn" | ' .. resolveHeight(killer) .. nl ..
 
  +
result = result .. '| class = "titleColumn" | ' .. strings.altTerror .. ' || class = "valueColumn" | ' .. altTerror .. nl .. ntl .. nl
ntl .. nl
 
  +
end
  +
local lullabyRadius = resolveLullabyRadius(killer)
  +
if lullabyRadius then
  +
result = result .. '| class = "titleColumn" | ' .. strings.lullabyRadius .. ' || class = "valueColumn" | ' .. lullabyRadius .. nl .. ntl .. nl
  +
end
  +
result = result ..
  +
'| class = "titleColumn" | ' .. strings.height .. space .. utils.IconLink(strings.height, "img") .. ' || class = "valueColumn" | ' .. resolveHeight(killer) .. nl .. ntl .. nl
 
if killer.dlc ~= nil then
 
if killer.dlc ~= nil then
result = result .. '| class = "titleColumn" | ' .. strings.dlc .. ' || class = "valueColumn" | [[' .. getDlcById(killer.dlc).name .. ']] ' .. nl .. ntl .. nl
+
result = result .. '| class = "titleColumn" | ' .. strings.dlc .. ' || class = "valueColumn" | ' .. link(dlcs.getDlcById(killer.dlc).name) .. space .. nl .. ntl .. nl
 
end
 
end
 
result = result ..
 
result = result ..
'| class = "titleColumn" | ' .. strings.actor .. ' || class = "valueColumn" | ' .. (killer.actor or strings.uknownActor) .. nl ..
+
'| class = "titleColumn" | ' .. strings.actor .. ' || class = "valueColumn" | ' .. resolveActor(killer) .. nl .. ntl .. nl ..
  +
'| class = "titleColumn center" colspan = 2 | ' .. strings.breathing .. nl .. ntl .. nl ..
--TODO Check all music existence, this should be in separate table, Twinsuse Twins as a reference
 
  +
'| class = "valueColumn center soundColumn" colspan = 2 | ' .. link(cstr.file .. (killer.techName or killer.name) .. space .. 'Breathing' .. dot .. cstr.ogg) .. nl
ntl .. nl ..
 
  +
local altBreathing = resolveAltBreathing(killer)
'| class = "titleColumn center" colspan = 2 | ' .. strings.breathing .. nl ..
 
  +
if altBreathing then
ntl .. nl ..
 
'| class = "valueColumn" | ' .. "Breathing" .. nl ..
+
result = result .. ntl .. nl ..
  +
tl .. ' class = "titleColumn center" colspan = 2 ' .. tl .. strings.altBreathing .. nl .. ntl .. nl ..
ntl .. nl ..
 
'| class = "titleColumn center" colspan = 2 | ' .. strings.menuMusic .. nl ..
+
tl .. ' class = "valueColumn center soundColumn" colspan = 2 ' .. tl .. altBreathing .. nl
  +
end
ntl .. nl ..
 
  +
local theme = resolveKillerThemeMusic(killer)
'| class = "valueColumn" | ' .. "Menu Music" .. nl ..
 
  +
if theme then
ntl .. nl ..
 
  +
result = result .. ntl .. nl ..
'| class = "titleColumn center" colspan = 2 | ' .. strings.terrorMusic .. nl ..
 
  +
'| class = "titleColumn center" colspan = 2 | ' .. strings.menuMusic .. nl .. ntl .. nl ..
ntl .. nl ..
 
'| class = "valueColumn" | ' .. "Terror Radius Music" .. nl ..
+
'| class = "valueColumn center soundColumn" colspan = 2 | ' .. theme .. nl
  +
end
ntl .. nl ..
 
  +
local terrorMusic = resolveTRMusic(killer)
'| class = "titleColumn center" colspan = 2 | ' .. strings.lullaby .. nl ..
 
  +
if terrorMusic then
ntl .. nl ..
 
'| class = "valueColumn" | ' .. "Lullaby" .. nl ..
+
result = result .. ntl .. nl ..
  +
'| class = "titleColumn center" colspan = 2 | ' .. strings.terrorMusic .. nl .. ntl .. nl ..
'|}'
 
  +
'| class = "valueColumn center soundColumn" colspan = 2 | ' .. terrorMusic .. nl
  +
end
  +
  +
local lullaby = resolveLullaby(killer, 1)
  +
local counter = ((lullaby and 1) or 0) --if you find a lullaby then set the counter to 1, otherwise 0
  +
local tempResult = cstr.empty
  +
while lullaby do
  +
tempResult = tempResult .. ntl .. nl ..
  +
'| class = "valueColumn center soundColumn" colspan = 2 | ' .. lullaby .. nl
  +
  +
counter = counter + 1
  +
lullaby = resolveLullaby(killer, counter)
  +
end
 
 
  +
if counter > 0 then --if lullaby was found
  +
result = result .. ntl .. nl .. '| class = "titleColumn center" colspan = 2 | ' .. ((counter > 2 and strings.lullabies) or strings.lullaby) .. nl .. tempResult
  +
end
  +
  +
result = result .. '|}'
 
 
 
mw.log(result)
 
mw.log(result)
 
return result
 
return result
  +
end
  +
  +
function resolveAltTerrorRadius(killer)
  +
if not killer.altRadius then return false end
  +
local result = killer.altRadius
  +
if type(killer.altRadius) == "table" then
  +
result = cstr.empty
  +
for i, radius in ipairs(killer.altRadius) do
  +
result = result .. radius[1] .. space .. brackets(radius[2]) .. ((i < #killer.altRadius and dnl) or cstr.empty)
  +
end
  +
end
  +
return result
  +
end
  +
  +
function resolveActor(killer)
  +
local result = strings.uknownActor
 
 
  +
if type(killer.actor) == "string" then
  +
result = killer.actor
  +
elseif type(killer.actor) == "table" then
  +
result = cstr.empty
  +
for i, actor in ipairs(killer.actor) do
  +
result = result .. actor .. ((i < #killer.actor and dnl) or cstr.empty)
  +
end
  +
end
  +
return result
  +
end
  +
  +
function resolveLullabyRadius(killer)
  +
if not killer.lullabyRadius then return false end
  +
local result = cstr.empty
 
 
  +
if type(killer.lullabyRadius) == "table" then
  +
for i, lullaby in ipairs(killer.lullabyRadius) do
  +
result = result .. lullaby[1] .. space .. strings.metres .. space .. brackets(lullaby[2])
  +
if i < #killer.lullabyRadius then
  +
result = result .. dnl
  +
end
  +
end
  +
else
  +
result = (killer.lullabyRadius and killer.lullabyRadius .. space ..strings.metres) or cstr.empty
  +
end
  +
  +
return result
  +
end
  +
  +
function resolveAltBreathing(killer, index)
  +
file = (killer.techName or killer.name) .. space .. 'Breathing' .. space .. (index or 2)
  +
valid = utils.isValidFileName(file, cstr.ogg)
  +
return (valid and link(cstr.file .. file .. dot .. cstr.ogg)) or valid
  +
end
  +
  +
function resolveKillerThemeMusic(killer)
  +
local dlcs = require("Module:DLCs")
  +
local dlc = dlcs.getDlcById(killer.dlc)
  +
local fileConst = '_Theme_Music'
  +
local file = cstr.empty
  +
if not killer.dlc then
  +
file = killer.techName or killer.name
  +
else
  +
file = utils.resolveFileName(utils.CapitalizeName(dlc.name), true, true)
  +
end
  +
file = (file or cstr.empty) .. fileConst
  +
local valid = utils.isValidFileName(file, cstr.ogg)
  +
return (valid and link(cstr.file .. file .. dot .. cstr.ogg)) or valid
  +
end
  +
  +
function resolveTRMusic(killer)
  +
file = 'TerrorRadius_' .. (killer.techName or killer.name)
  +
local valid = utils.isValidFileName(file, cstr.ogg)
  +
return (valid and link(cstr.file .. file .. dot .. cstr.ogg)) or valid
  +
end
  +
  +
function resolveLullaby(killer, index)
  +
file = (killer.techName or killer.name) .. space .. 'Lullaby' .. ((index and space .. index) or cstr.empty)
  +
valid = utils.isValidFileName(file, cstr.ogg)
  +
return (valid and link(cstr.file .. file .. dot .. cstr.ogg)) or valid
 
end
 
end
   
  +
--addon is for cosmetics portraits (used in Module:Cosmetics)
function resolveKillerPortraitImageFileName(killer)
 
  +
function resolveKillerPortraitImageFileName(killer, addon)
 
local fileConst = "_charSelect_portrait"
 
local fileConst = "_charSelect_portrait"
return "K" .. string.format("%02d", killer.id) .. fileConst
+
return "K" .. string.format("%02d", killer.id) .. ((addon and space .. addon) or cstr.empty) .. fileConst
 
end
 
end
   
Linia 179: Linia 279:
 
result = result .. '"' .. name .. '"'
 
result = result .. '"' .. name .. '"'
 
if i < #killer.altName then
 
if i < #killer.altName then
result = result .. nl
+
result = result .. dnl
 
end
 
end
 
end
 
end
Linia 213: Linia 313:
 
if type(realm.dlc) == "number" and killer.dlc == realm.dlc then return realm.name
 
if type(realm.dlc) == "number" and killer.dlc == realm.dlc then return realm.name
 
elseif type(realm.dlc) == "table" then
 
elseif type(realm.dlc) == "table" then
for i, dlc in ipairs(killer) do
+
for _, dlcId in ipairs(realm.dlc) do
if dlc.id == dlc[i] then return realm.name end
+
if dlcId == killer.dlc then return realm.name end
 
end
 
end
 
end
 
end
Linia 223: Linia 323:
   
 
function resolveKillerSpeed(killer)
 
function resolveKillerSpeed(killer)
local speedPercent = 0
+
local result = cstr.empty
local speedMps = 0
 
local note
 
local result
 
 
 
 
if type(killer.speed) == "number" then
 
if type(killer.speed) == "number" then
  +
result = getPercentSpeed(killer.speed) .. space .. '%' .. space .. b(bar) .. space .. killer.speed .. space .. strings.mps
speedPercent = killer.speed
 
speedMps = defaultSpeed * (killer.speed / 100) --speed is in percentage
 
 
else --so the killer speed is table
 
else --so the killer speed is table
  +
result = getPercentSpeed(killer.speed[1]) .. space .. '%' .. space .. b(bar) .. space .. killer.speed[1] .. space .. strings.mps .. space .. brackets(killer.speed[2])
speedPercent = killer.speed[1]
 
speedMps = defaultSpeed * (killer.speed[1] / 100)
 
note = killer.speed[2]
 
 
end
 
end
  +
 
result = speedPercent .. " % <b>" .. bar .. "</b> " .. speedMps .. " " .. strings.mps
 
if note ~= nil then
 
result = result .. nl .. "(" .. note .. ")"
 
end
 
 
 
return result
 
return result
 
end
 
end
Linia 247: Linia 336:
 
function resolveAltSpeed(killer)
 
function resolveAltSpeed(killer)
 
local result = ""
 
local result = ""
local speedMps
+
local speedPercent
 
 
 
for i, altSpeed in ipairs(killer.altSpeed) do
 
for i, altSpeed in ipairs(killer.altSpeed) do
speedMps = defaultSpeed * (altSpeed[1] / 100)
+
speedPercent = getPercentSpeed(altSpeed[1])
 
 
result = result .. altSpeed[1] .. " % <b>" .. bar .. "</b> " .. speedMps .. " " .. strings.mps
+
result = result .. speedPercent .. " % " .. b(bar) .. space .. altSpeed[1] .. space .. strings.mps
 
if altSpeed[2] ~= nil then
 
if altSpeed[2] ~= nil then
 
result = result .. pg .. "(" .. altSpeed[2] .. ")"
 
result = result .. pg .. "(" .. altSpeed[2] .. ")"
Linia 263: Linia 352:
 
 
 
return result
 
return result
  +
end
  +
  +
function getPercentSpeed(speed)
  +
return (speed / _defaultSpeed) * 100
 
end
 
end
   
Linia 269: Linia 362:
 
 
 
if type(killer.radius) == "number" then
 
if type(killer.radius) == "number" then
return killer.radius .. " " .. strings.metres
+
return killer.radius .. space .. strings.metres
 
elseif type(killer.radius) == "table" then
 
elseif type(killer.radius) == "table" then
 
for i, radius in ipairs(killer.radius) do
 
for i, radius in ipairs(killer.radius) do
Linia 277: Linia 370:
 
result = result .. radius[1] --metres value
 
result = result .. radius[1] --metres value
 
if radius[2] ~= nil then --note for alt speed, if there is a note for the speed the abbreviation for metres is used instead of full name
 
if radius[2] ~= nil then --note for alt speed, if there is a note for the speed the abbreviation for metres is used instead of full name
result = result .. strings.m .. " (" .. radius[2] .. ")"
+
result = result .. strings.m .. space .. brackets(radius[2])
 
else
 
else
 
result = result .. " " .. strings.metres
 
result = result .. " " .. strings.metres
Linia 304: Linia 397:
 
local fileName
 
local fileName
   
result = result .. "<div style=\"color: #fff;\">"
+
result = result .. '<div style="color: #fff;">'
  +
maxId = utils.getMaxId(killers)
 
for i, killer in ipairs(killers) do
 
for i, killer in ipairs(killers) do
 
name = killer.shortName or killer.realName or killer.name
 
name = killer.shortName or killer.realName or killer.name
fileName = resolveKillersPortraitFileNameById(killer.id)
+
fileName = utils.resolveCharacterPortraitFileName(killer, maxId)
 
 
  +
result = result ..
result = result .. "<div style=\"display: inline-block; text-align:center; margin: 10px\">[[" .. name .. "]] - " .. killer.name
 
result = result .. "[[File:" .. fileName .. ".png|center|frameless|link=" .. strings.the .. " " .. killer.name .. "]]</div>"
+
'<div style="display: inline-block; text-align:center; margin: 10px">' .. link(name) .. ' - ' .. killer.name ..
  +
link(cstr.file .. fileName .. '.png|center|frameless|link=' .. killer.name) .. '</div>'
 
 
end
 
end
result = result .. "</div>"
+
result = result .. '</div>'
   
 
return result
 
return result
Linia 323: Linia 417:
 
local fileName
 
local fileName
   
result = result .. "<div class=\"fpbox\" id=\"fpkiller\" style=\"text-align: center;\">"
+
result = result ..
  +
'<div class = "fpbox" id = "fpkiller" style = "text-align: center;">' ..
result = result .. "<div class=\"heading\">[[" .. strings.killers .. "]] [[File:IconHelpLoading killer.png|32px]]</div>" --changed to fit pl version -Yupi
 
  +
'<div class = "heading">' .. link(strings.killers) .. space .. link(cstr.file .. 'IconHelpLoading killer.png|32px') .. '</div>' ..
result = result .. "<div class=\"fplinks\">"
 
  +
'<div class = "fplinks charSection">'
for i, killer in ipairs(killers) do
 
 
 
  +
maxId = utils.getMaxId(killers)
fileName = resolveKillersPortraitFileNameById(killer.id)
 
  +
for i, killer in ipairs(killers) do
  +
fileName = utils.resolveCharacterPortraitFileName(killer, maxId)
 
 
  +
result = result ..
result = result .. "<div class=\"fplink plainlinks image\"><div class=\"box\"><div class=\"row\"><div class=\"cell\">"
 
  +
'<div class = "fplink charMainPageBox plainlinks image"><div class="box"><div class="row"><div class="cell">' ..
result = result .. "<div class=\"image\">[[File:" .. fileName .. ".png|link=" .. strings.the .. " " .. killer.name .. "]]</div>"
 
result = result .. "<div class=\"charLink killerLink link\">[[" .. strings.the .. " " .. killer.name .. "]]</div></div></div></div></div>"
+
'<div class = "image">' .. link(cstr.file .. fileName .. '.png|link=' .. killer.name) .. '</div>' ..
  +
'<div class = "charLink killerLink link">' .. link(killer.name) .. '</div>' ..
  +
'<div class = "charPerkBox">' .. resolveCharPerksMainPage(killer) .. '</div>' ..
  +
'</div></div></div></div>'
 
end
 
end
result = result .. "</div>"
+
result = result ..
  +
'</div>' ..
result = result .. "</div>"
 
  +
'</div>'
   
 
return result
 
return result
 
end
 
end
   
function resolveKillersPortraitFileNameById(id)
+
function resolveCharPerksMainPage(character)
local fileConst = "_charPreview_portrait"
+
local mPerks = require("Module:Perks")
local fileName
+
local result = ''
  +
local perkList = mPerks.getPerksByCharacter(character)
 
 
  +
utils.sortPerksByLevel(perkList)
fileName = getFileNameFromTableById(id) --get custom name from table
 
  +
for _, perk in ipairs(perkList) do
if not utils.isValidFileName(fileName) then --K{ID}_charPreview_portrait
 
  +
result = result .. link(cstr.file .. mPerks.getTeachablePerkIcon(perk) .. '|link=' .. perk.name .. '|42px')
fileName = "K" .. string.format("%02d", id) .. fileConst
 
 
end
 
end
  +
if not utils.isValidFileName(fileName) then --File not Found
 
  +
return result
fileName = strings.unknownKiller .. fileConst
 
end
 
 
mw.log(fileName)
 
return fileName
 
 
end
 
end
   
function getFileNameFromTableById(id)
+
function getKillerListWithPerks()
  +
local perkTable = {}
mw.log(id)
 
for j, sImage in ipairs(killerImages) do
+
for _,perk in ipairs(perks) do
if sImage.id == id then
+
if perk.character ~= nil and perk.charType == 'K' then
  +
if perkTable[perk.character] == nil then
return sImage.preview
 
  +
perkTable[perk.character] = {}
  +
end
  +
perkTable[perk.character].id = perk.character
  +
perkTable[perk.character][#perkTable[perk.character]+1] = perk
 
end
 
end
 
end
 
end
  +
return ""
 
  +
return perkTable
 
end
 
end
   
function getDlcById(id)
+
function p.resolveKillersEntries()
  +
local perkTable = getKillerListWithPerks()
for _, dlc in ipairs(dlcs) do
 
  +
local result = ""
if dlc.id == id then return dlc end
 
  +
  +
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
  +
  +
killer = p.getKillerById(trio.id)
  +
result = result .. '|+ ' .. killer.name .. nl ..
  +
ntl .. nl ..
  +
'| rowspan = 3 | [[' .. cstr.file .. resolveKillerPortraitImageFileName(killer) .. '.png|99px|link=' .. (killer.shortName or killer.realName or killer.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
 
end
  +
  +
result = result .. '</div>' .. nl
  +
  +
--mw.log(result)
  +
--mw.log(mw.dumpObject(perkTable))
  +
return result
 
end
 
end
   

Aktualna wersja na dzień 14:33, 17 sty 2022


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()
local defaultSpeed = 4 --m/s | 100%

local strings = {
	file = "Plik",
	killers = "Zabójcy",
	the = "test",
	unknownKiller = "UnknownKiller",
	realName = "Nazwa",
	noName = "Brak", --When the killer doesn't have the real name (ex. Demogorgon)
	altName = "Alias",
	gender = "Płeć",
	nationality = "Narodowość",
	realm = "Lokacja", --link
	power = "Moc", --link
	powerType = "Typ Mocy [[Atak|Ataku]]",
	spAttackTrue = "Specjalny Atak",
	spAttackFalse = "Podstawowy Atak",
	weapon = "Broń",
	speed = "Prędkość Ruchu", --iconlink
	altSpeed = "Alternatywna Prędkość ruchu",
	metres = "metrów",
	m = "m", --abbreviation of metres
	terror = "Zasięg Terroru", --iconlink
	lullabyRadius = "Zasięg [[Kołysanka|Kołysanki]]",
	height = "Wzrost", --image
	tall = "Wysoki",
	avg = "Średni",
	dlc = "DLC",
	actor = "Aktor Głosowy",
	breathing = "Oddech",
	altBreathing = "Alternatywny Oddech",
	menuMusic = "Muzyka Menu",
	terrorMusic = "Muzyka Zasięgu Terroru",
	lullaby = "Kołysanka",
	lullabies = "Kołysanki",

	mps = "m/s",
	err = "Error"
}

function p.getCountOfKillers()
	return utils.getCount("killer")
end

function p.getKillerById(id)
	for _, killer in ipairs(killers) do
		if killer.id == id then return killer end
	end
	return nil
end

function getKillerIdByName(name) 
	for _, killer in ipairs(killers) do
		if killer.shortName == name or killer.realName == name or killer.name == name or cstr.the .. space .. killer.name == name then
			return killer.id
		end
	end
	
	return 0
end

function p.getKillerNicknameByRealName(args, articleless)
	articleless = utils.bool(utils.resolveParameter(args, "articleless", true))
	name = utils.resolveParameter(args)
	for _, killer in ipairs(killers) do
		if killer.shortName == name or killer.realName == name or killer.name == name then
			return ((not articleless and strings.the .. space) or cstr.empty) .. killer.name
		end
	end
	return strings.unkwnKiller
end

function p.resolveKillerCharTable(name)
	local dlcs = require("Module:DLCs")
	name = utils.resolveParameter(name)
	killerId = getKillerIdByName(name)
	killer = utils.getCharacterById(killerId, killers)
	reuslt = ""
	
	if type(killer) ~= "table" then return killer end
	
	result = 
	'{| class = "infoboxtable"' .. nl ..
	ntl ..' class = "infoboxTitle" | ' .. nl ..
	'! class = "center bold" colspan = 2 | ' .. killer.name .. nl .. ntl .. nl ..
	
--	'<tabber>' ..
--	'|-|First=' ..
--	'First tab sample text.' ..
--	'|-|Second=' ..
--	'Second tab content goes here. ' ..
--	'|-|Third Tab Title=' ..
--	'Third tab content goes here.' ..
--	'</tabber>' ..

	'! class = "center" colspan = 2 | ' .. link(cstr.file .. resolveKillerPortraitImageFileName(killer) .. '.png|150px') .. nl ..
	ntl .. nl
	if killer.realName ~= nil then
		result = result .. '| class = "titleColumn" | ' .. strings.realName .. ' || class = "valueColumn" | ' .. (killer.shortName or killer.realName or strings.noName) .. nl .. ntl .. nl
	end
	if killer.altName ~= nil then
		result = result .. '| class = "titleColumn" | ' .. strings.altName .. ' || class = "valueColumn italic" | ' .. resolveAltName(killer) .. nl .. ntl .. nl
	end
	result = result ..
	'| class = "titleColumn" | ' .. strings.gender .. ' || class = "valueColumn" | ' .. utils.resolveGender(killer.gender) .. nl .. ntl .. nl ..
	'| class = "titleColumn" | ' .. strings.nationality .. ' || class = "valueColumn" | ' .. killer.nationality .. nl .. ntl .. nl
	if killer.realm ~= nil or killer.dlc ~= nil then
		local killerRealm = resolveKillerRealm(killer)
		if killerRealm ~= 0 then
			result = result .. '| class = "titleColumn" | ' .. link(strings.realm) .. ' || class = "valueColumn" | [[' .. killerRealm .. ']] ' .. nl .. ntl .. nl
		end
	end
	result = result ..
	'| class = "titleColumn" | ' .. link(strings.power) .. ' || class = "valueColumn" | ' .. link(killer.power) .. nl .. ntl .. nl
	if killer.specialAttack ~= nil then
		result = result .. '| class = "titleColumn" | ' .. strings.powerType .. ' || class = "valueColumn" | ' .. resolvePowerAttack(killer) .. nl .. ntl .. nl
	end
	result = result ..
	'| class = "titleColumn" | ' .. link(strings.weapon) .. ' || class = "valueColumn" | ' .. link(strings.weapons .. '#' .. killer.name .. tl .. killer.weapon) .. nl .. ntl .. nl ..
	'| class = "titleColumn" | ' .. utils.IconLink(strings.speed) .. ' || class = "valueColumn" | ' .. resolveKillerSpeed(killer) .. nl .. ntl .. nl
	if killer.altSpeed ~= nil then
		result = result .. '| class = "titleColumn" | ' .. strings.altSpeed .. ' || class = "valueColumn" | ' .. resolveAltSpeed(killer) .. nl .. ntl .. nl
	end
	result = result ..
	'| class = "titleColumn" | ' .. utils.IconLink(strings.terror) .. ' || class = "valueColumn" | ' .. resolveTerrorRadius(killer) .. nl .. ntl .. nl
	local altTerror = resolveAltTerrorRadius(killer)
	if altTerror then
		result = result .. '| class = "titleColumn" | ' .. strings.altTerror .. ' || class = "valueColumn" | ' .. altTerror .. nl .. ntl .. nl		
	end
	local lullabyRadius = resolveLullabyRadius(killer)
	if lullabyRadius then
		result = result .. '| class = "titleColumn" | ' .. strings.lullabyRadius .. ' || class = "valueColumn" | ' .. lullabyRadius .. nl .. ntl .. nl
	end
	result = result ..
	'| class = "titleColumn" | ' .. strings.height .. space .. utils.IconLink(strings.height, "img") .. ' || class = "valueColumn" | ' .. resolveHeight(killer) .. nl .. ntl .. nl
	if killer.dlc ~= nil then
		result = result .. '| class = "titleColumn" | ' .. strings.dlc .. ' || class = "valueColumn" | ' .. link(dlcs.getDlcById(killer.dlc).name) .. space .. nl .. ntl .. nl
	end
	result = result ..
	'| class = "titleColumn" | ' .. strings.actor .. ' || class = "valueColumn" | ' .. resolveActor(killer) .. nl .. ntl .. nl ..
	'| class = "titleColumn center" colspan = 2 | ' .. strings.breathing .. nl .. ntl .. nl ..
	'| class = "valueColumn center soundColumn" colspan = 2 | ' .. link(cstr.file .. (killer.techName or killer.name) .. space .. 'Breathing' .. dot .. cstr.ogg) .. nl
	local altBreathing = resolveAltBreathing(killer)
	if altBreathing then 
		result = result .. ntl .. nl ..
		tl .. ' class = "titleColumn center" colspan = 2 ' .. tl .. strings.altBreathing .. nl .. ntl .. nl ..
		tl .. ' class = "valueColumn center soundColumn" colspan = 2 ' .. tl .. altBreathing .. nl
	end
	local theme = resolveKillerThemeMusic(killer)
	if theme then
		result = result .. ntl .. nl ..
		'| class = "titleColumn center" colspan = 2 | ' .. strings.menuMusic .. nl .. ntl .. nl ..
		'| class = "valueColumn center soundColumn" colspan = 2 | ' .. theme .. nl
	end
	local terrorMusic = resolveTRMusic(killer)
	if terrorMusic then
		result = result .. ntl .. nl ..
		'| class = "titleColumn center" colspan = 2 | ' .. strings.terrorMusic .. nl ..	ntl .. nl ..
		'| class = "valueColumn center soundColumn" colspan = 2 | ' .. terrorMusic .. nl
	end

	local lullaby = resolveLullaby(killer, 1)
	local counter = ((lullaby and 1) or 0) --if you find a lullaby then set the counter to 1, otherwise 0
	local tempResult = cstr.empty
	while lullaby do
		tempResult = tempResult .. ntl .. nl ..
		'| class = "valueColumn center soundColumn" colspan = 2 | ' .. lullaby .. nl
		
		counter = counter + 1
		lullaby = resolveLullaby(killer, counter)
	end
	
	if counter > 0 then --if lullaby was found
		result = result .. ntl .. nl .. '| class = "titleColumn center" colspan = 2 | ' .. ((counter > 2 and strings.lullabies) or strings.lullaby) .. nl .. tempResult
	end
	
	result = result .. '|}'
	
	mw.log(result)
	return result
end

function resolveAltTerrorRadius(killer)
	if not killer.altRadius then return false end
	local result = killer.altRadius
	if type(killer.altRadius) == "table" then
		result = cstr.empty
		for i, radius in ipairs(killer.altRadius) do
			result = result .. radius[1] .. space .. brackets(radius[2]) .. ((i < #killer.altRadius and dnl) or cstr.empty)
		end
	end
	return result
end

function resolveActor(killer)
	local result = strings.uknownActor
	
	if type(killer.actor) == "string" then
		result = killer.actor
	elseif type(killer.actor) == "table" then
		result = cstr.empty
		for i, actor in ipairs(killer.actor) do
			result = result .. actor .. ((i < #killer.actor and dnl) or cstr.empty)
		end
	end
	return result
end

function resolveLullabyRadius(killer)
	if not killer.lullabyRadius then return false end
	local result = cstr.empty
	
	if type(killer.lullabyRadius) == "table" then
		for i, lullaby in ipairs(killer.lullabyRadius) do
			result = result .. lullaby[1] .. space .. strings.metres .. space .. brackets(lullaby[2])
			if i < #killer.lullabyRadius then
				result = result .. dnl
			end
		end
	else
		result = (killer.lullabyRadius and killer.lullabyRadius .. space ..strings.metres) or cstr.empty
	end
	
	return result
end

function resolveAltBreathing(killer, index)
	file = (killer.techName or killer.name) .. space .. 'Breathing' .. space .. (index or 2)
	valid = utils.isValidFileName(file, cstr.ogg)
	return (valid and link(cstr.file .. file .. dot .. cstr.ogg)) or valid
end

function resolveKillerThemeMusic(killer)
	local dlcs = require("Module:DLCs")
	local dlc = dlcs.getDlcById(killer.dlc)
	local fileConst = '_Theme_Music'
	local file = cstr.empty
	if not killer.dlc then
		file = killer.techName or killer.name
	else
		file = utils.resolveFileName(utils.CapitalizeName(dlc.name), true, true)
	end
	file = (file or cstr.empty) .. fileConst
	local valid = utils.isValidFileName(file, cstr.ogg)
	return (valid and link(cstr.file .. file .. dot .. cstr.ogg)) or valid
end

function resolveTRMusic(killer)
	file = 'TerrorRadius_' .. (killer.techName or killer.name)
	local valid = utils.isValidFileName(file, cstr.ogg)
	return (valid and link(cstr.file .. file .. dot .. cstr.ogg)) or valid
end

function resolveLullaby(killer, index)
	file = (killer.techName or killer.name) .. space .. 'Lullaby' .. ((index and space .. index) or cstr.empty)
	valid = utils.isValidFileName(file, cstr.ogg)
	return (valid and link(cstr.file .. file .. dot .. cstr.ogg)) or valid
end

--addon is for cosmetics portraits (used in Module:Cosmetics)
function resolveKillerPortraitImageFileName(killer, addon)
	local fileConst = "_charSelect_portrait"
	return "K" .. string.format("%02d", killer.id) .. ((addon and space .. addon) or cstr.empty) .. fileConst
end

function resolveAltName(killer)
	if type(killer.altName) == "string" then return '"' .. killer.altName .. '"'
	elseif type(killer.altName) == "table" then
		local result = ""
		for i, name in ipairs(killer.altName) do
			result = result .. '"' .. name .. '"'
			if i < #killer.altName then 
				result = result .. dnl
			end
		end
		return result
	end
	
	return strings.err
end

function resolvePowerAttack(killer)
	result = ""
	
	if killer.specialAttack then 
		result = strings.spAttackTrue
	else
		result = strings.spAttackFalse
	end
	
	if killer.altAttackNote ~= nil then
		result = result .. nl .. "(" .. killer.altAttackNote .. ")"
	end
	
	return result
end

function resolveKillerRealm(killer)
	if killer.dlc == nil then
		for _, realm in ipairs(realms) do
			if realm.id == killer.realm then return realm.name end
		end
	else
		for _, realm in ipairs(realms) do
			if type(realm.dlc) == "number" and killer.dlc == realm.dlc then return realm.name
			elseif type(realm.dlc) == "table" then
				for _, dlcId in ipairs(realm.dlc) do
					if dlcId == killer.dlc then return realm.name end
				end
			end
		end
	end
	return 0
end

function resolveKillerSpeed(killer)
	local result = cstr.empty
	
	if type(killer.speed) == "number" then
		result = getPercentSpeed(killer.speed) .. space .. '%' .. space .. b(bar) .. space .. killer.speed .. space .. strings.mps
	else --so the killer speed is table
		result = getPercentSpeed(killer.speed[1]) .. space .. '%' .. space .. b(bar) .. space .. killer.speed[1] .. space .. strings.mps .. space .. brackets(killer.speed[2])
	end

	return result
end

function resolveAltSpeed(killer)
	local result = ""
	local speedPercent
	
	for i, altSpeed in ipairs(killer.altSpeed) do
		speedPercent = getPercentSpeed(altSpeed[1])
		
		result = result .. speedPercent .. " % " .. b(bar) .. space .. altSpeed[1] .. space .. strings.mps
		if altSpeed[2] ~= nil then
			result = result .. pg .. "(" .. altSpeed[2] .. ")"
		end
		
		if i < #killer.altSpeed then 
			result = result .. "<hr>" --.. nl .. nl
		end
	end
	
	return result
end

function getPercentSpeed(speed)
	return (speed / _defaultSpeed) * 100
end

function resolveTerrorRadius(killer)
	result = ""
	
	if type(killer.radius) == "number" then
		return killer.radius .. space .. strings.metres
	elseif type(killer.radius) == "table" then
		for i, radius in ipairs(killer.radius) do
			if radius[3] ~= nil then --open span with title hover
				result = result .. '<span class = "valueTooltip" title = "' .. radius[3] .. '">'
			end
			result = result .. radius[1] --metres value
			if radius[2] ~= nil then --note for alt speed, if there is a note for the speed the abbreviation for metres is used instead of full name
				result = result .. strings.m .. space .. brackets(radius[2])
			else
				result = result .. " " .. strings.metres
			end
			if radius[3] ~= nil then --close span hover
				result = result .. '</span>'
			end
			if i < #killer.radius then 
				result = result .. nl .. nl
			end
		end
	end
	return result
end

function resolveHeight(killer)
	if		killer.height == 'T'	then return strings.tall
	elseif	killer.height == 'A'	then return strings.avg
	else								 return strings.err
	end
end

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

	result = result .. '<div style="color: #fff;">'
	maxId = utils.getMaxId(killers)
	for i, killer in ipairs(killers) do
		name = killer.shortName or killer.realName or killer.name
		fileName = utils.resolveCharacterPortraitFileName(killer, maxId)
		
		result = result .. 
			'<div style="display: inline-block; text-align:center; margin: 10px">' .. link(name) .. ' - ' .. killer.name ..
			link(cstr.file .. fileName .. '.png|center|frameless|link=' .. killer.name) .. '</div>'
	end
	result = result .. '</div>'

	return result
end

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

	result = result .. 
		'<div class = "fpbox" id = "fpkiller" style = "text-align: center;">' ..
		'<div class = "heading">' .. link(strings.killers) .. space .. link(cstr.file .. 'IconHelpLoading killer.png|32px') .. '</div>' ..
		'<div class = "fplinks charSection">'
		
	maxId = utils.getMaxId(killers)
	for i, killer in ipairs(killers) do
		fileName = utils.resolveCharacterPortraitFileName(killer, maxId)
		
		result = result .. 
		'<div class = "fplink charMainPageBox plainlinks image"><div class="box"><div class="row"><div class="cell">' ..
			'<div class = "image">' .. link(cstr.file .. fileName .. '.png|link=' .. killer.name) .. '</div>' ..
			'<div class = "charLink killerLink link">' .. link(killer.name) .. '</div>' .. 
			'<div class = "charPerkBox">' .. resolveCharPerksMainPage(killer) .. '</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 .. link(cstr.file .. mPerks.getTeachablePerkIcon(perk) .. '|link=' .. perk.name .. '|42px')
	end
	
	return result
end

function getKillerListWithPerks()
	local perkTable = {}
	for _,perk in ipairs(perks) do
		if perk.character ~= nil and perk.charType == 'K' 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.resolveKillersEntries()
	local perkTable = getKillerListWithPerks()
	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
		
		killer = p.getKillerById(trio.id)
		result = result .. '|+ ' .. killer.name .. nl ..
		ntl .. nl ..
		'| rowspan = 3 | [[' .. cstr.file .. resolveKillerPortraitImageFileName(killer) .. '.png|99px|link=' .. (killer.shortName or killer.realName or killer.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