From 2bde9d1378f00eb047650882d2766de0274f6b02 Mon Sep 17 00:00:00 2001 From: Oshisaure Date: Fri, 9 Oct 2020 02:00:42 +0100 Subject: [PATCH] Added secret grade detection for Marathon A1-A3 and Survival A1-A3 --- tetris/components/grid.lua | 34 ++++++++++++++++++++++++++++++++++ tetris/modes/marathon_a1.lua | 14 +++++++++++++- tetris/modes/marathon_a2.lua | 13 +++++++++++++ tetris/modes/marathon_a3.lua | 14 ++++++++++++++ tetris/modes/survival_a1.lua | 13 +++++++++++++ tetris/modes/survival_a2.lua | 13 +++++++++++++ tetris/modes/survival_a3.lua | 13 +++++++++++++ 7 files changed, 113 insertions(+), 1 deletion(-) diff --git a/tetris/components/grid.lua b/tetris/components/grid.lua index 2aaa98a..1fbacde 100644 --- a/tetris/components/grid.lua +++ b/tetris/components/grid.lua @@ -194,6 +194,40 @@ function Grid:checkForBravo(cleared_row_count) return true end +function Grid:checkSecretGrade() + local sgrade = 0 + for i=23,5,-1 do + local validLine = true + local emptyCell = 0 + if i > 13 then + emptyCell = 23-i + end + if i <= 13 then + emptyCell = i-5 + end + for j=0,9 do + if (not self:isOccupied(j,i) and j ~= emptyCell) or (j == emptyCell and self:isOccupied(j,i)) then + validLine = false + end + end + if not self:isOccupied(emptyCell,i-1) then + validLine = false + end + if(validLine) then + sgrade = sgrade + 1 + else + -- return sgrade + end + end + --[[ + if(sgrade == 0) then return "" + elseif(sgrade < 10) then return 10-sgrade + elseif(sgrade < 19) then return "S"..(sgrade-9) end + return "GM" + --]] + return sgrade +end + function Grid:update() for y = 1, 24 do for x = 1, 10 do diff --git a/tetris/modes/marathon_a1.lua b/tetris/modes/marathon_a1.lua index 52a0966..ea56ef2 100644 --- a/tetris/modes/marathon_a1.lua +++ b/tetris/modes/marathon_a1.lua @@ -23,6 +23,11 @@ function MarathonA1Game:new() level500 = false, level999 = false } + self.SGnames = { + "9", "8", "7", "6", "5", "4", "3", "2", "1", + "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", + "GM" + } self.randomizer = History4RollsRandomizer() @@ -191,6 +196,10 @@ function MarathonA1Game:drawScoringInfo() love.graphics.printf("SCORE", 240, 200, 40, "left") love.graphics.printf("NEXT RANK", 240, 260, 90, "left") love.graphics.printf("LEVEL", 240, 320, 40, "left") + local sg = self.grid:checkSecretGrade() + if sg >= 5 then + love.graphics.printf("SECRET GRADE", 240, 430, 180, "left") + end love.graphics.setFont(font_3x5_3) love.graphics.printf(self.score, 240, 220, 90, "left") @@ -202,7 +211,10 @@ function MarathonA1Game:drawScoringInfo() love.graphics.printf(getRankForScore(self.score).next, 240, 280, 90, "left") love.graphics.printf(self.level, 240, 340, 40, "right") love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right") - + if sg >= 5 then + love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left") + end + love.graphics.setFont(font_8x11) love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center") end diff --git a/tetris/modes/marathon_a2.lua b/tetris/modes/marathon_a2.lua index c23d856..cc8526a 100644 --- a/tetris/modes/marathon_a2.lua +++ b/tetris/modes/marathon_a2.lua @@ -27,6 +27,12 @@ function MarathonA2Game:new() self.section_times = { [0] = 0 } self.section_tetrises = { [0] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + self.SGnames = { + "9", "8", "7", "6", "5", "4", "3", "2", "1", + "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", + "GM" + } + self.randomizer = History6RollsRandomizer() self.lock_drop = false @@ -331,12 +337,19 @@ function MarathonA2Game:drawScoringInfo() love.graphics.printf("GRADE", 240, 120, 40, "left") love.graphics.printf("SCORE", 240, 200, 40, "left") love.graphics.printf("LEVEL", 240, 320, 40, "left") + local sg = self.grid:checkSecretGrade() + if sg >= 5 then + love.graphics.printf("SECRET GRADE", 240, 430, 180, "left") + end love.graphics.setFont(font_3x5_3) love.graphics.printf(self:getLetterGrade(), 240, 140, 90, "left") love.graphics.printf(self.score, 240, 220, 90, "left") love.graphics.printf(self.level, 240, 340, 40, "right") love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right") + if sg >= 5 then + love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left") + end love.graphics.setFont(font_8x11) love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center") diff --git a/tetris/modes/marathon_a3.lua b/tetris/modes/marathon_a3.lua index a39cb0e..9d6fa83 100644 --- a/tetris/modes/marathon_a3.lua +++ b/tetris/modes/marathon_a3.lua @@ -30,6 +30,13 @@ function MarathonA3Game:new() self.section_70_times = { [0] = 0 } self.section_times = { [0] = 0 } + + self.SGnames = { + "9", "8", "7", "6", "5", "4", "3", "2", "1", + "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", + "GM" + } + self.randomizer = History6RollsRandomizer() self.lock_drop = true @@ -378,6 +385,10 @@ function MarathonA3Game:drawScoringInfo() love.graphics.printf("GRADE", 240, 120, 40, "left") love.graphics.printf("SCORE", 240, 200, 40, "left") love.graphics.printf("LEVEL", 240, 320, 40, "left") + local sg = self.grid:checkSecretGrade() + if sg >= 5 then + love.graphics.printf("SECRET GRADE", 240, 430, 180, "left") + end -- draw section time data current_section = math.floor(self.level / 100) + 1 @@ -411,6 +422,9 @@ function MarathonA3Game:drawScoringInfo() love.graphics.printf(self:getLetterGrade(), 240, 140, 90, "left") love.graphics.printf(self.level, 240, 340, 40, "right") love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right") + if sg >= 5 then + love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left") + end love.graphics.setFont(font_8x11) love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center") diff --git a/tetris/modes/survival_a1.lua b/tetris/modes/survival_a1.lua index 78a81cc..41d10bc 100644 --- a/tetris/modes/survival_a1.lua +++ b/tetris/modes/survival_a1.lua @@ -25,6 +25,12 @@ function SurvivalA1Game:new() level999 = false } + self.SGnames = { + "9", "8", "7", "6", "5", "4", "3", "2", "1", + "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", + "GM" + } + self.randomizer = History4RollsRandomizer() self.lock_drop = false @@ -158,6 +164,10 @@ function SurvivalA1Game:drawScoringInfo() love.graphics.printf("SCORE", 240, 200, 40, "left") love.graphics.printf("NEXT RANK", 240, 260, 90, "left") love.graphics.printf("LEVEL", 240, 320, 40, "left") + local sg = self.grid:checkSecretGrade() + if sg >= 5 then + love.graphics.printf("SECRET GRADE", 240, 430, 180, "left") + end love.graphics.setFont(font_3x5_3) love.graphics.printf(self.score, 240, 220, 90, "left") @@ -169,6 +179,9 @@ function SurvivalA1Game:drawScoringInfo() love.graphics.printf(getRankForScore(self.score).next, 240, 280, 90, "left") love.graphics.printf(self.level, 240, 340, 40, "right") love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right") + if sg >= 5 then + love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left") + end love.graphics.setFont(font_8x11) love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center") diff --git a/tetris/modes/survival_a2.lua b/tetris/modes/survival_a2.lua index 6b82e9c..d44086d 100644 --- a/tetris/modes/survival_a2.lua +++ b/tetris/modes/survival_a2.lua @@ -19,6 +19,12 @@ function SurvivalA2Game:new() self.roll_frames = 0 self.combo = 1 self.randomizer = History6RollsRandomizer() + + self.SGnames = { + "9", "8", "7", "6", "5", "4", "3", "2", "1", + "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", + "GM" + } self.lock_drop = true end @@ -138,12 +144,19 @@ function SurvivalA2Game:drawScoringInfo() love.graphics.printf("GRADE", text_x, 120, 40, "left") love.graphics.printf("SCORE", text_x, 200, 40, "left") love.graphics.printf("LEVEL", text_x, 320, 40, "left") + local sg = self.grid:checkSecretGrade() + if sg >= 5 then + love.graphics.printf("SECRET GRADE", 240, 430, 180, "left") + end love.graphics.setFont(font_3x5_3) love.graphics.printf(self.score, text_x, 220, 90, "left") love.graphics.printf(self:getLetterGrade(), text_x, 140, 90, "left") love.graphics.printf(self.level, text_x, 340, 40, "right") love.graphics.printf(self:getSectionEndLevel(), text_x, 370, 40, "right") + if sg >= 5 then + love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left") + end end function SurvivalA2Game:getSectionEndLevel() diff --git a/tetris/modes/survival_a3.lua b/tetris/modes/survival_a3.lua index 30ce28a..a1fa033 100644 --- a/tetris/modes/survival_a3.lua +++ b/tetris/modes/survival_a3.lua @@ -24,6 +24,12 @@ function SurvivalA3Game:new() self.roll_frames = 0 self.combo = 1 self.randomizer = History6RollsRandomizer() + + self.SGnames = { + "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", + "m1", "m2", "m3", "m4", "m5", "m6", "m7", "m8", "m9", + "GM" + } self.lock_drop = true self.enable_hold = true @@ -207,6 +213,10 @@ function SurvivalA3Game:drawScoringInfo() love.graphics.printf("GRADE", text_x, 120, 40, "left") love.graphics.printf("SCORE", text_x, 200, 40, "left") love.graphics.printf("LEVEL", text_x, 320, 40, "left") + local sg = self.grid:checkSecretGrade() + if sg >= 5 then + love.graphics.printf("SECRET GRADE", 240, 430, 180, "left") + end local current_section = math.floor(self.level / 100) + 1 self:drawSectionTimesWithSplits(current_section) @@ -220,6 +230,9 @@ function SurvivalA3Game:drawScoringInfo() else love.graphics.printf(math.floor(self.level / 100 + 1) * 100, text_x, 370, 50, "right") end + if sg >= 5 then + love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left") + end end function SurvivalA3Game:getBackground()