2024-03-10 15:03:56 +01:00
|
|
|
import pygame
|
2024-03-11 21:24:16 +01:00
|
|
|
import displayControler as dCon
|
2024-03-23 13:46:48 +01:00
|
|
|
import Colors
|
|
|
|
import random
|
|
|
|
import Image
|
2024-03-24 23:30:02 +01:00
|
|
|
import Roslina
|
2024-03-10 15:03:56 +01:00
|
|
|
|
|
|
|
BORDER_THICKNESS=1 #Has to be INT value
|
|
|
|
class Slot:
|
2024-03-23 13:46:48 +01:00
|
|
|
def __init__(self,x_axis,y_axis,color,screen,image_loader):
|
2024-03-10 15:03:56 +01:00
|
|
|
self.x_axis=x_axis
|
|
|
|
self.y_axis=y_axis
|
2024-03-23 21:00:08 +01:00
|
|
|
self.plant_image = None
|
2024-03-24 23:30:02 +01:00
|
|
|
self.plant=None
|
2024-03-10 15:03:56 +01:00
|
|
|
self.screen=screen
|
2024-03-11 21:24:16 +01:00
|
|
|
self.field=pygame.Rect(self.x_axis*dCon.CUBE_SIZE,self.y_axis*dCon.CUBE_SIZE,dCon.CUBE_SIZE,dCon.CUBE_SIZE)
|
2024-03-23 13:46:48 +01:00
|
|
|
self.image_loader=image_loader
|
2024-04-15 10:02:09 +02:00
|
|
|
self.garage_image=None
|
2024-03-23 13:46:48 +01:00
|
|
|
|
2024-03-10 15:03:56 +01:00
|
|
|
def draw(self):
|
2024-03-23 13:46:48 +01:00
|
|
|
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
|
2024-03-10 15:03:56 +01:00
|
|
|
pygame.display.update()
|
2024-03-23 13:46:48 +01:00
|
|
|
|
|
|
|
def redraw_image(self):
|
2024-04-28 12:58:58 +02:00
|
|
|
self.mark_visited()
|
|
|
|
|
|
|
|
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)
|
2024-03-23 13:46:48 +01:00
|
|
|
|
2024-03-10 15:03:56 +01:00
|
|
|
def color_change(self,color):
|
2024-03-23 13:46:48 +01:00
|
|
|
self.plant=color
|
2024-03-10 15:03:56 +01:00
|
|
|
self.draw()
|
2024-03-23 13:46:48 +01:00
|
|
|
|
|
|
|
def set_random_plant(self):
|
2024-03-24 23:30:02 +01:00
|
|
|
(plant_name,self.plant_image)=self.random_plant()
|
|
|
|
self.plant=Roslina.Roslina(plant_name)
|
2024-03-23 13:46:48 +01:00
|
|
|
self.set_image()
|
|
|
|
|
|
|
|
def set_image(self):
|
2024-03-23 21:00:08 +01:00
|
|
|
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)
|
2024-03-23 13:46:48 +01:00
|
|
|
|
2024-04-15 10:02:09 +02:00
|
|
|
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)
|
|
|
|
|
2024-04-24 22:16:34 +02:00
|
|
|
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)
|
2024-04-27 00:59:48 +02:00
|
|
|
|
|
|
|
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)
|
2024-03-23 13:46:48 +01:00
|
|
|
|
|
|
|
def random_plant(self): #Probably will not be used later only for demo purpouse
|
|
|
|
return self.image_loader.return_random_plant()
|
2024-04-13 01:39:39 +02:00
|
|
|
|
|
|
|
def return_plant(self):
|
|
|
|
return self.plant
|
|
|
|
|
|
|
|
def get_hydrate_stats(self):
|
|
|
|
return self.plant.get_hydrate_stats()
|
2024-03-24 23:30:02 +01:00
|
|
|
|
|
|
|
def print_status(self):
|
2024-04-13 01:39:39 +02:00
|
|
|
return f"wspolrzedne: (X:{self.x_axis} Y:{self.y_axis}) "+self.plant.report_status()
|
2024-04-24 22:16:34 +02:00
|
|
|
|
2024-04-13 23:55:58 +02:00
|
|
|
def irrigatePlant(self):
|
|
|
|
self.plant.stan.nawodnienie = 100
|
2024-04-15 10:49:25 +02:00
|
|
|
|
|
|
|
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
|
2024-04-13 01:39:39 +02:00
|
|
|
|