From b6a2e145077ecdd2784417619c306f497696b88c Mon Sep 17 00:00:00 2001 From: zv0n Date: Thu, 29 Oct 2020 11:00:44 +0100 Subject: [PATCH] TETRIS: fix bug where shadows took pieces out of bag --- tetris/custom_classes.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tetris/custom_classes.hpp b/tetris/custom_classes.hpp index 75b64ff..added37 100644 --- a/tetris/custom_classes.hpp +++ b/tetris/custom_classes.hpp @@ -21,7 +21,8 @@ public: } TetrisBlock( const TetrisBlock &other ) : TetrisBlock(other.getDoubleRect().first.first,other.getDoubleRect().first.second,other.getDoubleRect().second.first,other.getDoubleRect().second.second,other.getRenderer(), other.getColor(), true, other._index, other._scene, other.pieces_bag) {} ~TetrisBlock() { - pieces_bag[_index]++; + if(_index != PIECE_SHADOW) + pieces_bag[_index]++; } virtual std::shared_ptr copySelf() override { return std::make_shared(*this); @@ -55,6 +56,8 @@ public: } void turnIntoShadow() { setId(SHADOW_ID); + // shadows don't consume pieces from bag + pieces_bag[_index]++; _index = PIECE_SHADOW; setColors(); }