This commit is contained in:
Ishaan Bhardwaj
2020-12-18 21:57:36 -05:00
parent a0887a46c0
commit bc8ef59f98
14 changed files with 429 additions and 28 deletions

View File

@@ -15,8 +15,8 @@ IntervalTrainingGame.tagline = "Can you clear the time hurdles when the game goe
function IntervalTrainingGame:new()
self.level = 0
IntervalTrainingGame.super:new()
self.roll_frames = 0
self.combo = 1
self.randomizer = History6RollsRandomizer()
@@ -29,12 +29,6 @@ function IntervalTrainingGame:new()
self.next_queue_length = 3
end
function IntervalTrainingGame:initialize(ruleset)
self.section_time_limit = 1800
if ruleset.world then self.section_time_limit = 37 * 60 end
self.super.initialize(self, ruleset)
end
function IntervalTrainingGame:getARE()
return 6
end
@@ -63,7 +57,7 @@ function IntervalTrainingGame:getSection()
return math.floor(level / 100) + 1
end
function IntervalTrainingGame:advanceOneFrame()
function IntervalTrainingGame:advanceOneFrame(inputs, ruleset)
if self.clear then
self.roll_frames = self.roll_frames + 1
if self.roll_frames > 2968 then
@@ -74,6 +68,8 @@ function IntervalTrainingGame:advanceOneFrame()
if self:getSectionTime() >= self.section_time_limit then
self.game_over = true
end
else
self.section_time_limit = ruleset.world and 37 * 60 or 1800
end
return true
end

View File

@@ -3,7 +3,7 @@ require 'funcs'
local GameMode = require 'tetris.modes.gamemode'
local Piece = require 'tetris.components.piece'
local History6RollsRandomizer = require 'tetris.randomizers.history_6rolls'
local DTETRandomizer = require 'tetris.randomizers.dtet'
local JokerGame = GameMode:extend()
@@ -14,7 +14,7 @@ JokerGame.tagline = "One of the hardest modes! Can you retain your stock to leve
function JokerGame:new()
self.super:new()
self.randomizer = History6RollsRandomizer()
self.randomizer = DTETRandomizer()
self.level = 50
self.stock = 0

View File

@@ -42,7 +42,7 @@ function MarathonC89Game:getDasLimit() return 16 end
function MarathonC89Game:getARR() return 6 end
function MarathonC89Game:getARE()
if self.last_row > 22 then return 10
if self.last_row > 22 then return 10
elseif self.last_row > 18 then return 12
elseif self.last_row > 14 then return 14
elseif self.last_row > 10 then return 16

View File

