2019-05-22 22:57:34 -05:00
|
|
|
local Piece = require 'tetris.components.piece'
|
|
|
|
local Ruleset = require 'tetris.rulesets.ruleset'
|
|
|
|
|
|
|
|
local ARS = Ruleset:extend()
|
|
|
|
|
|
|
|
ARS.name = "Classic ARS"
|
|
|
|
ARS.hash = "Arika"
|
|
|
|
|
|
|
|
ARS.spawn_positions = {
|
|
|
|
I = { x=5, y=4 },
|
|
|
|
J = { x=4, y=5 },
|
|
|
|
L = { x=4, y=5 },
|
|
|
|
O = { x=5, y=5 },
|
|
|
|
S = { x=4, y=5 },
|
|
|
|
T = { x=4, y=5 },
|
|
|
|
Z = { x=4, y=5 },
|
|
|
|
}
|
|
|
|
|
2019-06-16 21:16:09 -05:00
|
|
|
ARS.big_spawn_positions = {
|
2020-10-13 14:26:07 -05:00
|
|
|
I = { x=3, y=2 },
|
2019-06-16 21:16:09 -05:00
|
|
|
J = { x=2, y=3 },
|
|
|
|
L = { x=2, y=3 },
|
2020-10-13 14:26:07 -05:00
|
|
|
O = { x=3, y=3 },
|
2019-06-16 21:16:09 -05:00
|
|
|
S = { x=2, y=3 },
|
|
|
|
T = { x=2, y=3 },
|
|
|
|
Z = { x=2, y=3 },
|
|
|
|
}
|
|
|
|
|
2019-05-22 22:57:34 -05:00
|
|
|
ARS.block_offsets = {
|
|
|
|
I={
|
|
|
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} },
|
|
|
|
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=0, y=2} },
|
|
|
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} },
|
|
|
|
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=0, y=2} },
|
|
|
|
},
|
|
|
|
J={
|
|
|
|
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=-1} },
|
|
|
|
{ {x=0, y=-1}, {x=1, y=-2}, {x=0, y=-2}, {x=0, y=0} },
|
|
|
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=1, y=0} },
|
|
|
|
{ {x=0, y=-1}, {x=0, y=-2}, {x=0, y=0}, {x=-1, y=0} },
|
|
|
|
},
|
|
|
|
L={
|
|
|
|
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=1, y=-1} },
|
|
|
|
{ {x=0, y=-2}, {x=0, y=-1}, {x=1, y=0}, {x=0, y=0} },
|
|
|
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=-1, y=0} },
|
|
|
|
{ {x=0, y=-1}, {x=-1, y=-2}, {x=0, y=-2}, {x=0, y=0} },
|
|
|
|
},
|
|
|
|
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=-1, y=-2}, {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0} },
|
|
|
|
{ {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} },
|
|
|
|
{ {x=-1, y=-2}, {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0} },
|
|
|
|
},
|
|
|
|
T={
|
|
|
|
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=0, y=-1} },
|
|
|
|
{ {x=0, y=-1}, {x=0, y=0}, {x=1, y=-1}, {x=0, y=-2} },
|
|
|
|
{ {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=-1, y=-1}, {x=0, y=-2} },
|
|
|
|
},
|
|
|
|
Z={
|
|
|
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=0}, {x=0, y=0} },
|
|
|
|
{ {x=0, y=-1}, {x=0, y=0}, {x=1, y=-2}, {x=1, y=-1} },
|
|
|
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=0}, {x=0, y=0} },
|
|
|
|
{ {x=0, y=-1}, {x=0, y=0}, {x=1, y=-2}, {x=1, y=-1} },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function ARS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
|
|
|
|
|
|
|
-- I and O don't kick
|
|
|
|
if (piece.shape == "I" or piece.shape == "O") then return end
|
|
|
|
|
|
|
|
-- center column rule
|
|
|
|
if (
|
|
|
|
piece.shape == "J" or piece.shape == "T" or piece.shape == "L"
|
|
|
|
) and (
|
|
|
|
piece.rotation == 0 or piece.rotation == 2
|
2020-10-07 13:54:18 -05:00
|
|
|
) then
|
2020-11-06 19:49:44 -06:00
|
|
|
local offsets = new_piece:getBlockOffsets()
|
|
|
|
table.sort(offsets, function(A, B) return A.y < B.y or A.y == B.y and A.x < B.y end)
|
|
|
|
for index, offset in pairs(offsets) do
|
|
|
|
if grid:isOccupied(piece.position.x + offset.x, piece.position.y + offset.y) then
|
|
|
|
if offset.x == 0 then
|
|
|
|
return
|
|
|
|
else
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-05-22 22:57:34 -05:00
|
|
|
|
|
|
|
-- kick right, kick left
|
|
|
|
if (grid:canPlacePiece(new_piece:withOffset({x=1, y=0}))) then
|
|
|
|
self:onPieceRotate(piece, grid)
|
2020-12-04 19:36:11 -06:00
|
|
|
piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0})
|
2019-05-22 22:57:34 -05:00
|
|
|
elseif (grid:canPlacePiece(new_piece:withOffset({x=-1, y=0}))) then
|
|
|
|
self:onPieceRotate(piece, grid)
|
2020-12-04 19:36:11 -06:00
|
|
|
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function ARS:onPieceDrop(piece, grid)
|
|
|
|
piece.lock_delay = 0 -- step reset
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function ARS:get180RotationValue() return 3 end
|
2020-11-06 18:17:32 -06:00
|
|
|
|
2019-05-22 22:57:34 -05:00
|
|
|
function ARS:getDefaultOrientation() return 3 end -- downward facing pieces by default
|
|
|
|
|
|
|
|
return ARS
|