2022-03-24 20:02:21 +01:00
|
|
|
import pygame
|
2022-04-25 17:26:32 +02:00
|
|
|
from Field import Field
|
2022-04-20 18:27:24 +02:00
|
|
|
from Global_variables import Global_variables as G_var
|
2022-05-26 22:56:40 +02:00
|
|
|
from Sectors_types import Sectors_types
|
2022-05-08 20:57:20 +02:00
|
|
|
from Types_colors import Types_colors
|
2022-03-24 20:02:21 +01:00
|
|
|
|
2022-04-25 17:26:32 +02:00
|
|
|
|
|
|
|
class Shelf(Field):
|
2022-05-12 21:16:05 +02:00
|
|
|
def __init__(self, window, x, y, type, sector):
|
2022-04-25 17:26:32 +02:00
|
|
|
Field.__init__(self, window, x, y)
|
|
|
|
self.type = type
|
2022-05-08 20:57:20 +02:00
|
|
|
self.color = Types_colors.get_shelf_color(type)
|
2022-05-12 21:16:05 +02:00
|
|
|
self.sector = sector
|
2022-05-08 20:57:20 +02:00
|
|
|
self.rect = pygame.Rect(self.x * G_var().RECT_SIZE, self.y *
|
2022-04-25 17:26:32 +02:00
|
|
|
G_var().RECT_SIZE, G_var().RECT_SIZE, G_var().RECT_SIZE)
|
2022-03-24 20:02:21 +01:00
|
|
|
|
2022-05-26 22:56:40 +02:00
|
|
|
|
|
|
|
|
2022-03-24 20:02:21 +01:00
|
|
|
def draw(self):
|
2022-05-26 22:56:40 +02:00
|
|
|
my_font = pygame.font.SysFont('Arial', 30)
|
2022-05-08 20:57:20 +02:00
|
|
|
self.rect = pygame.Rect(self.x * G_var().RECT_SIZE, self.y *
|
2022-04-25 17:26:32 +02:00
|
|
|
G_var().RECT_SIZE, G_var().RECT_SIZE, G_var().RECT_SIZE)
|
2022-05-26 22:56:40 +02:00
|
|
|
pygame.draw.rect(self.window, self.color, self.rect)
|
|
|
|
text = self.choose_letter_acc_to_sector()
|
|
|
|
text_surface = my_font.render(text, False, (255, 255, 255))
|
|
|
|
self.window.blit(text_surface, (self.x * G_var().RECT_SIZE, self.y *
|
|
|
|
G_var().RECT_SIZE))
|
|
|
|
|
|
|
|
def choose_letter_acc_to_sector(self):
|
|
|
|
if self.sector == Sectors_types.normal:
|
|
|
|
letter = "N"
|
|
|
|
elif self.sector == Sectors_types.fragile:
|
|
|
|
letter = "F"
|
|
|
|
elif self.sector == Sectors_types.shipping_today:
|
|
|
|
letter = "T!"
|
|
|
|
else:
|
|
|
|
letter = "T"
|
|
|
|
return letter
|