import pygame import displayControler as dCon import Colors import random import Image import Roslina BORDER_THICKNESS=1 #Has to be INT value class Slot: def __init__(self,x_axis,y_axis,color,screen,image_loader): self.x_axis=x_axis self.y_axis=y_axis self.plant_image = None self.plant=None self.screen=screen self.field=pygame.Rect(self.x_axis*dCon.CUBE_SIZE,self.y_axis*dCon.CUBE_SIZE,dCon.CUBE_SIZE,dCon.CUBE_SIZE) self.image_loader=image_loader self.garage_image=None self.label = None self.imagePath = None def draw(self): pygame.draw.rect(self.screen,Colors.BROWN,self.field,0) #Draw field pygame.draw.rect(self.screen,Colors.BLACK,self.field,BORDER_THICKNESS) #Draw border pygame.display.update() def redraw_image(self, destroy = True): if destroy: self.mark_visited() else: self.screen.blit(self.plant_image, (self.x_axis * dCon.CUBE_SIZE, self.y_axis * dCon.CUBE_SIZE)) pygame.draw.rect(self.screen, Colors.BLACK, self.field, BORDER_THICKNESS) def mark_visited(self): plant,self.plant_image=self.image_loader.return_plant('road') self.screen.blit(self.plant_image, (self.x_axis * dCon.CUBE_SIZE, self.y_axis * dCon.CUBE_SIZE)) pygame.draw.rect(self.screen, Colors.BLACK, self.field, BORDER_THICKNESS) def color_change(self,color): self.plant=color self.draw() def set_random_plant(self, nn=False): if not nn: (plant_name,self.plant_image)=self.random_plant() self.plant=Roslina.Roslina(plant_name) else: self.plant_image, self.label, self.imagePath = self.random_plant_dataset() # print(self.plant_image) self.plant=Roslina.Roslina(self.label) self.set_image() def set_image(self): if self.plant_image is None: self.plant_image = self.image_loader.return_random_plant() self.screen.blit(self.plant_image, (self.x_axis * dCon.CUBE_SIZE, self.y_axis * dCon.CUBE_SIZE)) pygame.draw.rect(self.screen, Colors.BLACK, self.field, BORDER_THICKNESS) def set_garage_image(self): self.plant_image=self.image_loader.return_garage() self.screen.blit(self.plant_image, (self.x_axis * dCon.CUBE_SIZE, self.y_axis * dCon.CUBE_SIZE)) pygame.draw.rect(self.screen, Colors.BLACK, self.field, BORDER_THICKNESS) def set_stone_image(self): self.plant_image=self.image_loader.return_stone() self.screen.blit(self.plant_image, (self.x_axis * dCon.CUBE_SIZE, self.y_axis * dCon.CUBE_SIZE)) pygame.draw.rect(self.screen, Colors.BLACK, self.field, BORDER_THICKNESS) def set_gasStation_image(self): self.plant_image=self.image_loader.return_gasStation() self.screen.blit(self.plant_image, (self.x_axis * dCon.CUBE_SIZE, self.y_axis * dCon.CUBE_SIZE)) pygame.draw.rect(self.screen, Colors.BLACK, self.field, BORDER_THICKNESS) def random_plant(self): #Probably will not be used later only for demo purpouse return self.image_loader.return_random_plant() def random_plant_dataset(self): return Image.getRandomImageFromDataBase() def return_plant(self): return self.plant def get_hydrate_stats(self): return self.plant.get_hydrate_stats() def print_status(self): return f"wspolrzedne: (X:{self.x_axis} Y:{self.y_axis}) "+self.plant.report_status() def irrigatePlant(self): self.plant.stan.nawodnienie = 100 def setHydrate(self,index): if(index==0): self.plant.stan.nawodnienie=random.randint(0,60) elif(index==1): self.plant.stan.nawodnienie=random.randint(61,100) elif(index==-1): pass def return_stan_for_tree(self): return self.plant.return_stan_for_tree()