2023-03-26 18:13:07 +02:00
|
|
|
from etykieta import Etykieta
|
2023-04-20 20:54:58 +02:00
|
|
|
import pygame
|
2023-05-29 00:13:02 +02:00
|
|
|
import ekran
|
2023-03-24 13:46:38 +01:00
|
|
|
|
|
|
|
|
2023-05-27 23:23:02 +02:00
|
|
|
class Paczka(pygame.sprite.Sprite):
|
2023-06-05 00:45:29 +02:00
|
|
|
def __init__(self, rozmiar, waga, kategoria, priorytet, ksztalt, kruchosc, nadawca, adres, imie, nazwisko, telefon, img_path):
|
2023-05-27 23:23:02 +02:00
|
|
|
super().__init__()
|
2023-03-24 13:46:38 +01:00
|
|
|
self.rozmiar = rozmiar
|
2023-05-06 14:54:04 +02:00
|
|
|
self.image = pygame.image.load("images/paczka.png")
|
2023-05-27 23:23:02 +02:00
|
|
|
self.rect = self.image.get_rect()
|
2023-05-06 14:54:04 +02:00
|
|
|
if rozmiar == 'duzy':
|
|
|
|
self.image = pygame.transform.scale(self.image, (50, 50))
|
|
|
|
self.szerokosc = 50
|
|
|
|
self.wysokosc = 50
|
|
|
|
elif rozmiar == 'sredni':
|
|
|
|
self.image = pygame.transform.scale(self.image, (35, 35))
|
|
|
|
self.szerokosc = 35
|
|
|
|
self.wysokosc = 35
|
|
|
|
elif rozmiar == 'maly':
|
|
|
|
self.image = pygame.transform.scale(self.image, (20, 20))
|
|
|
|
self.szerokosc = 20
|
|
|
|
self.wysokosc = 20
|
|
|
|
else:
|
|
|
|
self.image = pygame.transform.scale(self.image, (20, 20))
|
|
|
|
self.szerokosc = 20
|
|
|
|
self.wysokosc = 20
|
|
|
|
self.rozmiar = 'undefined'
|
2023-03-24 13:46:38 +01:00
|
|
|
self.waga = waga
|
|
|
|
self.kategoria = kategoria
|
2023-05-25 19:59:54 +02:00
|
|
|
self.priorytet = priorytet
|
|
|
|
self.ksztalt = ksztalt
|
|
|
|
self.kruchosc = kruchosc
|
2023-06-05 00:45:29 +02:00
|
|
|
self.img_path = img_path
|
2023-05-06 14:54:04 +02:00
|
|
|
self.x = 430
|
|
|
|
self.y = 400
|
2023-05-25 19:59:54 +02:00
|
|
|
self.label = Etykieta(nadawca, adres, imie, nazwisko, telefon, priorytet)
|
2023-05-29 11:00:58 +02:00
|
|
|
self.is_in_move = False
|
2023-03-24 13:46:38 +01:00
|
|
|
|
|
|
|
# zmienia rozmiar obrazka w zaleznosci od rozmiaru
|
|
|
|
def __dobierz_rozmiar_obrazka(self):
|
|
|
|
if self.rozmiar == "duzy":
|
|
|
|
self.image = pygame.transform.scale(self.image, (50, 50))
|
|
|
|
self.szerokosc = 50
|
|
|
|
self.wysokosc = 50
|
|
|
|
return 1
|
|
|
|
elif self.rozmiar == "sredni":
|
|
|
|
self.image = pygame.transform.scale(self.image, (35, 35))
|
|
|
|
self.szerokosc = 35
|
|
|
|
self.wysokosc = 35
|
|
|
|
return 1
|
|
|
|
elif self.rozmiar == "maly":
|
|
|
|
self.image = pygame.transform.scale(self.image, (20, 20))
|
|
|
|
self.szerokosc = 20
|
|
|
|
self.wysokosc = 20
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def narysuj(self, x, y, screen):
|
|
|
|
self.x = x
|
|
|
|
self.y = y
|
|
|
|
if self.__dobierz_rozmiar_obrazka() == 1:
|
|
|
|
screen.blit(self.image, (self.x, self.y))
|
|
|
|
else:
|
|
|
|
print("Zmien rozmiar paczki")
|
|
|
|
print("Paczka moze miec rozmiar duzy, sredni lub maly")
|
|
|
|
exit(0)
|
2023-05-27 23:23:02 +02:00
|
|
|
|
|
|
|
def update_position(self, x, y):
|
|
|
|
self.x = x
|
|
|
|
self.y = y
|
2023-05-29 00:13:02 +02:00
|
|
|
self.rect.topleft = (x, y)
|
|
|
|
|
|
|
|
def tablica_do_drzewa(self, kategoria):
|
|
|
|
tablica = []
|
|
|
|
# rozmiar
|
|
|
|
if self.rozmiar == 'maly':
|
|
|
|
tablica.append(0)
|
|
|
|
elif self.rozmiar == 'sredni':
|
|
|
|
tablica.append(1)
|
|
|
|
else: tablica.append(2)
|
|
|
|
|
|
|
|
# waga
|
2023-05-29 08:31:08 +02:00
|
|
|
if self.waga <= 2:
|
2023-05-29 00:13:02 +02:00
|
|
|
tablica.append(0)
|
2023-05-29 08:31:08 +02:00
|
|
|
elif self.waga <= 10:
|
2023-05-29 00:13:02 +02:00
|
|
|
tablica.append(1)
|
|
|
|
else: tablica.append(2)
|
|
|
|
|
|
|
|
# piorytet
|
|
|
|
if self.priorytet is True:
|
2023-05-30 18:47:23 +02:00
|
|
|
tablica.append(1)
|
|
|
|
else: tablica.append(0)
|
2023-05-29 00:13:02 +02:00
|
|
|
|
|
|
|
# kształt
|
|
|
|
if self.ksztalt is True:
|
2023-05-30 18:47:23 +02:00
|
|
|
tablica.append(1)
|
|
|
|
else: tablica.append(0)
|
2023-05-29 00:13:02 +02:00
|
|
|
|
|
|
|
# kruchość
|
|
|
|
if self.kruchosc is True:
|
2023-05-30 18:47:23 +02:00
|
|
|
tablica.append(1)
|
|
|
|
else: tablica.append(0)
|
2023-05-29 00:13:02 +02:00
|
|
|
|
|
|
|
reg = ekran.zwroc_regaly_kategoria(kategoria)
|
|
|
|
# czy dolna wolna
|
|
|
|
if reg[0].is_dolna_free() is True:
|
|
|
|
tablica.append(1)
|
2023-05-30 18:47:23 +02:00
|
|
|
else:
|
|
|
|
tablica.append(0)
|
2023-05-29 00:13:02 +02:00
|
|
|
|
|
|
|
#czy górna wolna
|
|
|
|
if reg[0].is_dolna_free() is True:
|
|
|
|
tablica.append(1)
|
2023-05-30 18:47:23 +02:00
|
|
|
else:
|
|
|
|
tablica.append(0)
|
2023-05-29 00:13:02 +02:00
|
|
|
|
|
|
|
# czy na górnej więcej miejsca
|
2023-05-30 18:47:23 +02:00
|
|
|
if reg[0].czy_na_gornej_wiecej_miejsca() is True:
|
2023-05-29 00:13:02 +02:00
|
|
|
tablica.append(1)
|
2023-05-30 18:47:23 +02:00
|
|
|
else:
|
|
|
|
tablica.append(0)
|
2023-05-29 00:13:02 +02:00
|
|
|
|
|
|
|
return tablica, reg[0]
|