From 36c38bf5745a5cb6c2dd6e4da6adcee10f5a5851 Mon Sep 17 00:00:00 2001 From: Rin Date: Sat, 21 Aug 2021 21:33:03 +0100 Subject: [PATCH] Super PRS. It's PRS with up-kicks --- tetris/rulesets/sprs.lua | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tetris/rulesets/sprs.lua diff --git a/tetris/rulesets/sprs.lua b/tetris/rulesets/sprs.lua new file mode 100644 index 0000000..c22a207 --- /dev/null +++ b/tetris/rulesets/sprs.lua @@ -0,0 +1,56 @@ +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 \ No newline at end of file