Refactored component API for rulesets with an arbitary...

...number of pieces (fixes #31)
This commit is contained in:
Ishaan Bhardwaj
2021-10-16 20:35:47 -04:00
parent 42f872a557
commit 6f4adf5aad
5 changed files with 44 additions and 24 deletions

View File

@@ -3,7 +3,7 @@ local Object = require 'libs.classic'
local Randomizer = Object:extend()
function Randomizer:new()
self.possible_pieces = 7
self.possible_pieces = {"I", "J", "L", "O", "S", "T", "Z"}
self:initialize()
end
@@ -15,10 +15,8 @@ function Randomizer:initialize()
-- do nothing
end
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
function Randomizer:generatePiece()
return shapes[math.random(7)]
return self.possible_pieces[math.random(7)]
end
return Randomizer