Refactored immobile detection

pull/16/head
Ishaan Bhardwaj 2021-02-21 10:41:05 -05:00
parent 9129503d54
commit 1234e78354
1 changed files with 15 additions and 21 deletions

View File

@ -136,31 +136,13 @@ function GameMode:update(inputs, ruleset)
self:chargeDAS(inputs, self:getDasLimit(), self:getARR()) self:chargeDAS(inputs, self:getDasLimit(), self:getARR())
-- set attempt flags -- set attempt flags
if inputs["left"] or inputs["right"] then if inputs["left"] or inputs["right"] then self:onAttemptPieceMove(self.piece, self.grid) end
self:onAttemptPieceMove(self.piece, self.grid) if (
if self.immobile_spin_bonus and self.piece ~= nil then
if not self.piece:isMoveBlocked(self.grid, { x=-1, y=0 }) and
not self.piece:isMoveBlocked(self.grid, { x=1, y=0 }) then
self.piece.spin = false
end
end
end
if
inputs["rotate_left"] or inputs["rotate_right"] or inputs["rotate_left"] or inputs["rotate_right"] or
inputs["rotate_left2"] or inputs["rotate_right2"] or inputs["rotate_left2"] or inputs["rotate_right2"] or
inputs["rotate_180"] inputs["rotate_180"]
then ) then
self:onAttemptPieceRotate(self.piece, self.grid) self:onAttemptPieceRotate(self.piece, self.grid)
if self.immobile_spin_bonus and self.piece ~= nil then
if self.piece:isDropBlocked(self.grid) and
self.piece:isMoveBlocked(self.grid, { x=-1, y=0 }) and
self.piece:isMoveBlocked(self.grid, { x=1, y=0 }) and
self.piece:isMoveBlocked(self.grid, { x=0, y=-1 }) then
self.piece.spin = true
else
self.piece.spin = false
end
end
end end
if self.piece == nil then if self.piece == nil then
@ -244,7 +226,19 @@ function GameMode:update(inputs, ruleset)
end end
if self.piece.locked == true then if self.piece.locked == true then
-- spin detection, immobile only for now
if self.immobile_spin_bonus and (
self.piece:isDropBlocked(self.grid) and
self.piece:isMoveBlocked(self.grid, { x=-1, y=0 }) and
self.piece:isMoveBlocked(self.grid, { x=1, y=0 }) and
self.piece:isMoveBlocked(self.grid, { x=0, y=-1 })
) then
self.piece.spin = true
end
self.grid:applyPiece(self.piece) self.grid:applyPiece(self.piece)
-- mark squares (can be overridden)
if self.square_mode then if self.square_mode then
self.squares = self.squares + self.grid:markSquares() self.squares = self.squares + self.grid:markSquares()
end end