2020-11-20 13:30:40 -06:00
|
|
|
local Piece = require 'tetris.components.piece'
|
|
|
|
local Ruleset = require 'tetris.rulesets.ruleset'
|
|
|
|
|
|
|
|
local TheNext = Ruleset:extend()
|
|
|
|
|
2020-11-22 21:46:18 -06:00
|
|
|
TheNext.name = "The Nextris"
|
2020-11-20 13:30:40 -06:00
|
|
|
TheNext.hash = "TheNext"
|
|
|
|
|
|
|
|
TheNext.softdrop_lock = false
|
|
|
|
TheNext.harddrop_lock = false
|
|
|
|
|
|
|
|
TheNext.colourscheme = {
|
|
|
|
I = "C",
|
|
|
|
J = "B",
|
|
|
|
L = "M",
|
2020-12-22 21:09:17 -06:00
|
|
|
O = "X",
|
2020-11-20 13:30:40 -06:00
|
|
|
S = "G",
|
|
|
|
Z = "R",
|
|
|
|
T = "Y"
|
|
|
|
}
|
|
|
|
|
|
|
|
TheNext.spawn_positions = {
|
2020-11-20 13:49:11 -06:00
|
|
|
I = { x=5, y=3 },
|
|
|
|
J = { x=4, y=4 },
|
|
|
|
L = { x=4, y=4 },
|
|
|
|
O = { x=5, y=4 },
|
|
|
|
S = { x=4, y=4 },
|
|
|
|
T = { x=4, y=4 },
|
|
|
|
Z = { x=4, y=4 },
|
2020-11-20 13:30:40 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
TheNext.big_spawn_positions = {
|
|
|
|
I = { x=3, y=2 },
|
|
|
|
J = { x=2, y=3 },
|
|
|
|
L = { x=2, y=3 },
|
|
|
|
O = { x=3, y=3 },
|
|
|
|
S = { x=2, y=3 },
|
|
|
|
T = { x=2, y=3 },
|
|
|
|
Z = { x=2, y=3 },
|
|
|
|
}
|
|
|
|
|
|
|
|
TheNext.block_offsets = {
|
|
|
|
T={
|
|
|
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=0, y=-2} },
|
|
|
|
{ {x=0, y=-1}, {x=0, y=-2}, {x=0, y=0}, {x=1, y=-1} },
|
|
|
|
{ {x=0, y=-1}, {x=1, y=-1}, {x=-1, y=-1}, {x=0, y=0} },
|
|
|
|
{ {x=0, y=-1}, {x=0, y=0}, {x=0, y=-2}, {x=-1, y=-1} },
|
|
|
|
},
|
|
|
|
I={
|
|
|
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} },
|
|
|
|
{ {x=-1, y=-1}, {x=-1, y=-2}, {x=-1, y=0}, {x=-1, y=1} },
|
|
|
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} },
|
|
|
|
{ {x=-1, y=-1}, {x=-1, y=-2}, {x=-1, y=0}, {x=-1, y=1} },
|
|
|
|
},
|
|
|
|
O={
|
|
|
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
|
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
|
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
|
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
|
|
},
|
|
|
|
S={
|
|
|
|
{ {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} },
|
|
|
|
{ {x=0, y=-1}, {x=0, y=0}, {x=1, y=0}, {x=1, y=1} },
|
|
|
|
{ {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} },
|
|
|
|
{ {x=0, y=-1}, {x=0, y=0}, {x=1, y=0}, {x=1, y=1} },
|
|
|
|
},
|
|
|
|
Z={
|
|
|
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=0}, {x=0, y=0} },
|
|
|
|
{ {x=-1, y=1}, {x=-1, y=0}, {x=0, y=-1}, {x=0, y=0} },
|
|
|
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=0}, {x=0, y=0} },
|
|
|
|
{ {x=-1, y=1}, {x=-1, y=0}, {x=0, y=-1}, {x=0, y=0} },
|
|
|
|
},
|
|
|
|
J={
|
|
|
|
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=-1} },
|
|
|
|
{ {x=0, y=0}, {x=0, y=-1}, {x=1, y=-1}, {x=0, y=1} },
|
|
|
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=1, y=0} },
|
|
|
|
{ {x=1, y=0}, {x=1, y=-1}, {x=1, y=1}, {x=0, y=1} },
|
|
|
|
},
|
|
|
|
L={
|
|
|
|
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=1, y=-1} },
|
|
|
|
{ {x=-1, y=-1}, {x=-1, y=0}, {x=0, y=1}, {x=-1, y=1} },
|
|
|
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=-1, y=0} },
|
|
|
|
{ {x=0, y=0}, {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=1} },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
TheNext.wallkicks_ccw = {{x=-1, y=0}, {x=0, y=1}, {x=1, y=0}, {x=0, y=-1}}
|
|
|
|
TheNext.wallkicks_cw = {{x=1, y=0}, {x=0, y=1}, {x=-1, y=0}, {x=0, y=-1}}
|
|
|
|
|
|
|
|
function TheNext:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
2020-11-21 09:30:28 -06:00
|
|
|
|
2020-11-20 13:30:40 -06:00
|
|
|
local kicks
|
|
|
|
if piece.shape == "O" then
|
|
|
|
return
|
2020-11-21 09:30:28 -06:00
|
|
|
elseif rot_dir == 1 then
|
2020-11-20 13:30:40 -06:00
|
|
|
kicks = TheNext.wallkicks_cw
|
|
|
|
else
|
|
|
|
kicks = TheNext.wallkicks_ccw
|
|
|
|
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
|
2020-12-04 19:53:09 -06:00
|
|
|
self:onPieceRotate(piece, grid)
|
2020-11-20 13:30:40 -06:00
|
|
|
piece:setRelativeRotation(rot_dir)
|
|
|
|
piece:setOffset(offset)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function TheNext:onPieceDrop(piece, grid)
|
|
|
|
piece.lock_delay = 0 -- step reset
|
|
|
|
end
|
|
|
|
|
|
|
|
function TheNext:get180RotationValue()
|
|
|
|
if config.gamesettings.world_reverse == 1 then
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
return 3
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function TheNext:getDefaultOrientation() return 3 end
|
|
|
|
|
2020-11-21 09:30:28 -06:00
|
|
|
return TheNext
|