mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-12-22 21:49:02 -06:00
6f4adf5aad
...number of pieces (fixes #31)
23 lines
408 B
Lua
23 lines
408 B
Lua
local Object = require 'libs.classic'
|
|
|
|
local Randomizer = Object:extend()
|
|
|
|
function Randomizer:new()
|
|
self.possible_pieces = {"I", "J", "L", "O", "S", "T", "Z"}
|
|
self:initialize()
|
|
end
|
|
|
|
function Randomizer:nextPiece()
|
|
return self:generatePiece()
|
|
end
|
|
|
|
function Randomizer:initialize()
|
|
-- do nothing
|
|
end
|
|
|
|
function Randomizer:generatePiece()
|
|
return self.possible_pieces[math.random(7)]
|
|
end
|
|
|
|
return Randomizer
|