From da6f5ef70632c18dfaa655080d282ed54fd9ab80 Mon Sep 17 00:00:00 2001 From: Giovani Date: Tue, 8 Jun 2021 10:10:56 -0400 Subject: [PATCH] feat: improve the way that pieces get generated --- util/PieceGenerator.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/util/PieceGenerator.py b/util/PieceGenerator.py index 876e847..18008d3 100644 --- a/util/PieceGenerator.py +++ b/util/PieceGenerator.py @@ -3,12 +3,21 @@ import random from entity.Piece import Piece from util.ConfigurationManager import ConfigurationManager +""" + TODO Add link that goes through random piece generation +""" class PieceGenerator: + __pieces = [] + @classmethod def get_piece(cls, position): - piece = Piece(cls.__get_piece_shape(), position, cls.__get_piece_color()) - return piece + + if len(cls.__pieces) == 0: + for _ in range(7): + cls.__pieces.append(Piece(cls.__get_piece_shape(), position, cls.__get_piece_color())) + + return cls.__pieces.pop() def __get_piece_shape(): random_number = random.randint(0, 6)