2020-10-05 21:17:15 -05:00
|
|
|
require 'funcs'
|
|
|
|
|
|
|
|
local GameMode = require 'tetris.modes.gamemode'
|
|
|
|
local Piece = require 'tetris.components.piece'
|
|
|
|
|
2020-10-06 17:53:02 -05:00
|
|
|
local KonohaRandomizer = require 'tetris.randomizers.bag_konoha'
|
2020-10-05 21:17:15 -05:00
|
|
|
|
|
|
|
local KonohaGame = GameMode:extend()
|
|
|
|
|
|
|
|
KonohaGame.name = "All Clear A4"
|
|
|
|
KonohaGame.hash = "AllClearA4"
|
|
|
|
KonohaGame.tagline = "Get as many bravos as you can under the time limit!"
|
|
|
|
|
|
|
|
function KonohaGame:new()
|
|
|
|
KonohaGame.super:new()
|
|
|
|
|
2020-10-06 17:53:02 -05:00
|
|
|
self.randomizer = KonohaRandomizer()
|
2020-10-05 21:17:15 -05:00
|
|
|
self.bravos = 0
|
2020-11-06 19:49:44 -06:00
|
|
|
self.last_bonus_amount = 0
|
|
|
|
self.last_bonus_display_time = 0
|
2020-10-05 21:17:15 -05:00
|
|
|
self.time_limit = 10800
|
|
|
|
self.big_mode = true
|
|
|
|
|
|
|
|
self.enable_hold = true
|
|
|
|
self.next_queue_length = 3
|
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:getARE()
|
2020-11-06 19:49:44 -06:00
|
|
|
if self.level < 300 then return 30
|
2020-10-05 21:17:15 -05:00
|
|
|
elseif self.level < 400 then return 25
|
|
|
|
elseif self.level < 500 then return 20
|
|
|
|
elseif self.level < 600 then return 17
|
|
|
|
elseif self.level < 800 then return 15
|
|
|
|
elseif self.level < 900 then return 13
|
|
|
|
elseif self.level < 1000 then return 10
|
|
|
|
elseif self.level < 1300 then return 8
|
|
|
|
else return 6 end
|
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:getLineARE()
|
|
|
|
return self:getARE()
|
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:getDasLimit()
|
2020-11-06 19:49:44 -06:00
|
|
|
if self.level < 500 then return 10
|
2020-10-05 21:17:15 -05:00
|
|
|
elseif self.level < 800 then return 9
|
|
|
|
elseif self.level < 1000 then return 8
|
|
|
|
else return 7 end
|
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:getLineClearDelay()
|
2020-11-06 19:49:44 -06:00
|
|
|
if self.level < 200 then return 14
|
2020-10-05 21:17:15 -05:00
|
|
|
elseif self.level < 500 then return 9
|
|
|
|
elseif self.level < 800 then return 8
|
|
|
|
elseif self.level < 1000 then return 7
|
|
|
|
else return 6 end
|
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:getLockDelay()
|
2020-11-06 19:49:44 -06:00
|
|
|
if self.level < 500 then return 30
|
2020-10-05 21:17:15 -05:00
|
|
|
elseif self.level < 600 then return 25
|
|
|
|
elseif self.level < 700 then return 23
|
|
|
|
elseif self.level < 800 then return 20
|
|
|
|
elseif self.level < 900 then return 17
|
|
|
|
elseif self.level < 1000 then return 15
|
|
|
|
elseif self.level < 1200 then return 13
|
|
|
|
elseif self.level < 1300 then return 10
|
|
|
|
else return 8 end
|
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:getGravity()
|
2020-11-06 19:49:44 -06:00
|
|
|
if (self.level < 30) then return 4/256
|
2020-10-06 17:53:02 -05:00
|
|
|
elseif (self.level < 35) then return 8/256
|
|
|
|
elseif (self.level < 40) then return 12/256
|
2020-10-05 21:17:15 -05:00
|
|
|
elseif (self.level < 50) then return 16/256
|
|
|
|
elseif (self.level < 60) then return 32/256
|
|
|
|
elseif (self.level < 70) then return 48/256
|
|
|
|
elseif (self.level < 80) then return 64/256
|
|
|
|
elseif (self.level < 90) then return 128/256
|
|
|
|
elseif (self.level < 100) then return 192/256
|
|
|
|
elseif (self.level < 120) then return 1
|
|
|
|
elseif (self.level < 140) then return 2
|
|
|
|
elseif (self.level < 160) then return 3
|
|
|
|
elseif (self.level < 170) then return 4
|
|
|
|
elseif (self.level < 200) then return 5
|
|
|
|
else return 20 end
|
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:getSection()
|
|
|
|
return math.floor(level / 100) + 1
|
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:getSectionEndLevel()
|
|
|
|
return math.floor(self.level / 100 + 1) * 100
|
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:advanceOneFrame()
|
|
|
|
if self.ready_frames == 0 then
|
|
|
|
self.time_limit = self.time_limit - 1
|
|
|
|
self.frames = self.frames + 1
|
|
|
|
end
|
|
|
|
if self.time_limit <= 0 then
|
|
|
|
self.game_over = true
|
|
|
|
end
|
2020-11-06 19:49:44 -06:00
|
|
|
self.last_bonus_display_time = self.last_bonus_display_time - 1
|
2020-10-05 21:17:15 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:onPieceEnter()
|
|
|
|
if (self.level % 100 ~= 99) and self.frames ~= 0 then
|
|
|
|
self.level = self.level + 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:drawGrid(ruleset)
|
|
|
|
self.grid:draw()
|
2020-10-06 17:53:02 -05:00
|
|
|
if self.piece ~= nil and self.level < 100 then
|
|
|
|
self:drawGhostPiece(ruleset)
|
|
|
|
end
|
2020-10-05 21:17:15 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
local cleared_row_levels = {2, 4, 6, 12}
|
|
|
|
local bravo_bonus = {300, 480, 660, 900}
|
|
|
|
local non_bravo_bonus = {0, 0, 20, 40}
|
|
|
|
local bravo_ot_bonus = {0, 60, 120, 180}
|
|
|
|
|
|
|
|
function KonohaGame:onLineClear(cleared_row_count)
|
2020-11-06 19:49:44 -06:00
|
|
|
local oldtime = self.time_limit
|
2020-10-06 19:57:07 -05:00
|
|
|
|
2020-11-06 19:49:44 -06:00
|
|
|
self.level = self.level + cleared_row_levels[cleared_row_count / 2]
|
2020-10-08 19:44:06 -05:00
|
|
|
if self.grid:checkForBravo(cleared_row_count) then
|
2020-10-05 21:17:15 -05:00
|
|
|
self.bravos = self.bravos + 1
|
|
|
|
if self.level < 1000 then self.time_limit = self.time_limit + bravo_bonus[cleared_row_count / 2]
|
|
|
|
else self.time_limit = self.time_limit + bravo_ot_bonus[cleared_row_count / 2]
|
2020-10-06 17:53:02 -05:00
|
|
|
end
|
|
|
|
if self.bravos == 11 then self.randomizer.allowrepeat = true end
|
2020-10-05 21:17:15 -05:00
|
|
|
elseif self.level < 1000 then
|
|
|
|
self.time_limit = self.time_limit + non_bravo_bonus[cleared_row_count / 2]
|
|
|
|
end
|
2020-11-06 19:49:44 -06:00
|
|
|
|
|
|
|
local bonus = self.time_limit - oldtime
|
|
|
|
if bonus > 0 then
|
|
|
|
self.last_bonus_amount = bonus
|
|
|
|
self.last_bonus_display_time = 120
|
|
|
|
end
|
2020-10-05 21:17:15 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:getBackground()
|
2020-10-09 16:55:22 -05:00
|
|
|
return math.floor(self.level / 100)
|
2020-10-05 21:17:15 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:drawScoringInfo()
|
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
|
|
|
|
|
|
love.graphics.setFont(font_3x5_2)
|
|
|
|
love.graphics.print(
|
|
|
|
self.das.direction .. " " ..
|
|
|
|
self.das.frames .. " " ..
|
2020-10-06 12:14:00 -05:00
|
|
|
strTrueValues(self.prev_inputs)
|
2020-10-05 21:17:15 -05:00
|
|
|
)
|
|
|
|
love.graphics.printf("NEXT", 64, 40, 40, "left")
|
|
|
|
love.graphics.printf("TIME LIMIT", 240, 120, 120, "left")
|
|
|
|
love.graphics.printf("BRAVOS", 240, 200, 50, "left")
|
|
|
|
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
|
|
|
|
|
|
|
love.graphics.setFont(font_3x5_3)
|
2020-10-06 12:14:00 -05:00
|
|
|
if not self.game_over and self.time_limit < frameTime(0,10) and self.time_limit % 4 < 2 then
|
2020-11-06 19:49:44 -06:00
|
|
|
love.graphics.setColor(1, 0.3, 0.3, 1)
|
|
|
|
end
|
2020-10-06 19:57:07 -05:00
|
|
|
love.graphics.printf(formatTime(self.time_limit), 240, 140, 120, "right")
|
2020-10-09 12:37:39 -05:00
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
2020-11-06 19:49:44 -06:00
|
|
|
if self.last_bonus_display_time > 0 then
|
|
|
|
love.graphics.printf("+"..formatTime(self.last_bonus_amount), 240, 160, 120, "right")
|
|
|
|
end
|
2020-10-05 21:17:15 -05:00
|
|
|
love.graphics.printf(self.bravos, 240, 220, 90, "left")
|
2020-10-05 22:24:59 -05:00
|
|
|
love.graphics.printf(self.level, 240, 340, 50, "right")
|
|
|
|
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 50, "right")
|
2020-10-05 21:17:15 -05:00
|
|
|
|
|
|
|
love.graphics.setFont(font_8x11)
|
|
|
|
love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center")
|
|
|
|
end
|
|
|
|
|
|
|
|
function KonohaGame:getHighscoreData()
|
|
|
|
return {
|
|
|
|
bravos = self.bravos,
|
|
|
|
level = self.level,
|
|
|
|
frames = self.frames,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
return KonohaGame
|