2020-11-14 09:43:01 -06:00
|
|
|
local Piece = require 'tetris.components.piece'
|
2020-12-04 19:53:09 -06:00
|
|
|
local Ruleset = require 'tetris.rulesets.ti_srs'
|
2020-11-14 09:43:01 -06:00
|
|
|
|
|
|
|
local SRS = Ruleset:extend()
|
|
|
|
|
|
|
|
SRS.name = "SRS-X"
|
|
|
|
SRS.hash = "Reversed SRS drop functions"
|
2020-12-04 19:53:09 -06:00
|
|
|
SRS.softdrop_lock = true
|
|
|
|
SRS.harddrop_lock = false
|
|
|
|
|
|
|
|
SRS.colourscheme = {
|
|
|
|
I = "R",
|
|
|
|
L = "O",
|
|
|
|
J = "B",
|
|
|
|
S = "M",
|
|
|
|
Z = "G",
|
|
|
|
O = "Y",
|
|
|
|
T = "C",
|
2020-11-14 09:43:01 -06:00
|
|
|
}
|
|
|
|
|
2020-12-28 16:11:30 -06:00
|
|
|
SRS.MANIPULATIONS_MAX = 24
|
|
|
|
SRS.ROTATIONS_MAX = 12
|
|
|
|
|
|
|
|
function SRS:onPieceDrop(piece, grid)
|
|
|
|
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
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-14 09:43:01 -06:00
|
|
|
function SRS:onPieceMove(piece, grid)
|
|
|
|
piece.lock_delay = 0 -- move reset
|
|
|
|
if piece:isDropBlocked(grid) then
|
|
|
|
piece.manipulations = piece.manipulations + 1
|
2020-12-28 16:11:30 -06:00
|
|
|
if piece.manipulations >= self.MANIPULATIONS_MAX then
|
2020-11-14 09:43:01 -06:00
|
|
|
piece.locked = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function SRS:onPieceRotate(piece, grid)
|
|
|
|
piece.lock_delay = 0 -- rotate reset
|
|
|
|
if piece:isDropBlocked(grid) then
|
2020-12-28 16:11:30 -06:00
|
|
|
piece.rotations = piece.rotations + 1
|
|
|
|
if piece.rotations >= self.ROTATIONS_MAX then
|
2020-11-14 09:43:01 -06:00
|
|
|
piece.locked = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-12-04 20:45:52 -06:00
|
|
|
function SRS:get180RotationValue() return 2 end
|
|
|
|
|
2020-11-14 09:43:01 -06:00
|
|
|
return SRS
|