Dead by Daylight Wiki
mNo edit summary
mNo edit summary
Line 48: Line 48:
   
 
function p.getPerkDescription(id)
 
function p.getPerkDescription(id)
  +
id = ResolveIntParam(id)
if type(id) == "table" then id = id.args[1] end
 
 
 
 
for _, perkDesc in ipairs(perkDescription) do
 
for _, perkDesc in ipairs(perkDescription) do

Revision as of 16:24, 28 August 2020


local p = {}
--local data = require("Module:Datatable")
local dataPerks = require("Module:Datatable/Perks")

local bar = "|" -- code for |
local nl = "\n"
local ntl = "|-" -- new table line

local strings = {
}

function getUnusedPerksCount()
	local result = 0
	
	for _, perk in ipairs(perks) do
		if perk.unused == true then result = result + 1 end
	end

	return result
end

function getCommonPerksCount()
	local result = 0
	
	for _, perk in ipairs(perks) do
		if perk.character == nil and perk.unused ~= true then result = result + 1 end
	end
	
	return result
end

local _unusedPerksCount = getUnusedPerksCount()
local _commonPerksCount = getCommonPerksCount()
local _uniquePerksCount = table.getn(perks) - _unusedPerksCount - _commonPerksCount


function p.getPerksCount()
	return _uniquePerksCount + _commonPerksCount
end

function ResolveIntParam(param)
	if type(param) == "table" and param.args[1] ~= nil then
		return tonumber(param.args[1])
	else
		return param
	end
end

function p.getPerkDescription(id)
	id = ResolveIntParam(id)
	
	for _, perkDesc in ipairs(perkDescription) do
		if perkDesc.id == id then
			mw.log(perkDesc.desc[1])
			return perkDesc.desc[1]
		end
	end
end

return p