mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 19:19:02 -06:00
1fdd091456
You can now specify an arbitrary number of pieces for a ruleset. The randomizers will adjust accordingly. Expect a pento ruleset in the modpack soon! Also, gamemode skin selection has been refactored.
24 lines
516 B
Lua
24 lines
516 B
Lua
local Randomizer = require 'tetris.randomizers.randomizer'
|
|
|
|
local BagRandomizer = Randomizer:extend()
|
|
|
|
function BagRandomizer:new(pieces)
|
|
self.bag = {}
|
|
self.pieces = pieces
|
|
for i = 1, self.pieces do
|
|
table.insert(self.bag, i)
|
|
end
|
|
end
|
|
|
|
function BagRandomizer:generatePiece()
|
|
if next(self.bag) == nil then
|
|
for i = 1, self.pieces do
|
|
table.insert(self.bag, i)
|
|
end
|
|
end
|
|
local x = math.random(table.getn(self.bag))
|
|
return table.remove(self.bag, x)
|
|
end
|
|
|
|
return BagRandomizer
|