feat: improve the way that pieces get generated

This commit is contained in:
Giovani Rodriguez
2021-06-08 10:10:56 -04:00
parent fece1cf5bc
commit 3df1edd007

View File

@@ -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)