Added 5 bag randomizer

pull/1/head
Ishaan Bhardwaj 2020-10-04 22:49:17 -04:00
parent 593cad0e71
commit 971151e210
1 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,17 @@
local Randomizer = require 'tetris.randomizers.randomizer'
local Bag5Randomizer = Randomizer:extend()
function Bag5Randomizer:initialize()
self.bag = {"I", "J", "L", "O", "T"}
end
function Bag5Randomizer:generatePiece()
if next(self.bag) == nil then
self.bag = {"I", "J", "L", "O", "T"}
end
local x = math.random(table.getn(self.bag))
return table.remove(self.bag, x)
end
return Bag5Randomizer