cambridge-modpack/tetris/rulesets/shirase.lua

95 lines
2.9 KiB
Lua
Raw Normal View History

2021-02-08 22:24:05 -06:00
local SRS = require 'tetris.rulesets.standard'
2021-01-10 10:03:12 -06:00
local Shirase = SRS:extend()
Shirase.name = "Shirase RS"
Shirase.hash = "Shirase"
2021-02-11 14:58:35 -06:00
Shirase.world = false
2021-01-10 10:03:12 -06:00
Shirase.colourscheme = {
I = "R",
J = "R",
L = "R",
O = "R",
S = "R",
T = "R",
Z = "R"
}
Shirase.block_offsets = {
I={
{ {x=-2, y=0}, {x=-1, y=0}, {x=0, y=0}, {x=1, y=0} },
{ {x=1, y=-2}, {x=1, y=-1}, {x=1, y=0}, {x=1, y=1} },
{ {x=0, y=1}, {x=1, y=1}, {x=2, y=1}, {x=3, y=1} },
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=2}, {x=0, y=3} },
},
J={
{ {x=-1, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=1, y=0} },
{ {x=1, y=-2}, {x=2, y=-2}, {x=1, y=-1}, {x=1, y=0} },
{ {x=1, y=0}, {x=2, y=0}, {x=3, y=0}, {x=3, y=1} },
{ {x=1, y=0}, {x=1, y=1}, {x=0, y=2}, {x=1, y=2} },
},
L={
{ {x=1, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=1, y=0} },
{ {x=1, y=-2}, {x=1, y=-1}, {x=1, y=0}, {x=2, y=0} },
{ {x=1, y=0}, {x=2, y=0}, {x=3, y=0}, {x=1, y=1} },
{ {x=0, y=0}, {x=1, y=0}, {x=1, y=1}, {x=1, y=2} },
},
O={
{ {x=-1, y=-1}, {x=0, y=-1}, {x=-1, y=0}, {x=0, y=0} },
{ {x=0, y=-2}, {x=1, y=-2}, {x=0, y=-1}, {x=1, y=-1} },
{ {x=1, y=-1}, {x=2, y=-1}, {x=1, y=0}, {x=2, y=0} },
{ {x=0, y=0}, {x=1, y=0}, {x=0, y=1}, {x=1, y=1} },
},
S={
{ {x=0, y=-1}, {x=1, y=-1}, {x=-1, y=0}, {x=0, y=0} },
{ {x=1, y=-2}, {x=1, y=-1}, {x=2, y=-1}, {x=2, y=0} },
{ {x=2, y=0}, {x=3, y=0}, {x=1, y=1}, {x=2, y=1} },
{ {x=0, y=0}, {x=0, y=1}, {x=1, y=1}, {x=1, y=2} },
},
T={
{ {x=0, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=1, y=0} },
{ {x=1, y=-2}, {x=1, y=-1}, {x=2, y=-1}, {x=1, y=0} },
{ {x=1, y=0}, {x=2, y=0}, {x=3, y=0}, {x=2, y=1} },
{ {x=1, y=0}, {x=0, y=1}, {x=1, y=1}, {x=1, y=2} },
},
Z={
{ {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=1, y=0} },
{ {x=2, y=-2}, {x=1, y=-1}, {x=2, y=-1}, {x=1, y=0} },
{ {x=1, y=0}, {x=2, y=0}, {x=2, y=1}, {x=3, y=1} },
{ {x=1, y=0}, {x=0, y=1}, {x=1, y=1}, {x=0, y=2} },
}
}
2021-01-10 19:56:26 -06:00
function Shirase:attemptWallkicks(piece, new_piece, rot_dir, grid)
local kicks
if piece.shape == "I" then
kicks = SRS.wallkicks_line[piece.rotation][new_piece.rotation]
else
kicks = SRS.wallkicks_3x3[piece.rotation][new_piece.rotation]
end
assert(piece.rotation ~= new_piece.rotation)
for idx, offset in pairs(kicks) do
kicked_piece = new_piece:withOffset(offset)
if grid:canPlacePiece(kicked_piece) then
piece:setRelativeRotation(rot_dir)
piece:setOffset(offset)
self:onPieceRotate(piece, grid)
return
end
end
end
2021-01-10 10:03:12 -06:00
function Shirase:onPieceDrop(piece) piece.lock_delay = 0 end
function Shirase:onPieceMove(piece) piece.lock_delay = 0 end
function Shirase:onPieceRotate(piece) piece.lock_delay = 0 end
2021-02-11 14:58:35 -06:00
function Shirase:getDefaultOrientation()
return math.random(4)
end
2021-01-10 10:03:12 -06:00
return Shirase