2019-05-22 22:57:34 -05:00
|
|
|
require 'funcs'
|
|
|
|
|
|
|
|
local GameMode = require 'tetris.modes.gamemode'
|
|
|
|
local Piece = require 'tetris.components.piece'
|
|
|
|
|
2020-10-10 17:07:12 -05:00
|
|
|
local Bag7Randomiser = require 'tetris.randomizers.bag7noSZOstart'
|
2019-05-22 22:57:34 -05:00
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
local Race40Game = GameMode:extend()
|
2019-05-22 22:57:34 -05:00
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
Race40Game.name = "Race 40"
|
|
|
|
Race40Game.hash = "Race40"
|
|
|
|
Race40Game.tagline = "How fast can you clear 40 lines?"
|
2019-05-22 22:57:34 -05:00
|
|
|
|
2019-05-29 20:59:53 -05:00
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:new()
|
|
|
|
Race40Game.super:new()
|
2019-05-22 22:57:34 -05:00
|
|
|
|
|
|
|
self.lines = 0
|
|
|
|
self.line_goal = 40
|
|
|
|
self.pieces = 0
|
2020-10-10 17:07:12 -05:00
|
|
|
self.randomizer = Bag7Randomiser()
|
2019-05-22 22:57:34 -05:00
|
|
|
|
|
|
|
self.roll_frames = 0
|
2020-10-29 19:56:18 -05:00
|
|
|
|
|
|
|
self.SGnames = {
|
|
|
|
[0] = "",
|
|
|
|
"9", "8", "7", "6", "5", "4", "3", "2", "1",
|
|
|
|
"S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9",
|
|
|
|
"GM"
|
|
|
|
}
|
|
|
|
self.upstacked = false
|
2019-05-22 22:57:34 -05:00
|
|
|
|
|
|
|
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 = 3
|
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:getDropSpeed()
|
2019-05-22 22:57:34 -05:00
|
|
|
return 20
|
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:getARR()
|
2020-10-29 19:56:18 -05:00
|
|
|
return 1
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:getARE()
|
2019-05-22 22:57:34 -05:00
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:getLineARE()
|
2019-05-22 22:57:34 -05:00
|
|
|
return self:getARE()
|
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:getDasLimit()
|
2020-10-29 19:56:18 -05:00
|
|
|
return 10
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:getLineClearDelay()
|
2019-05-22 22:57:34 -05:00
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:getLockDelay()
|
2020-10-29 19:56:18 -05:00
|
|
|
return 30
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:getGravity()
|
2019-05-22 22:57:34 -05:00
|
|
|
return 1/64
|
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:advanceOneFrame()
|
2019-05-22 22:57:34 -05:00
|
|
|
if self.clear then
|
|
|
|
self.roll_frames = self.roll_frames + 1
|
|
|
|
if self.roll_frames > 150 then
|
|
|
|
self.completed = true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
elseif self.ready_frames == 0 then
|
|
|
|
self.frames = self.frames + 1
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:onPieceLock()
|
2019-05-22 22:57:34 -05:00
|
|
|
self.pieces = self.pieces + 1
|
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:onLineClear(cleared_row_count)
|
2019-05-22 22:57:34 -05:00
|
|
|
if not self.clear then
|
|
|
|
self.lines = self.lines + cleared_row_count
|
|
|
|
if self.lines >= self.line_goal then
|
|
|
|
self.clear = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:drawGrid(ruleset)
|
2019-05-22 22:57:34 -05:00
|
|
|
self.grid:draw()
|
|
|
|
if self.piece ~= nil then
|
|
|
|
self:drawGhostPiece(ruleset)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:getHighscoreData()
|
2019-05-22 22:57:34 -05:00
|
|
|
return {
|
|
|
|
level = self.level,
|
|
|
|
frames = self.frames,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-10-29 20:40:50 -05:00
|
|
|
function Race40Game:getSecretGrade(sg)
|
2020-10-29 19:56:18 -05:00
|
|
|
if sg == 19 then self.upstacked = true end
|
2020-10-29 20:40:50 -05:00
|
|
|
if self.upstacked then return self.SGnames[14 + math.floor((20 - sg) / 4)]
|
|
|
|
else return self.SGnames[math.floor((sg / 19) * 14)] end
|
2020-10-29 19:56:18 -05:00
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:drawScoringInfo()
|
|
|
|
Race40Game.super.drawScoringInfo(self)
|
2019-05-22 22:57:34 -05:00
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
|
|
|
|
|
|
local text_x = config["side_next"] and 320 or 240
|
|
|
|
|
|
|
|
love.graphics.setFont(font_3x5_2)
|
|
|
|
love.graphics.printf("NEXT", 64, 40, 40, "left")
|
|
|
|
love.graphics.printf("LINES", text_x, 320, 40, "left")
|
|
|
|
love.graphics.printf("line/min", text_x, 160, 80, "left")
|
|
|
|
love.graphics.printf("piece/sec", text_x, 220, 80, "left")
|
2020-10-29 19:56:18 -05:00
|
|
|
local sg = self.grid:checkSecretGrade()
|
2020-10-29 20:40:50 -05:00
|
|
|
if sg >= 7 or self.upstacked then
|
2020-10-29 19:56:18 -05:00
|
|
|
love.graphics.printf("SECRET GRADE", 240, 430, 180, "left")
|
2020-10-29 20:40:50 -05:00
|
|
|
end
|
2019-05-22 22:57:34 -05:00
|
|
|
|
|
|
|
love.graphics.setFont(font_3x5_3)
|
|
|
|
love.graphics.printf(string.format("%.02f", self.lines / math.max(1, self.frames) * 3600), text_x, 180, 80, "left")
|
|
|
|
love.graphics.printf(string.format("%.04f", self.pieces / math.max(1, self.frames) * 60), text_x, 240, 80, "left")
|
2020-10-29 20:40:50 -05:00
|
|
|
if sg >= 7 or self.upstacked then
|
|
|
|
love.graphics.printf(self:getSecretGrade(sg), 240, 450, 180, "left")
|
|
|
|
end
|
2019-05-22 22:57:34 -05:00
|
|
|
|
|
|
|
love.graphics.setFont(font_3x5_4)
|
|
|
|
love.graphics.printf(math.max(0, self.line_goal - self.lines), text_x, 340, 40, "left")
|
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
function Race40Game:getBackground()
|
2019-05-22 22:57:34 -05:00
|
|
|
return 2
|
|
|
|
end
|
|
|
|
|
2019-06-16 21:24:06 -05:00
|
|
|
return Race40Game
|