cambridge-modpack/tetris/rulesets/sprs.lua

56 lines
1.7 KiB
Lua
Raw Normal View History

2021-08-21 15:33:03 -05:00
local PRS = require 'tetris.rulesets.prs'
local SPRS = PRS:extend()
SPRS.name = "Super P.R.S"
SPRS.hash = "SuperPRS"
SPRS.world = true
function SPRS:attemptWallkicks(piece, newpiece, rot_dir, grid)
for y=0,5 do
for x=0,5 do
local offset = {x=x, y=y}
kicked_piece = newpiece:withOffset(offset)
if grid:canPlacePiece(kicked_piece) then
piece:setRelativeRotation(rot_dir)
piece:setOffset(offset)
self:onPieceRotate(piece, grid)
return
end
end
for x=0,5 do
local offset = {x=-x, y=y}
kicked_piece = newpiece:withOffset(offset)
if grid:canPlacePiece(kicked_piece) then
piece:setRelativeRotation(rot_dir)
piece:setOffset(offset)
self:onPieceRotate(piece, grid)
return
end
end
end
for y=0,-5,-1 do
for x=0,5 do
local offset = {x=x, y=y}
kicked_piece = newpiece:withOffset(offset)
if grid:canPlacePiece(kicked_piece) then
piece:setRelativeRotation(rot_dir)
piece:setOffset(offset)
self:onPieceRotate(piece, grid)
return
end
end
for x=0,5 do
local offset = {x=-x, y=y}
kicked_piece = newpiece:withOffset(offset)
if grid:canPlacePiece(kicked_piece) then
piece:setRelativeRotation(rot_dir)
piece:setOffset(offset)
self:onPieceRotate(piece, grid)
return
end
end
end
end
return SPRS