From 6178b2cee919c4e5d95b463ca06fe497ee6b8cac Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Thu, 8 Oct 2020 20:44:06 -0400 Subject: [PATCH] Proper bravo detection! --- tetris/components/grid.lua | 9 +++++++++ tetris/modes/konoha.lua | 10 +--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tetris/components/grid.lua b/tetris/components/grid.lua index 1aef9d7..2aaa98a 100644 --- a/tetris/components/grid.lua +++ b/tetris/components/grid.lua @@ -185,6 +185,15 @@ function Grid:applyBigPiece(piece) end end +function Grid:checkForBravo(cleared_row_count) + for i = 0, 23 - cleared_row_count do + for j = 0, 9 do + if self:isOccupied(j, i) then return false end + end + end + return true +end + function Grid:update() for y = 1, 24 do for x = 1, 10 do diff --git a/tetris/modes/konoha.lua b/tetris/modes/konoha.lua index f3ea612..1c4a63b 100755 --- a/tetris/modes/konoha.lua +++ b/tetris/modes/konoha.lua @@ -127,15 +127,7 @@ function KonohaGame:onLineClear(cleared_row_count) local oldtime = self.time_limit self.level = self.level + cleared_row_levels[cleared_row_count / 2] - self.bravo = true - for i = 0, 23 - cleared_row_count do - for j = 0, 9 do - if self.grid:isOccupied(j, i) then - self.bravo = false - end - end - end - if self.bravo then + if self.grid:checkForBravo(cleared_row_count) then 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]