cambridge-modpack/tetris/randomizers/bag5alt.lua

25 lines
594 B
Lua
Raw Normal View History

2020-11-11 21:24:56 -06:00
local Randomizer = require 'tetris.randomizers.randomizer'
local Bag5AltRandomizer = Randomizer:extend()
function Bag5AltRandomizer:initialize()
self.bag = {"I", "J", "L", "O", "T"}
self.prev = nil
end
function Bag5AltRandomizer:generatePiece()
if next(self.bag) == nil then
self.bag = {"I", "J", "L", "O", "T"}
end
local x = love.math.random(table.getn(self.bag))
2020-11-11 21:24:56 -06:00
local temp = table.remove(self.bag, x)
if temp == self.prev then
local y = love.math.random(table.getn(self.bag))
2020-11-11 21:24:56 -06:00
temp = table.remove(self.bag, y)
end
self.prev = temp
return temp
end
return Bag5AltRandomizer