mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 14:09:03 -06:00
Upward kicks for SRS count toward rotation limit
This commit is contained in:
parent
714c6b5e99
commit
31e2529265
@ -21,14 +21,15 @@ SRS.spawn_above_field = true
|
||||
|
||||
SRS.MANIPULATIONS_MAX = 128
|
||||
|
||||
function SRS:onPieceRotate(piece, grid)
|
||||
function SRS:onPieceRotate(piece, grid, upward)
|
||||
piece.lock_delay = 0 -- rotate reset
|
||||
if piece:isDropBlocked(grid) then
|
||||
if upward or piece:isDropBlocked(grid) then
|
||||
piece.manipulations = piece.manipulations + 1
|
||||
if piece.manipulations >= self.MANIPULATIONS_MAX then
|
||||
piece.locked = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function SRS:canPieceRotate(piece)
|
||||
return piece.manipulations < self.MANIPULATIONS_MAX
|
||||
end
|
||||
|
||||
return SRS
|
||||
|
@ -92,11 +92,14 @@ function SRS:onPieceRotate(piece, grid)
|
||||
piece.lock_delay = 0 -- rotate reset
|
||||
self:checkNewLow(piece)
|
||||
piece.manipulations = piece.manipulations + 1
|
||||
if piece:isDropBlocked(grid) then
|
||||
if piece.manipulations >= SRS.MANIPULATIONS_MAX then
|
||||
piece.locked = true
|
||||
end
|
||||
end
|
||||
if piece.manipulations >= self.MANIPULATIONS_MAX then
|
||||
piece:moveInGrid({ x = 0, y = 1 }, 1, grid)
|
||||
if piece:isDropBlocked(grid) then
|
||||
piece.locked = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function SRS:canPieceRotate() end
|
||||
|
||||
return SRS
|
||||
|
@ -54,7 +54,7 @@ function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||
if grid:canPlacePiece(kicked_piece) then
|
||||
piece:setRelativeRotation(rot_dir)
|
||||
piece:setOffset(offset)
|
||||
self:onPieceRotate(piece, grid)
|
||||
self:onPieceRotate(piece, grid, offset.y < 0)
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -69,7 +69,10 @@ end
|
||||
|
||||
function SRS:onPieceDrop(piece, grid)
|
||||
self:checkNewLow(piece)
|
||||
if piece.manipulations >= self.MANIPULATIONS_MAX and piece:isDropBlocked(grid) then
|
||||
if (
|
||||
piece.manipulations >= self.MANIPULATIONS_MAX or
|
||||
piece.rotations >= self.ROTATIONS_MAX
|
||||
) and piece:isDropBlocked(grid) then
|
||||
piece.locked = true
|
||||
else
|
||||
piece.lock_delay = 0 -- step reset
|
||||
@ -86,16 +89,15 @@ function SRS:onPieceMove(piece, grid)
|
||||
end
|
||||
end
|
||||
|
||||
function SRS:onPieceRotate(piece, grid)
|
||||
function SRS:onPieceRotate(piece, grid, upward)
|
||||
piece.lock_delay = 0 -- rotate reset
|
||||
self:checkNewLow(piece)
|
||||
if piece.rotations >= self.ROTATIONS_MAX then
|
||||
piece.rotations = piece.rotations + 1
|
||||
piece:moveInGrid({ x = 0, y = 1 }, 1, grid)
|
||||
if piece:isDropBlocked(grid) then
|
||||
piece.locked = true
|
||||
end
|
||||
end
|
||||
if upward or piece:isDropBlocked(grid) then
|
||||
piece.rotations = piece.rotations + 1
|
||||
end
|
||||
end
|
||||
|
||||
function SRS:canPieceRotate(piece)
|
||||
return piece.rotations < self.ROTATIONS_MAX
|
||||
end
|
||||
|
||||
function SRS:get180RotationValue() return 2 end
|
||||
|
@ -150,9 +150,9 @@ function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||
for idx, offset in pairs(kicks) do
|
||||
kicked_piece = new_piece:withOffset(offset)
|
||||
if grid:canPlacePiece(kicked_piece) then
|
||||
self:onPieceRotate(piece, grid)
|
||||
piece:setRelativeRotation(rot_dir)
|
||||
piece:setOffset(offset)
|
||||
self:onPieceRotate(piece, grid, offset.y < 0)
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -182,16 +182,17 @@ function SRS:onPieceMove(piece, grid)
|
||||
end
|
||||
end
|
||||
|
||||
function SRS:onPieceRotate(piece, grid)
|
||||
function SRS:onPieceRotate(piece, grid, upward)
|
||||
piece.lock_delay = 0 -- rotate reset
|
||||
if piece:isDropBlocked(grid) then
|
||||
if upward or piece:isDropBlocked(grid) then
|
||||
piece.rotations = piece.rotations + 1
|
||||
if piece.rotations >= self.ROTATIONS_MAX then
|
||||
piece.locked = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function SRS:canPieceRotate(piece)
|
||||
return piece.rotations < self.ROTATIONS_MAX
|
||||
end
|
||||
|
||||
function SRS:get180RotationValue() return 3 end
|
||||
|
||||
return SRS
|
||||
|
Loading…
Reference in New Issue
Block a user