@@ -0,0 +1,240 @@
require 'funcs'
local GameMode = require 'tetris.modes.gamemode'
local Bag7Randomizer = require 'tetris.randomizers.bag7'
local MarathonGFGame = GameMode:extend()
MarathonGFGame.name = "Marathon GF"
MarathonGFGame.hash = "MarathonGF"
MarathonGFGame.tagline = "The old puzzle mode from Tetris Friends!"
function MarathonGFGame:new()
self.super:new()
self.back_to_back = false
self.roll_limit = 10
self.roll_frames = 0
self.message = ""
self.message_timer = 0
self.randomizer = Bag7Randomizer()
self.combo = 0
self.lock_drop = true
self.lock_hard_drop = true
self.instant_hard_drop = true
self.instant_soft_drop = false
self.enable_hold = true
self.next_queue_length = 5
end
function MarathonGFGame:getARE() return 6 end
function MarathonGFGame:getLineARE() return 6 end
function MarathonGFGame:getLineClearDelay() return 24 end
function MarathonGFGame:getDasLimit() return config.das end
function MarathonGFGame:getARR() return config.arr end
function MarathonGFGame:getGravity()
if self.lines < 180 then
return (0.8 - (math.floor(self.lines / 10) * 0.007)) ^ -math.floor(self.lines / 10) / 60
elseif self.lines < 200 then return 20
else return 1/4 end
end
function MarathonGFGame:getDropSpeed()
return self:getGravity() * 20
end
function MarathonGFGame:advanceOneFrame()
if self.clear then
self.roll_frames = self.roll_frames + 1
if self.roll_frames < 0 then return false
else self.frames = self.frames + 1 end
if self.roll_frames >= self.roll_limit + 10 then
self.roll_frames = 0
self.roll_limit = self.roll_limit + 5
end
elseif self.ready_frames == 0 then
self.frames = self.frames + 1
end
if self.drop_bonus > 0 then
self.score = self.score + self.drop_bonus
self.drop_bonus = 0
end
return true
end
function MarathonGFGame:onLineClear(cleared_row_count)
if not self.clear then
local new_lines = self.lines + cleared_row_count
self:updateSectionTimes(self.lines, new_lines)
self.lines = math.min(new_lines, 200)
if self.lines == 200 then
self.clear = true
self.roll_frames = -150
end
end
end
function MarathonGFGame:getSectionTime()
return self.frames - self.section_start_time
end
function MarathonGFGame:updateSectionTimes(old_lines, new_lines)
if math.floor(old_lines / 10) < math.floor(new_lines / 10) then
-- record new section
table.insert(self.section_times, self:getSectionTime())
self.section_start_time = self.frames
end
end
function MarathonGFGame:updateScore(level, drop_bonus, cleared_lines)
local normal_table = {[0] = 0, 1, 3, 5, 8}
local spin_score = 4 * (cleared_lines + 1)
local all_clear_table = {8, 12, 18, 20}
if self.grid:checkForBravo(cleared_lines) then
self.score = self.score + (
((self.back_to_back and cleared_lines == 4)
and 32 or all_clear_table[cleared_lines]) *
100 * (math.floor(self.lines / 10) + 1)
)
end
if cleared_lines > 0 then
self.score = self.score + (
self.combo * 50 * (math.floor(self.lines / 10) + 1)
)
end
if self.piece.spin then
self.score = self.score + (
spin_score * 100 *
(math.floor(self.lines / 10) + 1) *
((self.back_to_back and cleared_lines ~= 0) and 1.5 or 1)
)
if cleared_lines ~= 0 then
self.back_to_back = true
self.combo = self.combo + 1
else self.combo = 0 end
elseif cleared_lines > 0 then
self.score = self.score + (
normal_table[cleared_lines] * 100 *
(math.floor(self.lines / 10) + 1) *
((self.back_to_back and cleared_lines == 4) and 1.5 or 1)
)
if cleared_lines == 4 then self.back_to_back = true
else self.back_to_back = false end
self.combo = self.combo + 1
else self.combo = 0 end
end
function MarathonGFGame:onAttemptPieceMove(piece)
if self.piece ~= nil then
if not piece:isMoveBlocked(self.grid, { x=-1, y=0 }) and
not piece:isMoveBlocked(self.grid, { x=1, y=0 }) then
piece.spin = false
end
end
end
function MarathonGFGame:onAttemptPieceRotate(piece)
if self.piece ~= nil and piece:isDropBlocked(self.grid) and
piece:isMoveBlocked(self.grid, { x=-1, y=0 }) and
piece:isMoveBlocked(self.grid, { x=1, y=0 }) and
piece:isMoveBlocked(self.grid, { x=0, y=-1 }) then
piece.spin = true
end
end
function MarathonGFGame:onPieceLock(piece, cleared_row_count)
self.super:onPieceLock()
if self.grid:checkForBravo(cleared_row_count) then
self.message = "ALL CLEAR!"
elseif piece.spin then
self.message = (self.back_to_back and cleared_row_count ~= 0 and "B2B " or "") ..
piece.shape .. "-SPIN " ..
cleared_row_count .. "!"
elseif cleared_row_count == 4 then
self.message = (self.back_to_back and "B2B " or "") ..
"QUADRA!"
elseif cleared_row_count ~= 0 and self.combo > 0 then
self.message = "COMBO " .. self.combo .. "!"
else
self.message = ""
end
self.message_timer = 60
end
MarathonGFGame.rollOpacityFunction = function(age)
return 0.5
end
MarathonGFGame.mRollOpacityFunction = function(age)
return 0
end
function MarathonGFGame:drawGrid(ruleset)
if not self.game_over then
if self.lines >= 200 and self.roll_frames >= self.roll_limit then
self.grid:drawInvisible(self.rollOpacityFunction)
elseif self.lines >= 200 then
self.grid:drawInvisible(self.mRollOpacityFunction)
else self.grid:draw() end
else self.grid:draw() end
self:drawGhostPiece(ruleset)
end
function MarathonGFGame:getHighscoreData()
return {
score = self.score,
frames = self.frames,
}
end
function MarathonGFGame:getBackground()
return math.min(19, math.floor(self.lines / 10))
end
function MarathonGFGame:drawScoringInfo()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.setFont(font_3x5_2)
love.graphics.print(
self.das.direction .. " " ..
self.das.frames .. " " ..
strTrueValues(self.prev_inputs)
)
love.graphics.printf("NEXT", 64, 40, 40, "left")
love.graphics.printf("SCORE", 240, 180, 80, "left")
love.graphics.printf("LEVEL", 240, 250, 80, "left")
love.graphics.printf("LINES", 240, 320, 40, "left")
local current_section = math.floor(self.lines / 10) + 1
self:drawSectionTimesWithSplits(current_section)
if self.message_timer > 0 then
love.graphics.printf(self.message, 64, 400, 160, "center")
self.message_timer = self.message_timer - 1
end
love.graphics.setFont(font_3x5_3)
love.graphics.printf(self.score, 240, 200, 120, "left")
love.graphics.printf(self.lines, 240, 340, 40, "right")
love.graphics.printf(self.clear and self.lines or self:getSectionEndLines(), 240, 370, 40, "right")
if not self.game_over and self.clear and self.roll_frames % 4 < 2 then
love.graphics.setColor(1, 1, 0.3, 1)
end
love.graphics.printf(math.floor(self.lines / 10) + 1, 240, 270, 160, "left")
love.graphics.setColor(1, 1, 1, 1)
love.graphics.setFont(font_8x11)
love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center")
end
function MarathonGFGame:getSectionEndLines()
return math.floor(self.lines / 10 + 1) * 10
end
return MarathonGFGame

