Module:Killers

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 strings = { killers = "Killers", the = "The", unknownKiller = "UnknownKiller" }

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

function getKillerIndexById(id) for i, s in ipairs(killers) do		if s.id == id then return i end end return 0 end

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

result = result .. "" for i, killer in ipairs(killers) do		name = killer.shortName or killer.realName or killer.name fileName = resolveKillersPortraitFileNameById(killer.id) result = result .. "" .. name .. " - " .. killer.name result = result .. " "

end result = result .. " "

return result end

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

result = result .. "" result = result .. "The " .. strings.killers .. " " result = result .. "" for i, killer in ipairs(killers) do		fileName = resolveKillersPortraitFileNameById(killer.id) result = result .. "" result = result .. " " result = result .. "" .. strings.the .. " " .. killer.name .. "    " end result = result .. " "	result = result .. " "

return result end

function resolveKillersPortraitFileNameById(id) local fileConst = "_charPreview_portrait" local fileName fileName = getFileNameFromTableById(id) --get custom name from table if not utils.isValidFileName(fileName) then --K{ID}_charPreview_portrait fileName = "K" .. string.format("%02d", id) .. fileConst end if not utils.isValidFileName(fileName) then --File not Found fileName = strings.unknownKiller .. fileConst end

mw.log(fileName) return fileName end

function getFileNameFromTableById(id) mw.log(id) for j, sImage in ipairs(killerImages) 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