TETRIS: fix bug where shadows took pieces out of bag

This commit is contained in:
zv0n 2020-10-29 11:00:44 +01:00
parent ca4ccbebc8
commit b6a2e14507

View File

@ -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( 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() { ~TetrisBlock() {
pieces_bag[_index]++; if(_index != PIECE_SHADOW)
pieces_bag[_index]++;
} }
virtual std::shared_ptr<RenderObject> copySelf() override { virtual std::shared_ptr<RenderObject> copySelf() override {
return std::make_shared<TetrisBlock>(*this); return std::make_shared<TetrisBlock>(*this);
@ -55,6 +56,8 @@ public:
} }
void turnIntoShadow() { void turnIntoShadow() {
setId(SHADOW_ID); setId(SHADOW_ID);
// shadows don't consume pieces from bag
pieces_bag[_index]++;
_index = PIECE_SHADOW; _index = PIECE_SHADOW;
setColors(); setColors();
} }