From 303e844608414c036dd4f76274b2b47c61231789 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Sun, 21 Feb 2021 17:40:54 -0500 Subject: [PATCH] E-Heart ARS updated to not kick the other dir --- tetris/rulesets/eheart.lua | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/tetris/rulesets/eheart.lua b/tetris/rulesets/eheart.lua index f938d12..d5cd1c3 100644 --- a/tetris/rulesets/eheart.lua +++ b/tetris/rulesets/eheart.lua @@ -13,26 +13,20 @@ function EHeart:attemptWallkicks(piece, new_piece, rot_dir, grid) -- center column rule (kicks) 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 - -- individual checks for all 9 cells, in the given order - if offset.y < 0 then - if offset.x < 0 then self:lateralKick(1, piece, new_piece, rot_dir, grid) - elseif offset.x == 0 then return - elseif offset.x > 0 then self:lateralKick(-1, piece, new_piece, rot_dir, grid) end - elseif offset.y == 0 then - if offset.x < 0 then self:lateralKick(1, piece, new_piece, rot_dir, grid) - elseif offset.x == 0 then return - elseif offset.x > 0 then self:lateralKick(-1, piece, new_piece, rot_dir, grid) end - elseif offset.y > 0 then - if offset.x < 0 then self:lateralKick(1, piece, new_piece, rot_dir, grid) - elseif offset.x == 0 then return - elseif offset.x > 0 then self:lateralKick(-1, piece, new_piece, rot_dir, grid) end - end + 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 + self:lateralKick(1, piece, new_piece, rot_dir, grid) + break + elseif offset.x == 0 then + return + elseif offset.x > 0 then + self:lateralKick(-1, piece, new_piece, rot_dir, grid) + break end end - + end end function EHeart:lateralKick(dx, piece, new_piece, rot_dir, grid)