Last active
December 29, 2018 16:00
-
-
Save siasur/f72fe361faab5f0d786b3522e4744fea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function math.clamp(val, min, max) | |
local step = math.max(val, min) | |
return math.min(step, max) | |
end | |
local roles = { | |
{ name = "Traitor", pct = 0.25, max = 6, minply = 0}, | |
{ name = "Detective", pct = 0.17, max = 4, minply = 8}, | |
{ name = "Jackal", pct = 1, max = 1, minply = 6} | |
} | |
local function determineCounts(ply_count) | |
local playerDistribution = "" | |
local unasignedCount = ply_count | |
for k, v in pairs(roles) do | |
local name = v.name | |
local pct = v.pct | |
local max = v.max | |
local minPlayer = v.minply | |
local count = 0 | |
if (ply_count >= minPlayer) then | |
local targetCount = math.floor(ply_count * pct) | |
count = math.clamp(targetCount, 1, max) | |
unasignedCount = unasignedCount - count | |
end | |
playerDistribution = playerDistribution .. name .. ": " .. count .. " | " | |
end | |
playerDistribution = playerDistribution .. "Innocent: " .. unasignedCount | |
return playerDistribution | |
end | |
local minPlayer = 2 | |
local maxPlayer = 24 | |
for i = minPlayer, maxPlayer, 1 do | |
print("Spielerzahl: ".. i .. " -> " .. determineCounts(i)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment