diff --git a/tetris/modes/duality_a1.lua b/tetris/modes/duality_a1.lua index c0247e0..cef7116 100644 --- a/tetris/modes/duality_a1.lua +++ b/tetris/modes/duality_a1.lua @@ -8,8 +8,8 @@ DualityA1Game.name = "Duality A1" DualityA1Game.hash = "DualityA1" DualityA1Game.tagline = "Control two boards at once!" -function DualityA1Game:new() - DualityA1Game.super:new() +function DualityA1Game:new(_, c) + DualityA1Game.super:new(_, c) self.randomizer = SplitHistoryRandomizer() self.other_grid = Grid(10, 24) self.next_queue_length = 2 diff --git a/tetris/modes/inversion_a2n.lua b/tetris/modes/inversion_a2n.lua index 4824f19..fae51fd 100644 --- a/tetris/modes/inversion_a2n.lua +++ b/tetris/modes/inversion_a2n.lua @@ -6,8 +6,8 @@ InversionGame.name = "Inversion A2N" InversionGame.hash = "InversionA2N" InversionGame.tagline = "What if the active piece was invisible?" -function InversionGame:new() - SurvivalA2Game:new() +function InversionGame:new(_, c) + SurvivalA2Game:new(_,c) self.piece_active_time = 0 end diff --git a/tetris/modes/marathon_c99.lua b/tetris/modes/marathon_c99.lua index fa75c0e..5489202 100644 --- a/tetris/modes/marathon_c99.lua +++ b/tetris/modes/marathon_c99.lua @@ -47,8 +47,10 @@ local slots_table = { local slot_popup = {["text"]="",["time"]=0,["slotnum"]=0} local line_popup = {["y"]=0,["score"]=0,["lines"]=0} -function MarathonC99Game:new() - self.super:new() +function MarathonC99Game:new(_, cfg) + if cfg == nil then cfg = {} end -- Don't break older Cambridge versions + + self.super:new(_, cfg) self.grid = Grid(10, 22) self.slots_random = love.math.newRandomGenerator(os.time()) @@ -60,10 +62,11 @@ function MarathonC99Game:new() self.tetris_slots = 0 self.ccw_bonus = 10 ^ 7 slot_popup = {["text"]="",["time"]=0} - self.irs = false - self.enable_hard_drop = false + self.irs = cfg.irs == 2 + self.enable_hard_drop = cfg.hardDrop == 2 self.lock_drop = false - self.next_queue_length = 1 + self.next_queue_length = cfg.nextQueue == 2 and 3 or 1 + self.enable_hold = cfg.hold == 2 end function MarathonC99Game:getARE() @@ -165,10 +168,11 @@ function MarathonC99Game:advanceOneFrame(inputs, ruleset) self.frames = self.frames + 1 end if self.piece ~= nil then + local lo = self.piece.last_orientation or self.piece.rotation if not ( - self.piece.rotation - self.piece.last_orientation == -1 or -- 3 >> 2, 2 >> 1, 1 >> 0 - self.piece.rotation - self.piece.last_orientation == 3 or -- 0 >> 3 - self.piece.rotation - self.piece.last_orientation == 0 -- not rotated + self.piece.rotation - lo == -1 or -- 3 >> 2, 2 >> 1, 1 >> 0 + self.piece.rotation - lo == 3 or -- 0 >> 3 + self.piece.rotation - lo == 0 -- not rotated ) then self.ccw_bonus = 0 end @@ -272,6 +276,9 @@ function MarathonC99Game:drawGrid() love.graphics.printf(line_popup.score,40,line_popup.y-1,200,"center") end self.grid:draw() + if self.piece ~= nil and self.config.ghostPiece == 2 then + self:drawGhostPiece(ruleset) + end end function MarathonC99Game:drawScoringInfo() @@ -372,4 +379,14 @@ function MarathonC99Game:getHighscoreData() } end +function MarathonC99Game:provideSettings() + return { + {"hardDrop", "Hard Drop", {"Off", "On"}}, + {"irs", "IRS", {"Off", "On"}}, + {"nextQueue", "Next pieces", {"One", "Three"}}, + {"hold", "Hold", {"Off", "On"}}, + {"ghostPiece", "Ghost piece", {"Off", "On"}} + } +end + return MarathonC99Game \ No newline at end of file diff --git a/tetris/modes/survival_a2n.lua b/tetris/modes/survival_a2n.lua index 3c883a7..a2b3cc6 100644 --- a/tetris/modes/survival_a2n.lua +++ b/tetris/modes/survival_a2n.lua @@ -6,8 +6,8 @@ SurvivalA2NGame.name = "Survival A2N" SurvivalA2NGame.hash = "SurvivalA2N" SurvivalA2NGame.tagline = "A variation of Survival A2 for Carnival of Derp." -function SurvivalA2NGame:new() - self.super:new() +function SurvivalA2NGame:new(_, c) + self.super:new(_, c) self.next_queue_length = 3 self.enable_hold = true end diff --git a/tetris/rulesets/prs.lua b/tetris/rulesets/prs.lua new file mode 100644 index 0000000..3af2596 --- /dev/null +++ b/tetris/rulesets/prs.lua @@ -0,0 +1,55 @@ +local SRS = require 'tetris.rulesets.standard' + +local PRS = SRS:extend() + +PRS.name = "Permissive Rotation System" +PRS.hash = "PRS" +PRS.world = true + +function PRS:attemptRotate(new_inputs, piece, grid, initial) + local rot_dir = 0 + + if (new_inputs["rotate_left"] or new_inputs["rotate_left2"]) then + rot_dir = 3 + elseif (new_inputs["rotate_right"] or new_inputs["rotate_right2"]) then + rot_dir = 1 + elseif (new_inputs["rotate_180"]) then + rot_dir = self:get180RotationValue() + end + + if rot_dir == 0 then return end + + if config.gamesettings.world_reverse == 3 or (self.world and config.gamesettings.world_reverse == 2) then + rot_dir = 4 - rot_dir + end + + local new_piece = piece:withRelativeRotation(rot_dir) + self:attemptWallkicks(piece, new_piece, rot_dir, grid) +end + +function PRS:attemptWallkicks(piece, newpiece, rot_dir, grid) + for y=0,5 do + for x=0,5 do + local offset = {x=x, y=y} + kicked_piece = newpiece:withOffset(offset) + if grid:canPlacePiece(kicked_piece) then + piece:setRelativeRotation(rot_dir) + piece:setOffset(offset) + self:onPieceRotate(piece, grid) + return + end + end + for x=0,5 do + local offset = {x=-x, y=y} + kicked_piece = newpiece:withOffset(offset) + if grid:canPlacePiece(kicked_piece) then + piece:setRelativeRotation(rot_dir) + piece:setOffset(offset) + self:onPieceRotate(piece, grid) + return + end + end + end +end + +return PRS \ No newline at end of file diff --git a/tetris/rulesets/sprs.lua b/tetris/rulesets/sprs.lua new file mode 100644 index 0000000..c22a207 --- /dev/null +++ b/tetris/rulesets/sprs.lua @@ -0,0 +1,56 @@ +local PRS = require 'tetris.rulesets.prs' + +local SPRS = PRS:extend() + +SPRS.name = "Super P.R.S" +SPRS.hash = "SuperPRS" +SPRS.world = true + +function SPRS:attemptWallkicks(piece, newpiece, rot_dir, grid) + for y=0,5 do + for x=0,5 do + local offset = {x=x, y=y} + kicked_piece = newpiece:withOffset(offset) + if grid:canPlacePiece(kicked_piece) then + piece:setRelativeRotation(rot_dir) + piece:setOffset(offset) + self:onPieceRotate(piece, grid) + return + end + end + for x=0,5 do + local offset = {x=-x, y=y} + kicked_piece = newpiece:withOffset(offset) + if grid:canPlacePiece(kicked_piece) then + piece:setRelativeRotation(rot_dir) + piece:setOffset(offset) + self:onPieceRotate(piece, grid) + return + end + end + end + for y=0,-5,-1 do + for x=0,5 do + local offset = {x=x, y=y} + kicked_piece = newpiece:withOffset(offset) + if grid:canPlacePiece(kicked_piece) then + piece:setRelativeRotation(rot_dir) + piece:setOffset(offset) + self:onPieceRotate(piece, grid) + return + end + end + for x=0,5 do + local offset = {x=-x, y=y} + kicked_piece = newpiece:withOffset(offset) + if grid:canPlacePiece(kicked_piece) then + piece:setRelativeRotation(rot_dir) + piece:setOffset(offset) + self:onPieceRotate(piece, grid) + return + end + end + end +end + +return SPRS \ No newline at end of file