View File

@@ -23,7 +23,7 @@ function MarathonWCBGame:new()
self.instant_hard_drop = true
self.instant_soft_drop = true
self.enable_hold = false
self.next_queue_length = 3
self.next_queue_length = 6
self.piece_is_active = false
end

View File

@@ -19,6 +19,8 @@ function NightOfNights:new()
self.lock_drop = true
self.lock_hard_drop = true
self.instant_soft_drop = false
self.instant_hard_drop = false
self.enable_hold = true
self.next_queue_length = 3
end
@@ -26,7 +28,8 @@ end
function NightOfNights:getARE() return 0 end
function NightOfNights:getLineARE() return 0 end
function NightOfNights:getLineClearDelay() return 0 end
function NightOfNights:getDasLimit() return 6 end
function NightOfNights:getDasLimit() return config.das end
function NightOfNights:getARR() return config.arr end
function NightOfNights:getGravity() return 20 end
function NightOfNights:whilePieceActive()

View File

@@ -13,11 +13,11 @@ function ProGame:new()
self.super:new()
self.next_queue_length = 6
self.randomizer = TetraRandomizer()
self.active_time = 0
end
function ProGame:initialize(ruleset)
self.super.initialize(self, ruleset)
ruleset.onPieceDrop = function() end
ruleset.onPieceMove = function() end
ruleset.onPieceRotate = function() end
end
@@ -25,12 +25,13 @@ end
function ProGame:getARE() return 6 end
function ProGame:getLineARE() return 6 end
function ProGame:getLineClearDelay() return 6 end
function ProGame:getDasLimit() return 6 end
function ProGame:getDasLimit() return config.das end
function ProGame:getARR() return config.arr end
function ProGame:getDropSpeed() return 20 end
function ProGame:getGravity()
if self.lines < 20 then return 1
elseif self.lines < 40 then return 3
elseif self.lines < 40 then return 2
elseif self.lines < 60 then return 5
else return 20 end
end
@@ -69,14 +70,18 @@ function ProGame:advanceOneFrame(inputs, ruleset)
end
function ProGame:onPieceEnter()
self.active_time = 0
self.section_clear = false
self.piece.lowest_y = -math.huge
end
function ProGame:onHold()
self.piece.lowest_y = -math.huge
end
function ProGame:whilePieceActive()
if self.piece:isDropBlocked(self.grid) then
self.active_time = self.active_time + 1
self.piece.locked = self.active_time >= self:getLockDelay() * 4
end
self.piece.lock_delay = self.piece.lowest_y < self.piece.position.y
and 0 or self.piece.lock_delay
self.piece.lowest_y = math.max(self.piece.lowest_y, self.piece.position.y)
end
function ProGame:onLineClear(cleared_row_count)

View File

@@ -36,9 +36,6 @@ function Race40Game:new()
self.instant_soft_drop = false
self.enable_hold = true
self.next_queue_length = 3
self.irs = false
self.ihs = false
end
function Race40Game:getDropSpeed()
@@ -46,7 +43,7 @@ function Race40Game:getDropSpeed()
end
function Race40Game:getARR()
return 1
return config.arr
end
function Race40Game:getARE()
@@ -58,7 +55,7 @@ function Race40Game:getLineARE()
end
function Race40Game:getDasLimit()
return 8
return config.das
end
function Race40Game:getLineClearDelay()
@@ -86,6 +83,11 @@ function Race40Game:advanceOneFrame()
return true
end
function Race40Game:onPieceEnter()
self.irs = false
self.ihs = false
end
function Race40Game:onPieceLock()
self.super:onPieceLock()
self.pieces = self.pieces + 1

View File

@@ -40,7 +40,8 @@ end
function LudicrousSpeed:getARE() return 0 end
function LudicrousSpeed:getLineARE() return 0 end
function LudicrousSpeed:getLineClearDelay() return 0 end
function LudicrousSpeed:getDasLimit() return 8 end
function LudicrousSpeed:getDasLimit() return config.das end
function LudicrousSpeed:getARR() return config.arr end
function LudicrousSpeed:getDropSpeed() return 20 end
local function mean(t)