This commit is contained in:
lx
2026-07-06 14:01:11 -04:00
commit c4f97d729d
16468 changed files with 935321 additions and 0 deletions
@@ -0,0 +1,10 @@
-- Helper function to throttle based on player Id:
return function(throttle, userId)
assert(type(throttle) == "number")
assert(type(userId) == "number")
-- Determine userRollout using last two digits of user ID:
-- (+1 to change range from 0-99 to 1-100 as 0 is off, 100 is full on):
local userRollout = (userId % 100) + 1
return userRollout <= throttle
end
@@ -0,0 +1,67 @@
return function()
local ThrottleUserId = require(script.Parent.ThrottleUserId)
describe("ThrottleUserId", function()
it("should always reject zero%", function()
local gating = ThrottleUserId(0, 10000)
expect(gating).to.equal(false)
gating = ThrottleUserId(0, 10001)
expect(gating).to.equal(false)
gating = ThrottleUserId(0, 10025)
expect(gating).to.equal(false)
gating = ThrottleUserId(0, 10075)
expect(gating).to.equal(false)
gating = ThrottleUserId(0, 10099)
expect(gating).to.equal(false)
gating = ThrottleUserId(0, 10100)
expect(gating).to.equal(false)
end)
it("should always accept 100%", function()
local gating = ThrottleUserId(100, 10000)
expect(gating).to.equal(true)
gating = ThrottleUserId(100, 10001)
expect(gating).to.equal(true)
gating = ThrottleUserId(100, 10025)
expect(gating).to.equal(true)
gating = ThrottleUserId(100, 10075)
expect(gating).to.equal(true)
gating = ThrottleUserId(100, 10099)
expect(gating).to.equal(true)
gating = ThrottleUserId(100, 10100)
expect(gating).to.equal(true)
end)
it("should reject IDs over throttle percent", function()
local gating = ThrottleUserId(25, 10050)
expect(gating).to.equal(false)
gating = ThrottleUserId(50, 10075)
expect(gating).to.equal(false)
gating = ThrottleUserId(75, 10099)
expect(gating).to.equal(false)
end)
it("should accept IDs under throttle percent", function()
local gating = ThrottleUserId(1, 10100)
expect(gating).to.equal(true)
gating = ThrottleUserId(10, 10109)
expect(gating).to.equal(true)
gating = ThrottleUserId(25, 10023)
expect(gating).to.equal(true)
end)
end)
end