From ccb032ad4c8391b5c275fe0f55f3a545ff266356 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Sun, 7 Feb 2021 19:26:53 -0500 Subject: [PATCH] Joker now has a 21-tall board, Tengen added --- tetris/modes/joker.lua | 2 + tetris/rulesets/tengen.lua | 107 +++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 tetris/rulesets/tengen.lua diff --git a/tetris/modes/joker.lua b/tetris/modes/joker.lua index d406c5a..f11a09c 100644 --- a/tetris/modes/joker.lua +++ b/tetris/modes/joker.lua @@ -1,6 +1,7 @@ require 'funcs' local GameMode = require 'tetris.modes.gamemode' +local Grid = require 'tetris.components.grid' local Piece = require 'tetris.components.piece' local DTETRandomizer = require 'tetris.randomizers.dtet' @@ -16,6 +17,7 @@ JokerGame.tagline = "One of the hardest modes! Can you retain your stock to leve function JokerGame:new() self.super:new() + self.grid = Grid(10, 25) self.randomizer = DTETRandomizer() self.level = 50 diff --git a/tetris/rulesets/tengen.lua b/tetris/rulesets/tengen.lua new file mode 100644 index 0000000..6019d9f --- /dev/null +++ b/tetris/rulesets/tengen.lua @@ -0,0 +1,107 @@ +local Piece = require 'tetris.components.piece' +local Ruleset = require 'tetris.rulesets.ruleset' + +local Tengen = Ruleset:extend() + +Tengen.name = "Tengen" +Tengen.hash = "Tengen" +Tengen.colourscheme = { + I = "R", + J = "O", + L = "M", + O = "B", + S = "G", + T = "Y", + Z = "C" +} + +Tengen.spawn_positions = { + I = { x=3, y=4 }, + J = { x=4, y=5 }, + L = { x=4, y=5 }, + O = { x=4, y=5 }, + S = { x=4, y=5 }, + T = { x=4, y=5 }, + Z = { x=4, y=5 }, +} + +Tengen.big_spawn_positions = { + I = { x=1, y=2 }, + J = { x=2, y=3 }, + L = { x=2, y=3 }, + O = { x=2, y=3 }, + S = { x=2, y=3 }, + T = { x=2, y=3 }, + Z = { x=2, y=3 }, +} + +Tengen.block_offsets = { + I={ + { {x=0, y=0}, {x=1, y=0}, {x=2, y=0}, {x=3, y=0} }, + { {x=1, y=0}, {x=1, y=1}, {x=1, y=2}, {x=1, y=3} }, + { {x=0, y=0}, {x=1, y=0}, {x=2, y=0}, {x=3, y=0} }, + { {x=1, y=0}, {x=1, y=1}, {x=1, y=2}, {x=1, y=3} }, + }, + J={ + { {x=-1, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=1, y=0} }, + { {x=-1, y=-1}, {x=0, y=-1}, {x=-1, y=0}, {x=-1, y=1} }, + { {x=-1, y=-1}, {x=0, y=-1}, {x=1, y=-1}, {x=1, y=0} }, + { {x=0, y=-1}, {x=0, y=0}, {x=-1, y=1}, {x=0, y=1} }, + }, + L={ + { {x=1, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=1, y=0} }, + { {x=-1, y=-1}, {x=-1, y=0}, {x=-1, y=1}, {x=0, y=1} }, + { {x=-1, y=-1}, {x=0, y=-1}, {x=1, y=-1}, {x=-1, y=0} }, + { {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=0, y=1} }, + }, + O={ + { {x=0, y=-1}, {x=1, y=-1}, {x=0, y=0}, {x=1, y=0} }, + { {x=0, y=-1}, {x=1, y=-1}, {x=0, y=0}, {x=1, y=0} }, + { {x=0, y=-1}, {x=1, y=-1}, {x=0, y=0}, {x=1, y=0} }, + { {x=0, y=-1}, {x=1, y=-1}, {x=0, y=0}, {x=1, y=0} }, + }, + S={ + { {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=0}, {x=0, y=1} }, + { {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=0}, {x=0, y=1} }, + }, + T={ + { {x=0, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=1, y=0} }, + { {x=-1, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=-1, y=1} }, + { {x=-1, y=-1}, {x=0, y=-1}, {x=1, y=-1}, {x=0, y=0} }, + { {x=0, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=1} }, + }, + Z={ + { {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=1, y=0} }, + { {x=0, y=-1}, {x=-1, y=0}, {x=0, 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=-1, y=0}, {x=0, y=0}, {x=-1, y=1} }, + } +} + + +-- Component functions. + +function Tengen:attemptWallkicks(piece, new_piece, rot_dir, grid) + + -- O doesn't kick + if (piece.shape == "O") then return end + + if (grid:canPlacePiece(new_piece:withOffset({x=-1, y=0}))) then + piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0}) + end + +end + +function Tengen:onPieceDrop(piece, grid) + piece.lock_delay = 0 -- step reset +end + +function Tengen:get180RotationValue() + return 3 +end + +function Tengen:getDefaultOrientation() return 3 end -- downward facing pieces by default + +return Tengen