Some more rulesets + a gamemode

This commit is contained in:
Ishaan Bhardwaj 2020-11-20 14:30:40 -05:00
parent 9df0501cf5
commit 122e0c6a36
3 changed files with 173 additions and 1 deletions

View File

@ -59,7 +59,7 @@ function JokerGame:onLineClear(cleared_row_count)
self.time_limit = math.min(self.time_limit + frameTime(0,15), frameTime(5,00)) self.time_limit = math.min(self.time_limit + frameTime(0,15), frameTime(5,00))
end end
if self.stock <= 0 and (self.level == 200 or self.level == 300) then self.game_over = true end if self.stock <= 0 and (self.level == 200 or self.level >= 300) then self.game_over = true end
end end
function JokerGame:drawGrid() self.grid:drawOutline() end function JokerGame:drawGrid() self.grid:drawOutline() end

View File

@ -0,0 +1,42 @@
local SRS = require 'tetris.rulesets.arika_srs'
local Cultris = SRS:extend()
Cultris.name = "Cultris II"
Cultris.hash = "Cultris"
Cultris.colourscheme = {
I = "G",
L = "M",
J = "B",
S = "C",
Z = "F",
O = "Y",
T = "R",
}
Cultris.wallkicks = {
{x=-1, y=0}, {x=1, y=0}, {x=0, y=1}, {x=-1, y=1}, {x=1, y=1}, {x=-2, y=0}, {x=2, y=0}
}
function Cultris:attemptWallkicks(piece, new_piece, rot_dir, grid)
local kicks = Cultris.wallkicks
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
function Cultris:onPieceMove() end
function Cultris:onPieceRotate() end
function Cultris:get180RotationValue() return 2 end
return Cultris

130
tetris/rulesets/thenext.lua Normal file
View File

@ -0,0 +1,130 @@
local Piece = require 'tetris.components.piece'
local Ruleset = require 'tetris.rulesets.ruleset'
local TheNext = Ruleset:extend()
TheNext.name = "The Next Tetris"
TheNext.hash = "TheNext"
TheNext.softdrop_lock = false
TheNext.harddrop_lock = false
TheNext.colourscheme = {
I = "C",
J = "B",
L = "M",
O = "A",
S = "G",
Z = "R",
T = "Y"
}
TheNext.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 },
}
TheNext.big_spawn_positions = {
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 },
}
TheNext.block_offsets = {
T={
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=0, y=-2} },
{ {x=0, y=-1}, {x=0, y=-2}, {x=0, y=0}, {x=1, y=-1} },
{ {x=0, y=-1}, {x=1, y=-1}, {x=-1, y=-1}, {x=0, y=0} },
{ {x=0, y=-1}, {x=0, y=0}, {x=0, y=-2}, {x=-1, y=-1} },
},
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} },
},
}
TheNext.wallkicks_ccw = {{x=-1, y=0}, {x=0, y=1}, {x=1, y=0}, {x=0, y=-1}}
TheNext.wallkicks_cw = {{x=1, y=0}, {x=0, y=1}, {x=-1, y=0}, {x=0, y=-1}}
function TheNext:attemptWallkicks(piece, new_piece, rot_dir, grid)
local kicks
if piece.shape == "O" then
return
elseif new_piece.rotation == piece.rotation + 1 or
(piece.rotation == 3 and new_piece.rotation == 0) then
kicks = TheNext.wallkicks_cw
else
kicks = TheNext.wallkicks_ccw
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
function TheNext:onPieceDrop(piece, grid)
piece.lock_delay = 0 -- step reset
end
function TheNext:get180RotationValue()
if config.gamesettings.world_reverse == 1 then
return 1
else
return 3
end
end
function TheNext:getDefaultOrientation() return 3 end
return TheNext