From fb6ebb1d7d29f11b02c323406bd31d1f1817847d Mon Sep 17 00:00:00 2001 From: tonywesoly Date: Mon, 25 Apr 2022 17:58:51 +0200 Subject: [PATCH] Fixes to placing packages --- Environment.py | 1 - Moving_truck.py | 7 ++++--- Package.py | 1 + Placed_package.py | 7 ------- 4 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 Placed_package.py diff --git a/Environment.py b/Environment.py index 4d55c12..2fe54dd 100644 --- a/Environment.py +++ b/Environment.py @@ -2,7 +2,6 @@ from Empty import Empty from Moving_truck import Moving_truck from Package import Package from Package_types import Package_types -from Placed_package import Placed_package from Shelf import Shelf import pygame import random diff --git a/Moving_truck.py b/Moving_truck.py index 976efd4..01022f4 100644 --- a/Moving_truck.py +++ b/Moving_truck.py @@ -1,6 +1,5 @@ from Empty import Empty from Package import Package -from Placed_package import Placed_package from Shelf import Shelf @@ -16,7 +15,7 @@ class Moving_truck: field_to_move_to = self.enviroment_2d[truck_x+x][truck_y+y] if isinstance(field_to_move_to, Empty): self.swap_fields(truck_x, truck_y, truck_x+x, truck_y+y) - elif isinstance(field_to_move_to, Package) and not isinstance(field_to_move_to, Placed_package): + elif isinstance(field_to_move_to, Package) and not field_to_move_to.is_placed: self.move_truck_with_package(x, y) def move_truck_with_package(self, x, y): @@ -38,8 +37,10 @@ class Moving_truck: truck_x = self.truck.x truck_y = self.truck.y package = self.enviroment_2d[truck_x+x][truck_y+y] + # self.enviroment_2d[truck_x+x][truck_y + + # y] = Placed_package(package) self.enviroment_2d[truck_x+x][truck_y + - y] = Placed_package(package) + y].is_placed = True self.move_without_swapping( truck_x+x, truck_y+y, truck_x+(x*2), truck_y+(y*2)) self.move_without_swapping(truck_x, truck_y, truck_x+x, truck_y+y) diff --git a/Package.py b/Package.py index e2b02b9..2ffb153 100644 --- a/Package.py +++ b/Package.py @@ -12,6 +12,7 @@ class Package(Field): Field.__init__(self, window, x, y) self.mark_image = self.get_marking_photo() self.type = random.choice(list(Package_types)) + self.is_placed = False def get_marking_photo(self): file_path_type = ["resources/package_markings/*.jpg"] diff --git a/Placed_package.py b/Placed_package.py deleted file mode 100644 index 980d5c6..0000000 --- a/Placed_package.py +++ /dev/null @@ -1,7 +0,0 @@ -from Package import Package - - -class Placed_package(Package): - def __init__(self, package): - Package.__init__(self, package.window, package.x, package.y) - self.type = package.type