From 8a2237a77c0430a41e83ea73bff50b69cd28c675 Mon Sep 17 00:00:00 2001 From: Oshisaure Date: Wed, 7 Oct 2020 19:54:18 +0100 Subject: [PATCH] Fixed Arika rulesets - Fixed centre column rule on Classic ARS, Ti-ARS and ACE-ARS - Added T floorkick for Ti-ARS and ACE-ARS --- tetris/rulesets/arika.lua | 18 ++++++++++----- tetris/rulesets/arika_ace.lua | 41 ++++++++++++++++++++++++----------- tetris/rulesets/arika_ti.lua | 41 ++++++++++++++++++++++++----------- 3 files changed, 69 insertions(+), 31 deletions(-) diff --git a/tetris/rulesets/arika.lua b/tetris/rulesets/arika.lua index 93c9264..607d812 100644 --- a/tetris/rulesets/arika.lua +++ b/tetris/rulesets/arika.lua @@ -81,11 +81,19 @@ function ARS:attemptWallkicks(piece, new_piece, rot_dir, grid) piece.shape == "J" or piece.shape == "T" or piece.shape == "L" ) and ( piece.rotation == 0 or piece.rotation == 2 - ) and ( - grid:isOccupied(piece.position.x, piece.position.y) or - grid:isOccupied(piece.position.x, piece.position.y - 1) or - grid:isOccupied(piece.position.x, piece.position.y - 2) - ) then return end + ) then + 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 -- kick right, kick left if (grid:canPlacePiece(new_piece:withOffset({x=1, y=0}))) then diff --git a/tetris/rulesets/arika_ace.lua b/tetris/rulesets/arika_ace.lua index b7c3ce2..c3a7f51 100755 --- a/tetris/rulesets/arika_ace.lua +++ b/tetris/rulesets/arika_ace.lua @@ -84,11 +84,19 @@ function ARS:attemptWallkicks(piece, new_piece, rot_dir, grid) piece.shape == "J" or piece.shape == "T" or piece.shape == "L" ) and ( piece.rotation == 0 or piece.rotation == 2 - ) and ( - grid:isOccupied(piece.position.x, piece.position.y) or - grid:isOccupied(piece.position.x, piece.position.y - 1) or - grid:isOccupied(piece.position.x, piece.position.y - 2) - ) then return end + ) then + 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 if piece.shape == "I" then -- special kick rules for I @@ -116,14 +124,21 @@ function ARS:attemptWallkicks(piece, new_piece, rot_dir, grid) piece.floorkick = 1 end end - elseif piece.shape ~= "I" then - -- kick right, kick left - if (grid:canPlacePiece(new_piece:withOffset({x=1, y=0}))) then - piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0}) - elseif (grid:canPlacePiece(new_piece:withOffset({x=-1, y=0}))) then - piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0}) - end - else + else + -- kick right, kick left + if grid:canPlacePiece(new_piece:withOffset({x=1, y=0})) then + piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0}) + elseif grid:canPlacePiece(new_piece:withOffset({x=-1, y=0})) then + piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0}) + elseif piece.shape == "T" + and newpiece.rotation == 1 + and piece.floorkick == 0 + and grid:canPlacePiece(new_piece:withOffset({x=0, y=-1})) + then + -- T floorkick + piece.floorkick = piece.floorkick + 1 + piece:setRelativeRotation(rot_dir):setOffset({x=0, y=-1}) + end end end diff --git a/tetris/rulesets/arika_ti.lua b/tetris/rulesets/arika_ti.lua index e477595..43e802a 100644 --- a/tetris/rulesets/arika_ti.lua +++ b/tetris/rulesets/arika_ti.lua @@ -84,11 +84,19 @@ function ARS:attemptWallkicks(piece, new_piece, rot_dir, grid) piece.shape == "J" or piece.shape == "T" or piece.shape == "L" ) and ( piece.rotation == 0 or piece.rotation == 2 - ) and ( - grid:isOccupied(piece.position.x, piece.position.y) or - grid:isOccupied(piece.position.x, piece.position.y - 1) or - grid:isOccupied(piece.position.x, piece.position.y - 2) - ) then return end + ) then + 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 if piece.shape == "I" then -- special kick rules for I @@ -116,14 +124,21 @@ function ARS:attemptWallkicks(piece, new_piece, rot_dir, grid) piece.floorkick = 1 end end - elseif piece.shape ~= "I" then - -- kick right, kick left - if (grid:canPlacePiece(new_piece:withOffset({x=1, y=0}))) then - piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0}) - elseif (grid:canPlacePiece(new_piece:withOffset({x=-1, y=0}))) then - piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0}) - end - else + else + -- kick right, kick left + if grid:canPlacePiece(new_piece:withOffset({x=1, y=0})) then + piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0}) + elseif grid:canPlacePiece(new_piece:withOffset({x=-1, y=0})) then + piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0}) + elseif piece.shape == "T" + and newpiece.rotation == 1 + and piece.floorkick == 0 + and grid:canPlacePiece(new_piece:withOffset({x=0, y=-1})) + then + -- T floorkick + piece.floorkick = piece.floorkick + 1 + piece:setRelativeRotation(rot_dir):setOffset({x=0, y=-1}) + end end end