Ruleset and randomizer refactoring (Read comments)

You can now specify an arbitrary number of pieces for a ruleset.
The randomizers will adjust accordingly.
Expect a pento ruleset in the modpack soon!
Also, gamemode skin selection has been refactored.
This commit is contained in:
Ishaan Bhardwaj
2021-01-06 22:53:44 -05:00
parent ced40297cc
commit 1fdd091456
5 changed files with 54 additions and 12 deletions

View File

@@ -72,14 +72,21 @@ function GameMode:getLineClearDelay() return 40 end
function GameMode:getDasLimit() return 15 end
function GameMode:getNextPiece(ruleset)
return {
skin = "2tie",
shape = self.randomizer:nextPiece(),
skin = self:getSkin(),
shape = (
ruleset.pieces == self.randomizer.possible_pieces and
self.randomizer:nextPiece() or
ruleset.fallback_randomizer:nextPiece()
),
orientation = ruleset:getDefaultOrientation(),
}
end
function GameMode:getSkin()
return "2tie"
end
function GameMode:initialize(ruleset, secret_inputs)
-- generate next queue
self:new(secret_inputs)
@@ -445,11 +452,11 @@ function GameMode:initializeNextPiece(inputs, ruleset, piece_data, generate_next
table.remove(self.next_queue, 1)
table.insert(self.next_queue, self:getNextPiece(ruleset))
end
self:playNextSound()
self:playNextSound(ruleset)
end
function GameMode:playNextSound()
playSE("blocks", self.next_queue[1].shape)
function GameMode:playNextSound(ruleset)
playSE("blocks", ruleset.next_sounds[self.next_queue[1].shape])
end
function GameMode:getHighScoreData()