cambridge-modpack/tetris/rulesets/thenew.lua

126 lines
3.2 KiB
Lua
Raw Permalink Normal View History

2020-11-20 13:30:40 -06:00
local Piece = require 'tetris.components.piece'
local Ruleset = require 'tetris.rulesets.ruleset'
2021-01-12 12:49:48 -06:00
local TheNew = Ruleset:extend()
2020-11-20 13:30:40 -06:00
2021-01-12 12:49:48 -06:00
TheNew.name = "The Newtris"
TheNew.hash = "TheNew"
2020-11-20 13:30:40 -06:00
2021-01-12 12:49:48 -06:00
TheNew.softdrop_lock = false
TheNew.harddrop_lock = false
2020-11-20 13:30:40 -06:00
2021-01-12 12:49:48 -06:00
TheNew.colourscheme = {
2020-11-20 13:30:40 -06:00
I = "C",
J = "B",
L = "M",
O = "W",
2020-11-20 13:30:40 -06:00
S = "G",
Z = "R",
T = "Y"
}
2021-02-08 22:24:05 -06:00
TheNew.spawn_above_field = true
2020-11-20 13:30:40 -06:00
2021-01-12 12:49:48 -06:00
TheNew.spawn_positions = {
I = { x=5, y=4 },
J = { x=4, y=5 },
L = { x=4, y=5 },
O = { x=5, y=5 },
S = { x=4, y=5 },
T = { x=4, y=5 },
Z = { x=4, y=5 },
2020-11-20 13:30:40 -06:00
}
2021-01-12 12:49:48 -06:00
TheNew.big_spawn_positions = {
2020-11-20 13:30:40 -06:00
I = { x=3, y=2 },
J = { x=2, y=3 },
L = { x=2, y=3 },
O = { x=3, y=3 },
S = { x=2, y=3 },
T = { x=2, y=3 },
Z = { x=2, y=3 },
}
2021-01-12 12:49:48 -06:00
TheNew.block_offsets = {
2020-11-20 13:30:40 -06:00
T={
2021-01-13 17:43:08 -06:00
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=0, y=1} },
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=0} },
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=0, y=-1} },
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=0} },
},
2020-11-20 13:30:40 -06:00
I={
{ {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} },
{ {x=-1, y=-1}, {x=-1, y=-2}, {x=-1, y=0}, {x=-1, y=1} },
{ {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} },
{ {x=-1, y=-1}, {x=-1, y=-2}, {x=-1, y=0}, {x=-1, y=1} },
},
O={
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
},
S={
{ {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} },
{ {x=0, y=-1}, {x=0, y=0}, {x=1, y=0}, {x=1, y=1} },
{ {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} },
{ {x=0, y=-1}, {x=0, y=0}, {x=1, y=0}, {x=1, y=1} },
},
Z={
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=0}, {x=0, y=0} },
{ {x=-1, y=1}, {x=-1, y=0}, {x=0, y=-1}, {x=0, y=0} },
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=0}, {x=0, y=0} },
{ {x=-1, y=1}, {x=-1, y=0}, {x=0, y=-1}, {x=0, y=0} },
},
J={
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=-1} },
{ {x=0, y=0}, {x=0, y=-1}, {x=1, y=-1}, {x=0, y=1} },
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=1, y=0} },
{ {x=1, y=0}, {x=1, y=-1}, {x=1, y=1}, {x=0, y=1} },
},
L={
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=1, y=-1} },
{ {x=-1, y=-1}, {x=-1, y=0}, {x=0, y=1}, {x=-1, y=1} },
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=-1, y=0} },
{ {x=0, y=0}, {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=1} },
},
}
2021-01-12 12:49:48 -06:00
TheNew.wallkicks_ccw = {{x=0, y=1}, {x=-1, y=0}, {x=1, y=0}, {x=0, y=-1}}
TheNew.wallkicks_cw = {{x=0, y=1}, {x=1, y=0}, {x=-1, y=0}, {x=0, y=-1}}
2020-11-20 13:30:40 -06:00
2021-01-12 12:49:48 -06:00
function TheNew:attemptWallkicks(piece, new_piece, rot_dir, grid)
2020-11-20 13:30:40 -06:00
local kicks
if piece.shape == "O" then
return
elseif rot_dir == 1 then
2021-01-12 12:49:48 -06:00
kicks = TheNew.wallkicks_cw
2020-11-20 13:30:40 -06:00
else
2021-01-12 12:49:48 -06:00
kicks = TheNew.wallkicks_ccw
2020-11-20 13:30:40 -06:00
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
2020-12-04 19:53:09 -06:00
self:onPieceRotate(piece, grid)
2020-11-20 13:30:40 -06:00
piece:setRelativeRotation(rot_dir)
piece:setOffset(offset)
return
end
end
end
2021-01-12 12:49:48 -06:00
function TheNew:onPieceDrop(piece, grid)
2020-11-20 13:30:40 -06:00
piece.lock_delay = 0 -- step reset
end
2021-01-12 12:49:48 -06:00
function TheNew:get180RotationValue()
2021-01-28 20:09:42 -06:00
return 3
2020-11-20 13:30:40 -06:00
end
2021-01-12 12:49:48 -06:00
function TheNew:getDefaultOrientation() return 3 end
2020-11-20 13:30:40 -06:00
2021-01-12 12:49:48 -06:00
return TheNew