This commit is contained in:
andrzej 2020-05-07 21:35:24 +02:00
parent 0e0f15a86e
commit ace8f74440
2 changed files with 9 additions and 8 deletions

View File

@ -49,7 +49,6 @@ class MainGameFrame:
for x in range(self.warehouse_map.width):
for y in range(self.warehouse_map.height):
self.draw_field(x, y)
self.draw_target(1, 1)
def draw_target(self, x, y):
target_screen_position = (

View File

@ -191,25 +191,27 @@ class Warehouse:
racks.append(y)
return racks
def place_packages(self, no_of_packages):
def place_packages(self, no_of_packages: int):
packages = []
for i in range(no_of_packages):
pack_x, pack_y = self._set_package_position()
new_package_size = random.randrange(1, 10)
pack_x, pack_y = self._set_package_position(new_package_size)
package_field = self.tiles[pack_x][pack_y]
new_package = Pack(lays_on_field=package_field)
categ_seed = random.random()
if categ_seed > 0.8:
new_package.category = "freezed"
new_package.set_status()
new_package.size = random.randrange(1, 10)
# new_package.set_status()
new_package.size = new_package_size
if package_field.category.name in self.storage_types:
package_field.capacity -= new_package.size
packages.append(new_package)
return packages
def _set_package_position(self):
def _set_package_position(self, pack_size: int):
starting_x, starting_y = random.randrange(self.width), random.randrange(self.height)
while not isinstance(self.tiles[starting_x][starting_y], Tile):
while not isinstance(self.tiles[starting_x][starting_y], Tile) \
and self.tiles[starting_x][starting_y].size - pack_size < 0:
starting_x, starting_y = random.randrange(self.width), random.randrange(
self.height)
return starting_x, starting_y