This commit is contained in:
Sylvie Nightshade 2023-07-02 22:14:35 -04:00 committed by GitHub
commit 588db12445
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 142 additions and 14 deletions

View File

@ -8,8 +8,8 @@ DualityA1Game.name = "Duality A1"
DualityA1Game.hash = "DualityA1" DualityA1Game.hash = "DualityA1"
DualityA1Game.tagline = "Control two boards at once!" DualityA1Game.tagline = "Control two boards at once!"
function DualityA1Game:new() function DualityA1Game:new(_, c)
DualityA1Game.super:new() DualityA1Game.super:new(_, c)
self.randomizer = SplitHistoryRandomizer() self.randomizer = SplitHistoryRandomizer()
self.other_grid = Grid(10, 24) self.other_grid = Grid(10, 24)
self.next_queue_length = 2 self.next_queue_length = 2

View File

@ -6,8 +6,8 @@ InversionGame.name = "Inversion A2N"
InversionGame.hash = "InversionA2N" InversionGame.hash = "InversionA2N"
InversionGame.tagline = "What if the active piece was invisible?" InversionGame.tagline = "What if the active piece was invisible?"
function InversionGame:new() function InversionGame:new(_, c)
SurvivalA2Game:new() SurvivalA2Game:new(_,c)
self.piece_active_time = 0 self.piece_active_time = 0
end end

View File

@ -47,8 +47,10 @@ local slots_table = {
local slot_popup = {["text"]="",["time"]=0,["slotnum"]=0} local slot_popup = {["text"]="",["time"]=0,["slotnum"]=0}
local line_popup = {["y"]=0,["score"]=0,["lines"]=0} local line_popup = {["y"]=0,["score"]=0,["lines"]=0}
function MarathonC99Game:new() function MarathonC99Game:new(_, cfg)
self.super:new() if cfg == nil then cfg = {} end -- Don't break older Cambridge versions
self.super:new(_, cfg)
self.grid = Grid(10, 22) self.grid = Grid(10, 22)
self.slots_random = love.math.newRandomGenerator(os.time()) self.slots_random = love.math.newRandomGenerator(os.time())
@ -60,10 +62,11 @@ function MarathonC99Game:new()
self.tetris_slots = 0 self.tetris_slots = 0
self.ccw_bonus = 10 ^ 7 self.ccw_bonus = 10 ^ 7
slot_popup = {["text"]="",["time"]=0} slot_popup = {["text"]="",["time"]=0}
self.irs = false self.irs = cfg.irs == 2
self.enable_hard_drop = false self.enable_hard_drop = cfg.hardDrop == 2
self.lock_drop = false 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 end
function MarathonC99Game:getARE() function MarathonC99Game:getARE()
@ -165,10 +168,11 @@ function MarathonC99Game:advanceOneFrame(inputs, ruleset)
self.frames = self.frames + 1 self.frames = self.frames + 1
end end
if self.piece ~= nil then if self.piece ~= nil then
local lo = self.piece.last_orientation or self.piece.rotation
if not ( if not (
self.piece.rotation - self.piece.last_orientation == -1 or -- 3 >> 2, 2 >> 1, 1 >> 0 self.piece.rotation - lo == -1 or -- 3 >> 2, 2 >> 1, 1 >> 0
self.piece.rotation - self.piece.last_orientation == 3 or -- 0 >> 3 self.piece.rotation - lo == 3 or -- 0 >> 3
self.piece.rotation - self.piece.last_orientation == 0 -- not rotated self.piece.rotation - lo == 0 -- not rotated
) then ) then
self.ccw_bonus = 0 self.ccw_bonus = 0
end end
@ -272,6 +276,9 @@ function MarathonC99Game:drawGrid()
love.graphics.printf(line_popup.score,40,line_popup.y-1,200,"center") love.graphics.printf(line_popup.score,40,line_popup.y-1,200,"center")
end end
self.grid:draw() self.grid:draw()
if self.piece ~= nil and self.config.ghostPiece == 2 then
self:drawGhostPiece(ruleset)
end
end end
function MarathonC99Game:drawScoringInfo() function MarathonC99Game:drawScoringInfo()
@ -372,4 +379,14 @@ function MarathonC99Game:getHighscoreData()
} }
end 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 return MarathonC99Game

View File

@ -6,8 +6,8 @@ SurvivalA2NGame.name = "Survival A2N"
SurvivalA2NGame.hash = "SurvivalA2N" SurvivalA2NGame.hash = "SurvivalA2N"
SurvivalA2NGame.tagline = "A variation of Survival A2 for Carnival of Derp." SurvivalA2NGame.tagline = "A variation of Survival A2 for Carnival of Derp."
function SurvivalA2NGame:new() function SurvivalA2NGame:new(_, c)
self.super:new() self.super:new(_, c)
self.next_queue_length = 3 self.next_queue_length = 3
self.enable_hold = true self.enable_hold = true
end end

55
tetris/rulesets/prs.lua Normal file
View File

@ -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

56
tetris/rulesets/sprs.lua Normal file
View File

@ -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