From 7cd07a4d97db2e33dc1a753bb755e042abea5b2f Mon Sep 17 00:00:00 2001 From: Rin Date: Sat, 21 Aug 2021 19:45:51 +0100 Subject: [PATCH 1/9] Add C99 mode settings --- tetris/modes/marathon_c99.lua | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tetris/modes/marathon_c99.lua b/tetris/modes/marathon_c99.lua index f872bf2..1a9b063 100644 --- a/tetris/modes/marathon_c99.lua +++ b/tetris/modes/marathon_c99.lua @@ -47,8 +47,8 @@ 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) + self.super:new(cfg) self.grid = Grid(10, 22) self.additive_gravity = false @@ -58,10 +58,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() @@ -262,6 +263,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() @@ -359,4 +363,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 From d22a5d821c9cc8db11632d88cb31104fee1761fc Mon Sep 17 00:00:00 2001 From: Rin Date: Sat, 21 Aug 2021 20:22:45 +0100 Subject: [PATCH 2/9] Fixes --- tetris/modes/duality_a1.lua | 4 ++-- tetris/modes/marathon_c99.lua | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tetris/modes/duality_a1.lua b/tetris/modes/duality_a1.lua index 701afb1..451c738 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/marathon_c99.lua b/tetris/modes/marathon_c99.lua index 1a9b063..ad45ce6 100644 --- a/tetris/modes/marathon_c99.lua +++ b/tetris/modes/marathon_c99.lua @@ -159,10 +159,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 From c6804d4367ad73194a3fffd2ed0fc6315a55894d Mon Sep 17 00:00:00 2001 From: Rin Date: Sat, 21 Aug 2021 20:31:46 +0100 Subject: [PATCH 3/9] Add permissive rotation system --- tetris/rulesets/prs.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tetris/rulesets/prs.lua diff --git a/tetris/rulesets/prs.lua b/tetris/rulesets/prs.lua new file mode 100644 index 0000000..6100ce3 --- /dev/null +++ b/tetris/rulesets/prs.lua @@ -0,0 +1,34 @@ +local SRS = require 'tetris.rulesets.standard' + +local PRS = SRS:extend() + +PRS.name = "Permissive Rotation System" +PRS.hash = "PRS" +PRS.world = true + +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 From 01af13003ae215341d66e37a0129c82e495ad230 Mon Sep 17 00:00:00 2001 From: Rin Date: Sat, 21 Aug 2021 20:33:13 +0100 Subject: [PATCH 4/9] Improve PRS to make it more accurate to puzzle trial's --- tetris/rulesets/prs.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tetris/rulesets/prs.lua b/tetris/rulesets/prs.lua index 6100ce3..3af2596 100644 --- a/tetris/rulesets/prs.lua +++ b/tetris/rulesets/prs.lua @@ -6,6 +6,27 @@ 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 From 00f2d1c4a8fbed2138dcc3232e5898bd3c83baca Mon Sep 17 00:00:00 2001 From: Rin Date: Sat, 21 Aug 2021 21:02:49 +0100 Subject: [PATCH 5/9] Fix stuff --- tetris/modes/marathon_c99.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tetris/modes/marathon_c99.lua b/tetris/modes/marathon_c99.lua index ad45ce6..703e456 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(cfg) - self.super:new(cfg) +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.additive_gravity = false From 36c38bf5745a5cb6c2dd6e4da6adcee10f5a5851 Mon Sep 17 00:00:00 2001 From: Rin Date: Sat, 21 Aug 2021 21:33:03 +0100 Subject: [PATCH 6/9] Super PRS. It's PRS with up-kicks --- tetris/rulesets/sprs.lua | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tetris/rulesets/sprs.lua 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 From bff53b6fd51eb8f4968b3de58b4e30c7bdd9d81e Mon Sep 17 00:00:00 2001 From: Rin Date: Sun, 22 Aug 2021 07:33:32 +0100 Subject: [PATCH 7/9] Fix duality a1 --- tetris/modes/duality_a1.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tetris/modes/duality_a1.lua b/tetris/modes/duality_a1.lua index 451c738..cf6c4b9 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(c) - DualityA1Game.super:new(c) +function DualityA1Game:new(_, c) + DualityA1Game.super:new(_, c) self.randomizer = SplitHistoryRandomizer() self.other_grid = Grid(10, 24) self.next_queue_length = 2 From 99665f23e7339449562b36364ce3d10e217cc1ef Mon Sep 17 00:00:00 2001 From: Rin Date: Sun, 22 Aug 2021 07:35:54 +0100 Subject: [PATCH 8/9] Fix Inversion A2N --- tetris/modes/inversion_a2n.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tetris/modes/inversion_a2n.lua b/tetris/modes/inversion_a2n.lua index 4824f19..7d7c8c0 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 From c65bd78653d80df406d281b63bf7014c8d35405d Mon Sep 17 00:00:00 2001 From: Rin Date: Sun, 22 Aug 2021 07:38:01 +0100 Subject: [PATCH 9/9] Fix Survival A2N; I'll remove it once the mode config system is stable --- tetris/modes/inversion_a2n.lua | 2 +- tetris/modes/survival_a2n.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tetris/modes/inversion_a2n.lua b/tetris/modes/inversion_a2n.lua index 7d7c8c0..fae51fd 100644 --- a/tetris/modes/inversion_a2n.lua +++ b/tetris/modes/inversion_a2n.lua @@ -7,7 +7,7 @@ InversionGame.hash = "InversionA2N" InversionGame.tagline = "What if the active piece was invisible?" function InversionGame:new(_, c) - SurvivalA2Game:new(_, c) + SurvivalA2Game:new(_,c) self.piece_active_time = 0 end 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