cambridge-modpack/tetris/rulesets/pptprs.lua

113 lines
3.3 KiB
Lua
Raw Normal View History

2020-11-11 21:24:56 -06:00
local Piece = require 'tetris.components.piece'
2021-01-28 20:09:42 -06:00
local SRS = require 'tetris.rulesets.standard'
2020-11-11 21:24:56 -06:00
local PPTPRS = SRS:extend()
PPTPRS.name = "PPTPRS"
PPTPRS.hash = "Puyo Tetris Pentos"
2021-01-07 18:03:40 -06:00
PPTPRS.spawn_positions = {
2021-01-12 12:38:08 -06:00
I = { x=5, y=4 },
2021-02-08 22:24:05 -06:00
J = { x=4, y=5 },
L = { x=4, y=5 },
O = { x=5, y=5 },
S = { x=5, y=5 },
2021-01-12 12:38:08 -06:00
T = { x=4, y=5 },
2021-02-08 22:24:05 -06:00
Z = { x=4, y=5 },
2021-01-07 18:03:40 -06:00
}
2020-11-11 21:24:56 -06:00
PPTPRS.block_offsets = {
I={
{ {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0}, {x=-3, y=0} },
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=0, y=2}, {x=0, y=-2} },
{ {x=0, y=1}, {x=-1, y=1}, {x=-2, y=1}, {x=1, y=1}, {x=2, y=1} },
{ {x=-1, y=0}, {x=-1, y=-1}, {x=-1, y=1}, {x=-1, y=2}, {x=-1, y=3} },
},
J={
2021-01-07 18:03:40 -06:00
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=-1, y=-2}, {x=0, y=0} },
{ {x=0, y=-1}, {x=0, y=-2}, {x=0, y=0} , {x=1, y=-2}, {x=-1, y=-1} },
{ {x=0, y=-1}, {x=1, y=-1}, {x=-1, y=-1}, {x=1, y=0}, {x=0, y=-2} },
{ {x=0, y=-1}, {x=0, y=0}, {x=0, y=-2}, {x=-1, y=0}, {x=1, y=-1} },
2020-11-11 21:24:56 -06:00
},
L={
2021-01-07 18:03:40 -06:00
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=1, y=-2}, {x=-1, y=0} },
{ {x=0, y=-1}, {x=0, y=-2}, {x=0, y=0}, {x=1, y=0}, {x=-1, y=-2} },
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=1, y=-2}, {x=-1, y=0} },
{ {x=0, y=-1}, {x=0, y=-2}, {x=0, y=0}, {x=1, y=0}, {x=-1, y=-2} },
2020-11-11 21:24:56 -06:00
},
O={
2021-01-07 18:03:40 -06:00
{ {x=0, y=-1}, {x=-1, y=-1}, {x=-1, y=-2}, {x=0, y=-2}, {x=-1, y=0} },
{ {x=0, y=-1}, {x=-1, y=-1}, {x=-1, y=-2}, {x=0, y=-2}, {x=-2, y=-2} },
{ {x=0, y=-1}, {x=-1, y=-1}, {x=-1, y=-2}, {x=0, y=-2}, {x=0, y=-3} },
{ {x=0, y=-1}, {x=-1, y=-1}, {x=-1, y=-2}, {x=0, y=-2}, {x=1, y=-1} },
2020-11-11 21:24:56 -06:00
},
S={
{ {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0} },
{ {x=1, y=1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=-1}, {x=0, y=-2} },
{ {x=-1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=1, y=0}, {x=2, y=0} },
{ {x=-1, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=1}, {x=0, y=2} },
},
T={
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=0, y=-1}, {x=0, y=-2} },
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=0}, {x=2, y=0} },
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=0, y=1}, {x=0, y=2} },
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=0}, {x=-2, y=0} },
},
Z={
2021-01-07 18:03:40 -06:00
{ {x=-1, y=-2}, {x=0, y=-2}, {x=0, y=-1}, {x=1, y=-1}, {x=1, y=0} },
{ {x=1, y=-2}, {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} },
{ {x=1, y=0}, {x=0, y=0}, {x=0, y=-1}, {x=-1, y=-1}, {x=-1, y=-2} },
{ {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=-2}, {x=1, y=-2} },
2020-11-11 21:24:56 -06:00
}
}
PPTPRS.wallkicks_O = {
[0]={
[1]={{x=0, y=1}},
[2]={{x=0, y=1}},
[3]={{x=-1, y=0}},
},
[1]={
[0]={{x=0, y=-1}},
[2]={{x=-1, y=0}},
[3]={{x=-1, y=0}},
},
[2]={
[0]={{x=0, y=-1}},
[1]={{x=1, y=0}},
[3]={{x=0, y=-1}},
},
[3]={
[0]={{x=1, y=0}},
[1]={{x=1, y=0}},
[2]={{x=0, y=1}},
},
}
function PPTPRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
2020-12-28 16:11:30 -06:00
local kicks
2020-11-11 21:24:56 -06:00
if piece.shape == "O" then
kicks = PPTPRS.wallkicks_O[piece.rotation][new_piece.rotation]
elseif 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)
2021-02-17 13:49:01 -06:00
self:onPieceRotate(piece, grid, offset.y < 0)
2020-11-11 21:24:56 -06:00
return
end
end
end
return PPTPRS