From 7dd2190c764623b8bd8f8947acd292cc2a9cd379 Mon Sep 17 00:00:00 2001 From: Pavel Date: Fri, 14 Apr 2023 00:25:35 +0200 Subject: [PATCH] Added maximum mount of container_filling value, it's 100% - one pell it's 25%. --- domain/commands/vacuum_move_command.py | 5 +++-- domain/entities/vacuum.py | 5 ++++- main.py | 3 +-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/domain/commands/vacuum_move_command.py b/domain/commands/vacuum_move_command.py index 2248b26..d150c2a 100644 --- a/domain/commands/vacuum_move_command.py +++ b/domain/commands/vacuum_move_command.py @@ -31,8 +31,9 @@ class VacuumMoveCommand(Command): return if self.world.is_garbage_at(end_x, end_y): - self.vacuum.increase_container_filling() - self.world.dust[end_x][end_y].pop() + if self.vacuum.get_container_filling() < 100: + self.vacuum.increase_container_filling() + self.world.dust[end_x][end_y].pop() if self.world.is_docking_station_at(end_x, end_y): self.vacuum.dump_trash() diff --git a/domain/entities/vacuum.py b/domain/entities/vacuum.py index 3d90409..1ccbc14 100644 --- a/domain/entities/vacuum.py +++ b/domain/entities/vacuum.py @@ -10,9 +10,12 @@ class Vacuum(Entity): self.container_filling = 0 def increase_container_filling(self) -> None: - self.container_filling += 10 + self.container_filling += 25 def dump_trash(self) -> None: self.container_filling = 0 + def get_container_filling(self): + return self.container_filling + # TODO VACUUM: add more properties diff --git a/main.py b/main.py index e9ad34d..2dac579 100644 --- a/main.py +++ b/main.py @@ -63,7 +63,6 @@ class Main: def update(self): self.commands.append(RandomCatMoveCommand(self.world, self.world.cat)) - for command in self.commands: command.run() self.commands.clear() @@ -76,7 +75,7 @@ def generate_world(tiles_x: int, tiles_y: int) -> World: temp_y = randint(0, tiles_y - 1) world.add_entity(Entity(temp_x, temp_y, "PEEL")) world.vacuum = Vacuum(1, 1) - world.doc_station = Doc_Station(9, 9) + world.doc_station = Doc_Station(9, 8) world.cat = Cat(7, 8) world.add_entity(world.cat) world.add_entity(Entity(2, 8, "PLANT1"))