From b533946471f88546e99ff44ea1e3ae311af62f48 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Thu, 28 Dec 2023 18:23:55 +0200 Subject: [PATCH] feat(game): add inital block value option --- src/py2048/block.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/py2048/block.py b/src/py2048/block.py index 823ad86..df37125 100644 --- a/src/py2048/block.py +++ b/src/py2048/block.py @@ -7,13 +7,13 @@ from .config import Config class Block(pygame.sprite.Sprite): - def __init__(self, x: int, y: int): + def __init__(self, x: int, y: int, value: int | None = 2): """Initialize a block""" super().__init__() self.image = pygame.Surface((Config.BLOCK_SIZE, Config.BLOCK_SIZE)) self.rect = self.image.get_rect() self.rect.topleft = (x, y) - self.value: int = 2 if random.random() <= Config.BLOCK_VALUE_PROBABILITY else 4 + self.value: int = value if value is not None else 2 if random.random() <= Config.BLOCK_VALUE_PROBABILITY else 4 self.font = pygame.font.SysFont(Config.FONT_FAMILY, Config.FONT_SIZE) self.update()