Add Tetra-X from Tetra Legends

pull/1/head
Ishaan Bhardwaj 2020-11-14 13:49:58 -05:00 committed by GitHub
parent f73af2edc4
commit 905199cbc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 93 additions and 0 deletions

93
tetris/rulesets/tetra.lua Normal file
View File

@ -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