Floorkicks reworked (read comments)

If not classic lock, upward kicks reset to the top of the tile
pull/16/head
Ishaan Bhardwaj 2021-02-16 23:28:54 -05:00
parent 6a5d5a9c88
commit 714c6b5e99
2 changed files with 19 additions and 10 deletions

View File

@ -117,11 +117,15 @@ function Piece:lockIfBottomed(grid)
return self
end
function Piece:addGravity(gravity, grid)
function Piece:addGravity(gravity, grid, classic_lock)
local new_gravity = self.gravity + gravity
if self:isDropBlocked(grid) then
self.gravity = math.min(1, new_gravity)
self.lock_delay = self.lock_delay + 1
if classic_lock then
self.gravity = math.min(1, new_gravity)
else
self.gravity = 0
self.lock_delay = self.lock_delay + 1
end
else
local dropped_squares = math.floor(new_gravity)
local new_frac_gravity = new_gravity - dropped_squares

View File

@ -115,7 +115,9 @@ function Ruleset:rotatePiece(inputs, piece, grid, prev_inputs, initial)
local was_drop_blocked = piece:isDropBlocked(grid)
self:attemptRotate(new_inputs, piece, grid, initial)
if self:canPieceRotate(piece, grid) then
self:attemptRotate(new_inputs, piece, grid, initial)
end
if not was_drop_blocked and piece:isDropBlocked(grid) then
playSE("bottom")
@ -160,6 +162,7 @@ function Ruleset:attemptWallkicks(piece, new_piece, rot_dir, grid)
end
function Ruleset:movePiece(piece, grid, move, instant)
if not self:canPieceMove(piece, grid) then return end
local x = piece.position.x
local was_drop_blocked = piece:isDropBlocked(grid)
if move == "left" then
@ -181,7 +184,7 @@ end
function Ruleset:dropPiece(
inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked,
hard_drop_enabled, additive_gravity
hard_drop_enabled, additive_gravity, classic_lock
)
if piece.big then
gravity = gravity / 2
@ -191,18 +194,18 @@ function Ruleset:dropPiece(
local y = piece.position.y
if inputs["down"] == true and drop_locked == false then
if additive_gravity then
piece:addGravity(gravity + drop_speed, grid)
piece:addGravity(gravity + drop_speed, grid, classic_lock)
else
piece:addGravity(math.max(gravity, drop_speed), grid)
piece:addGravity(math.max(gravity, drop_speed), grid, classic_lock)
end
elseif inputs["up"] == true and hard_drop_enabled == true then
if hard_drop_locked == true or piece:isDropBlocked(grid) then
piece:addGravity(gravity, grid)
piece:addGravity(gravity, grid, classic_lock)
else
piece:dropToBottom(grid)
end
else
piece:addGravity(gravity, grid)
piece:addGravity(gravity, grid, classic_lock)
end
if piece.position.y ~= y then
self:onPieceDrop(piece, grid)
@ -303,11 +306,13 @@ function Ruleset:processPiece(
end
self:dropPiece(
inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked,
hard_drop_enabled, additive_gravity
hard_drop_enabled, additive_gravity, classic_lock
)
self:lockPiece(piece, grid, lock_delay, classic_lock)
end
function Ruleset:canPieceMove(piece, grid) return true end
function Ruleset:canPieceRotate(piece, grid) return true end
function Ruleset:onPieceMove(piece) end
function Ruleset:onPieceRotate(piece) end
function Ruleset:onPieceDrop(piece) end