diff --git a/tetris/components/grid.lua b/tetris/components/grid.lua index 1711fdb..2edea61 100644 --- a/tetris/components/grid.lua +++ b/tetris/components/grid.lua @@ -288,6 +288,7 @@ function Grid:mirror() local new_grid = {} for y = 1, 24 do for x = 1, 10 do + print(#self.grid) new_grid[y][x] = self.grid[y][11 - x] end end diff --git a/tetris/modes/sakura.lua b/tetris/modes/sakura.lua index 685f245..9fb965a 100644 --- a/tetris/modes/sakura.lua +++ b/tetris/modes/sakura.lua @@ -3,7 +3,7 @@ require 'funcs' local GameMode = require 'tetris.modes.gamemode' local Piece = require 'tetris.components.piece' -local History6RollsRandomizer = require 'tetris.randomizers.history_6rolls_35bag' +local SakuraRandomizer = require 'tetris.randomizers.sakura' local SakuraGame = GameMode:extend() @@ -267,7 +267,7 @@ local STAGE_TRANSITION_TIME = 300 function SakuraGame:new() self.super:new() - self.randomizer = History6RollsRandomizer() + self.randomizer = SakuraRandomizer() self.current_map = 1 self.time_limit = 10800 @@ -313,6 +313,12 @@ function SakuraGame:onPieceEnter() self.stage_pieces = self.stage_pieces + 1 end +function SakuraGame:onPieceLock() + if effects[self.current_map] == "mirror" and self.stage_pieces % 3 == 0 then + self.grid:mirror() + end +end + function SakuraGame:advanceOneFrame(inputs, ruleset) if self.ready_frames == 0 then if self.lcd > 0 then diff --git a/tetris/randomizers/fixed_sequence.lua b/tetris/randomizers/fixed_sequence.lua new file mode 100644 index 0000000..cbd8606 --- /dev/null +++ b/tetris/randomizers/fixed_sequence.lua @@ -0,0 +1,16 @@ +local Randomizer = require 'tetris.randomizers.randomizer' + +local Sequence = Randomizer:extend() + +function Sequence:initialize() + self.sequence = "IJLOT" + self.counter = 0 +end + +function Sequence:generatePiece() + local piece = string.sub(self.sequence, self.counter + 1, self.counter + 1) + self.counter = (self.counter + 1) % string.len(self.sequence) + return piece +end + +return Sequence \ No newline at end of file diff --git a/tetris/randomizers/sakura.lua b/tetris/randomizers/sakura.lua new file mode 100644 index 0000000..4b88025 --- /dev/null +++ b/tetris/randomizers/sakura.lua @@ -0,0 +1,10 @@ +local Sequence = require 'tetris.randomizers.fixed_sequence' + +local Sakura = Sequence:extend() + +function Sakura:initialize() + self.super:initialize() + self.sequence = "LIJOTSZILJOTISJZLOIJSZTIOJZTLSOZTISOLTJSIZTOJLIZSTOIZLTJOSILTZSOITJLZSTJJISOLJITSLZOIZSJOITSZLJTSZLISTJLZOTIOZSJILTZSOITZJSOLTJSZIOJLZIOJTZIZLOSIZTJOILZSOJIOSZTJILOSSILZOTJIZTSOLZTSOIJTZSILTZOSIJZTOLJISOLJTZSOLTZJSOTILZJTOLZIJSOZTJLOZSTLOZITSOLZTJIOSLZJTO" +end + +return Sakura \ No newline at end of file