cambridge/tetris/rulesets/standard_exp.lua

59 lines
1.3 KiB
Lua
Raw Normal View History

2019-05-22 22:57:34 -05:00
local Piece = require 'tetris.components.piece'
2020-12-04 19:36:11 -06:00
local Ruleset = require 'tetris.rulesets.arika_srs'
2019-05-22 22:57:34 -05:00
local SRS = Ruleset:extend()
2020-10-05 21:17:15 -05:00
SRS.name = "Guideline SRS"
2019-05-22 22:57:34 -05:00
SRS.hash = "Standard"
SRS.enable_IRS_wallkicks = true
function SRS:check_new_low(piece)
for _, block in pairs(piece:getBlockOffsets()) do
local y = piece.position.y + block.y
if y > piece.lowest_y then
piece.manipulations = 0
piece.lowest_y = y
end
end
end
2019-05-22 22:57:34 -05:00
function SRS:onPieceCreate(piece, grid)
piece.manipulations = 0
piece.lowest_y = -math.huge
2019-05-22 22:57:34 -05:00
end
function SRS:onPieceDrop(piece, grid)
self:check_new_low(piece)
if piece.manipulations >= 15 and piece:isDropBlocked(grid) then
piece.locked = true
else
piece.lock_delay = 0 -- step reset
end
2019-05-22 22:57:34 -05:00
end
function SRS:onPieceMove(piece, grid)
piece.lock_delay = 0 -- move reset
if piece:isDropBlocked(grid) then
piece.manipulations = piece.manipulations + 1
if piece.manipulations >= 15 then
2019-05-22 22:57:34 -05:00
piece.locked = true
end
end
end
function SRS:onPieceRotate(piece, grid)
piece.lock_delay = 0 -- rotate reset
self:check_new_low(piece)
piece.manipulations = piece.manipulations + 1
2019-05-22 22:57:34 -05:00
if piece:isDropBlocked(grid) then
if piece.manipulations >= 15 then
2019-05-22 22:57:34 -05:00
piece.locked = true
end
end
end
2020-12-04 20:36:25 -06:00
function SRS:get180RotationValue() return 2 end
2019-05-22 22:57:34 -05:00
return SRS