From 905199cbc2f92591f3126b7edd79d999742483ec Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj <59454579+SashLilac@users.noreply.github.com> Date: Sat, 14 Nov 2020 13:49:58 -0500 Subject: [PATCH] Add Tetra-X from Tetra Legends --- tetris/rulesets/tetra.lua | 93 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 tetris/rulesets/tetra.lua diff --git a/tetris/rulesets/tetra.lua b/tetris/rulesets/tetra.lua new file mode 100644 index 0000000..df5f390 --- /dev/null +++ b/tetris/rulesets/tetra.lua @@ -0,0 +1,93 @@ +local SRS = require 'tetris.rulesets.ti_srs' + +local Tetra = SRS:extend() + +Tetra.name = "Tetra-X" +Tetra.hash = "TetraX" + +Tetra.colourscheme = { + I = "O", + L = "Y", + J = "B", + S = "C", + Z = "R", + O = "G", + T = "M", +} + +Tetra.wallkicks_3x3 = { + [0]={ + [1]={{x=0, y=1}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=1}, {x=1, y=1}, {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}}, + [2]={{x=0, y=1}, {x=0, y=-1}, {x=-1, y=0}, {x=1, y=0}}, + [3]={{x=0, y=1}, {x=1, y=0}, {x=-1, y=0}, {x=1, y=1}, {x=-1, y=1}, {x=0, y=-1}, {x=1, y=-1}, {x=-1, y=-1}}, + }, + [1]={ + [0]={{x=0, y=1}, {x=1, y=0}, {x=-1, y=0}, {x=1, y=1}, {x=-1, y=1}, {x=0, y=-1}, {x=1, y=-1}, {x=-1, y=-1}}, + [2]={{x=0, y=1}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=1}, {x=1, y=1}, {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}}, + [3]={{x=0, y=1}, {x=0, y=-1}, {x=-1, y=0}, {x=1, y=0}}, + }, + [2]={ + [0]={{x=0, y=1}, {x=0, y=-1}, {x=-1, y=0}, {x=1, y=0}}, + [1]={{x=0, y=1}, {x=1, y=0}, {x=-1, y=0}, {x=1, y=1}, {x=-1, y=1}, {x=0, y=-1}, {x=1, y=-1}, {x=-1, y=-1}}, + [3]={{x=0, y=1}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=1}, {x=1, y=1}, {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}}, + }, + [3]={ + [0]={{x=0, y=1}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=1}, {x=1, y=1}, {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}}, + [1]={{x=0, y=1}, {x=0, y=-1}, {x=-1, y=0}, {x=1, y=0}}, + [2]={{x=0, y=1}, {x=1, y=0}, {x=-1, y=0}, {x=1, y=1}, {x=-1, y=1}, {x=0, y=-1}, {x=1, y=-1}, {x=-1, y=-1}}, + }, +} + +Tetra.wallkicks_line = { + [0]={ + [1]={{x=0, y=-1}, {x=0, y=-2}, {x=0, y=1}, {x=1, y=-1}, {x=-1, y=-1}, {x=1, y=-2}, {x=-1, y=-2}}, + [2]={{x=0, y=-1}, {x=0, y=1}}, + [3]={{x=0, y=-1}, {x=0, y=-2}, {x=0, y=1}, {x=-1, y=-1}, {x=1, y=-1}, {x=-1, y=-2}, {x=1, y=-2}}, + }, + [1]={ + [0]={{x=0, y=-1}, {x=0, y=-2}, {x=0, y=1}, {x=-1, y=0}, {x=1, y=0}, {x=2, y=0}}, + [2]={{x=0, y=-1}, {x=0, y=-2}, {x=0, y=1}, {x=-1, y=0}, {x=1, y=0}, {x=2, y=0}}, + [3]={{x=0, y=-1}, {x=0, y=1}}, + }, + [2]={ + [0]={{x=0, y=-1}, {x=0, y=1}}, + [1]={{x=0, y=1}, {x=0, y=2}, {x=0, y=-1}, {x=-1, y=1}, {x=1, y=1}, {x=-1, y=2}, {x=1, y=2}}, + [3]={{x=0, y=1}, {x=0, y=2}, {x=0, y=-1}, {x=1, y=1}, {x=-1, y=1}, {x=1, y=2}, {x=-1, y=2}}, + }, + [3]={ + [0]={{x=0, y=-1}, {x=0, y=-2}, {x=0, y=1}, {x=1, y=0}, {x=-1, y=0}, {x=-2, y=0}}, + [1]={{x=0, y=-1}, {x=0, y=1}}, + [2]={{x=0, y=-1}, {x=0, y=-2}, {x=0, y=1}, {x=1, y=0}, {x=-1, y=0}, {x=-2, y=0}}, + }, +} + +function Tetra:attemptWallkicks(piece, new_piece, rot_dir, grid) + + local kicks + if piece.shape == "O" then + return + elseif piece.shape == "I" then + kicks = Tetra.wallkicks_line[piece.rotation][new_piece.rotation] + else + kicks = Tetra.wallkicks_3x3[piece.rotation][new_piece.rotation] + end + + assert(piece.rotation ~= new_piece.rotation) + + for idx, offset in pairs(kicks) do + kicked_piece = new_piece:withOffset(offset) + if grid:canPlacePiece(kicked_piece) then + piece:setRelativeRotation(rot_dir) + piece:setOffset(offset) + self:onPieceRotate(piece, grid) + return + end + end + +end + +function Tetra:onPieceMove() end +function Tetra:onPieceRotate() end +function Tetra:get180RotationValue() return 2 end + +return Tetra \ No newline at end of file