Added the lost Konoha mode from TGM4
This commit is contained in:
24
tetris/randomizers/bag5alt.lua
Executable file
24
tetris/randomizers/bag5alt.lua
Executable file
@@ -0,0 +1,24 @@
|
||||
local Randomizer = require 'tetris.randomizers.randomizer'
|
||||
|
||||
local Bag5AltRandomizer = Randomizer:extend()
|
||||
|
||||
function Bag5AltRandomizer:initialize()
|
||||
self.bag = {"I", "J", "L", "O", "T"}
|
||||
self.prev = "O"
|
||||
end
|
||||
|
||||
function Bag5AltRandomizer:generatePiece()
|
||||
if next(self.bag) == nil then
|
||||
self.bag = {"I", "J", "L", "O", "T"}
|
||||
end
|
||||
local x = math.random(table.getn(self.bag))
|
||||
local temp = table.remove(self.bag, x)
|
||||
if temp == self.prev then
|
||||
local y = math.random(table.getn(self.bag))
|
||||
temp = table.remove(self.bag, y)
|
||||
end
|
||||
self.prev = temp
|
||||
return temp
|
||||
end
|
||||
|
||||
return Bag5AltRandomizer
|
||||
Reference in New Issue
Block a user