From 36c6a7c5a5d68aa70f62ad14ddb496125b6b6e63 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Tue, 12 Jan 2021 13:38:08 -0500 Subject: [PATCH] Ruleset update --- tetris/rulesets/extended_sega.lua | 32 +++++ tetris/rulesets/mizu_rs.lua | 28 ++--- tetris/rulesets/mob_deluxe.lua | 198 ++++++++++++++++++++++++++++++ tetris/rulesets/nintendo_r.lua | 10 ++ tetris/rulesets/pptprs.lua | 14 +-- 5 files changed, 261 insertions(+), 21 deletions(-) create mode 100644 tetris/rulesets/extended_sega.lua create mode 100644 tetris/rulesets/mob_deluxe.lua diff --git a/tetris/rulesets/extended_sega.lua b/tetris/rulesets/extended_sega.lua new file mode 100644 index 0000000..1b1405d --- /dev/null +++ b/tetris/rulesets/extended_sega.lua @@ -0,0 +1,32 @@ +local Sega = require 'tetris.rulesets.sega' + +local ExtendedSega = Sega:extend() + +ExtendedSega.name = "Extended Sega" +ExtendedSega.hash = "ExtendedSega" + +function ExtendedSega:attemptWallkicks(piece, new_piece, rot_dir, grid) + if piece.shape == "I" or piece.shape == "O" then return end + + local kick_dir = "none" + + for _, offset in pairs(new_piece:getBlockOffsets()) do + if piece.position.x + offset.x < 0 then + kick_dir = "right" + break + elseif piece.position.x + offset.x >= grid.width then + kick_dir = "left" + break + end + end + + if kick_dir == "none" then + return + elseif kick_dir == "right" and (grid:canPlacePiece(new_piece:withOffset({x=1, y=0}))) then + piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0}) + elseif kick_dir == "left" and (grid:canPlacePiece(new_piece:withOffset({x=-1, y=0}))) then + piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0}) + end +end + +return ExtendedSega \ No newline at end of file diff --git a/tetris/rulesets/mizu_rs.lua b/tetris/rulesets/mizu_rs.lua index 8476622..b379fb7 100644 --- a/tetris/rulesets/mizu_rs.lua +++ b/tetris/rulesets/mizu_rs.lua @@ -20,23 +20,23 @@ MizuRS.colourscheme = { } MizuRS.spawn_positions = { - I = { x=5, y=2 }, - J = { x=4, y=3 }, - L = { x=4, y=3 }, - O = { x=5, y=3 }, - S = { x=4, y=3 }, - T = { x=4, y=3 }, - Z = { x=4, y=3 }, + 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 }, } MizuRS.big_spawn_positions = { - I = { x=3, y=0 }, - J = { x=2, y=1 }, - L = { x=2, y=1 }, - O = { x=3, y=1 }, - S = { x=2, y=1 }, - T = { x=2, y=1 }, - Z = { x=2, y=1 }, + 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 }, } MizuRS.block_offsets = { diff --git a/tetris/rulesets/mob_deluxe.lua b/tetris/rulesets/mob_deluxe.lua new file mode 100644 index 0000000..aaf10f6 --- /dev/null +++ b/tetris/rulesets/mob_deluxe.lua @@ -0,0 +1,198 @@ +local Piece = require 'tetris.components.piece' +local Ruleset = require 'tetris.rulesets.ruleset' + +local SRS = Ruleset:extend() + +SRS.name = "MoB-Deluxe" +SRS.hash = "Spiderman losing his grip" +SRS.world = true +SRS.colourscheme = { + I = "C", + L = "O", + J = "B", + S = "G", + Z = "R", + O = "Y", + T = "M", +} +SRS.softdrop_lock = false +SRS.harddrop_lock = true + +SRS.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 }, +} + +SRS.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 }, +} + +SRS.block_offsets = { + I={ + { {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} }, + { {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=0, y=2} }, + { {x=0, y=1}, {x=-1, y=1}, {x=-2, y=1}, {x=1, y=1} }, + { {x=-1, y=0}, {x=-1, y=-1}, {x=-1, y=1}, {x=-1, y=2} }, + }, + 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=0, y=1} , {x=1, y=-1} }, + { {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=0, y=-1}, {x=-1, y=1} }, + }, + L={ + { {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=0, y=1}, {x=1, y=1} }, + { {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=0, y=-1}, {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=1, y=1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=-1} }, + { {x=-1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=1, y=0} }, + { {x=-1, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=1} }, + }, + T={ + { {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} }, + }, + Z={ + { {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=1, y=0} }, + { {x=1, y=-1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=1} }, + { {x=1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=-1, y=0} }, + { {x=-1, y=1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=-1} }, + } +} + +SRS.wallkicks_3x3 = { + [0]={ + [1]={{x=-1, y=0}, {x=-1, y=-1}}, + [2]={}, + [3]={{x=1, y=0}, {x=1, y=-1}}, + }, + [1]={ + [0]={{x=1, y=0}, {x=1, y=1}}, + [2]={{x=1, y=0}, {x=1, y=-1}}, + [3]={}, + }, + [2]={ + [0]={}, + [1]={{x=-1, y=0}, {x=-1, y=1}}, + [3]={{x=1, y=0}, {x=1, y=1}}, + }, + [3]={ + [0]={{x=-1, y=0}, {x=-1, y=1}}, + [1]={}, + [2]={{x=-1, y=0}, {x=-1, y=-1}}, + }, +}; + +SRS.wallkicks_line = { + [0]={ + [1]={{x=-1, y=0}, {x=-1, y=-1}, {x=1, y=0}, {x=1, y=1}}, + [2]={}, + [3]={{x=1, y=0}, {x=1, y=-1}, {x=-1, y=0}, {x=-1, y=-1}}, + }, + [1]={ + [0]={{x=1, y=0}, {x=1, y=1}, {x=-1, y=0}, {x=-1, y=-1}}, + [2]={{x=1, y=0}, {x=1, y=-1}, {x=-1, y=0}, {x=-1, y=1}}, + [3]={}, + }, + [2]={ + [0]={}, + [1]={{x=-1, y=0}, {x=-1, y=1}, {x=1, y=0}, {x=1, y=-1}}, + [3]={{x=1, y=0}, {x=1, y=1}, {x=-1, y=0}, {x=-1, y=-1}}, + }, + [3]={ + [0]={{x=-1, y=0}, {x=-1, y=1}, {x=1, y=0}, {x=1, y=-1}}, + [1]={}, + [2]={{x=-1, y=0}, {x=-1, y=-1}, {x=1, y=0}, {x=1, y=1}}, + }, +}; + +-- Component functions. + +function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid) + + local kicks + if piece.shape == "O" then + return + 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 + self:onPieceRotate(piece, grid) + piece:setRelativeRotation(rot_dir) + piece:setOffset(offset) + return + end + end + +end + +function SRS:onPieceCreate(piece, grid) + piece.manipulations = 0 + piece.rotations = 0 +end + +function SRS:onPieceDrop(piece, grid) + piece.lock_delay = 0 -- step reset +end + +function SRS:onPieceMove(piece, grid) + piece.lock_delay = 0 -- move reset + if piece:isDropBlocked(grid) then + piece.manipulations = piece.manipulations + 1 + if piece.manipulations >= 10 then + piece:dropToBottom(grid) + piece.locked = true + end + end +end + +function SRS:onPieceRotate(piece, grid) + piece.lock_delay = 0 -- rotate reset + if piece:isDropBlocked(grid) then + piece.rotations = piece.rotations + 1 + if piece.rotations >= 8 then + piece:dropToBottom(grid) + piece.locked = true + end + end +end + +function SRS:get180RotationValue() + if config.gamesettings.world_reverse == 1 then + return 1 + else + return 3 + end +end + +return SRS diff --git a/tetris/rulesets/nintendo_r.lua b/tetris/rulesets/nintendo_r.lua index a325124..2908caa 100644 --- a/tetris/rulesets/nintendo_r.lua +++ b/tetris/rulesets/nintendo_r.lua @@ -15,6 +15,16 @@ Nintendo.spawn_positions = { Z = { x=4, y=5 }, } +Nintendo.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 }, +} + Nintendo.block_offsets = { I={ { {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} }, diff --git a/tetris/rulesets/pptprs.lua b/tetris/rulesets/pptprs.lua index cac5f3f..804429d 100644 --- a/tetris/rulesets/pptprs.lua +++ b/tetris/rulesets/pptprs.lua @@ -7,13 +7,13 @@ PPTPRS.name = "PPTPRS" PPTPRS.hash = "Puyo Tetris Pentos" PPTPRS.spawn_positions = { - I = { x=5, y=2 }, - J = { x=4, y=2 }, - L = { x=4, y=2 }, - O = { x=5, y=2 }, - S = { x=4, y=3 }, - T = { x=4, y=3 }, - Z = { x=4, y=2 }, + I = { x=5, y=4 }, + J = { x=4, y=4 }, + L = { x=4, y=4 }, + O = { x=5, y=4 }, + S = { x=4, y=5 }, + T = { x=4, y=5 }, + Z = { x=4, y=4 }, } PPTPRS.block_offsets = {