From 7de410c59ad9020b0627340701eb9d1caade1f8e Mon Sep 17 00:00:00 2001 From: Wojciech Kubicki Date: Mon, 25 Mar 2024 01:52:34 +0100 Subject: [PATCH] refactor(tile_init): set type based on random vegetable --- src/tile.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/tile.py b/src/tile.py index 94f78652..3de958a8 100644 --- a/src/tile.py +++ b/src/tile.py @@ -6,22 +6,24 @@ import pytholog as pl import random class Tile(pygame.sprite.Sprite): - def __init__(self, id, type, field): + def __init__(self, id, field, type): super().__init__() self.id = id x = id%16 y = id//16 - vegetable_types = tractor_kb.query(pl.Expr("warzywo(X)")) - random_vegetable = vegetable_types[random.randint(0, len(vegetable_types)-1)]['X'] - - self.type = type self.field = field + + vegetables = tractor_kb.query(pl.Expr("warzywo(Nazwa_warzywa)")) + random_vegetable = vegetables[random.randint(0, len(vegetables)-1)]['Nazwa_warzywa'] self.set_type(random_vegetable) - self.rect = self.image.get_rect() + + self.faza = 'posadzono' + # you can set TILE_SIZE in the .env file to adjust the window size load_dotenv(find_dotenv()) TILE_SIZE = int(os.getenv("TILE_SIZE")) + self.rect = self.image.get_rect() self.rect.topleft = (x * TILE_SIZE, y * TILE_SIZE) def draw(self, surface):