From a348280132d92194189f0f23dfe66850760a1e44 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Wed, 12 Jul 2023 01:31:14 -0400 Subject: [PATCH] The True Hero remaster --- tetris/modes/hero.lua | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tetris/modes/hero.lua b/tetris/modes/hero.lua index a91fdfd..f64ba82 100644 --- a/tetris/modes/hero.lua +++ b/tetris/modes/hero.lua @@ -127,18 +127,18 @@ function TheTrueHero:advanceOneFrame(inputs, ruleset) self.section_frames = 0 self.attack_number = self.attack_number + 1 local prev_attack = self.current_attack - self.current_attack = -1 - local attack_rolls = 0 - while (( - prev_attack == self.current_attack or - self.current_attack == 5 - ) and (attack_rolls < 2)) or attack_rolls == 0 do - attack_rolls = attack_rolls + 1 + for i = 1, 3 do if self.attack_number > 20 then self.current_attack = love.math.random(#self.attacks) else self.current_attack = love.math.random(4) end + if ( + prev_attack ~= self.current_attack and + self.current_attack ~= 5 + ) then + break + end end if self.current_attack == 1 then self.var = math.floor(3 + love.math.random( @@ -198,14 +198,16 @@ end function TheTrueHero:onPieceLock(piece, cleared_row_count) self.super:onPieceLock() if self.current_attack == 1 or self.current_attack == 3 then - self.var = math.max(self.var - 1, 0) - self:advanceBottomRow(1) - playSE("undyne", "ding") - elseif self.current_attack == 2 then - self.var = math.max(self.var - cleared_row_count, 0) - if cleared_row_count ~= 0 then + if self.var ~= math.floor(self.current_attack / 2) then playSE("undyne", "ding") end + self.var = math.max(self.var - 1, 0) + self:advanceBottomRow(1) + elseif self.current_attack == 2 then + if cleared_row_count ~= 0 and self.var ~= 0 then + playSE("undyne", "ding") + end + self.var = math.max(self.var - cleared_row_count, 0) end end