diff --git a/sprites/garbage_collector.py b/sprites/garbage_collector.py index e1e11af..ba06dc6 100644 --- a/sprites/garbage_collector.py +++ b/sprites/garbage_collector.py @@ -34,21 +34,19 @@ class Garbage_collector(Cell): rubbish = house.get_rubbish_data() to_collect = rubbish - if(rubbish[0] > GC_CAPACITY - self.trash_space_taken.get("plastic")): - to_collect[0] = self.trash_space_taken.get("plastic") - self.trash_space_taken['plastic'] += to_collect[0] - self.trash_collected += to_collect[0] + dic = { + 0: "plastic", + 1: "glass", + 2: "metal" + } + + for i in range(0,2): + + if(rubbish[0] > GC_CAPACITY - self.trash_space_taken.get(dic[i])): + to_collect[0] = self.trash_space_taken.get(dic[i]) + self.trash_space_taken[dic[i]] += to_collect[i] + self.trash_collected += to_collect[i] - if(rubbish[1] > GC_CAPACITY - self.trash_space_taken.get("glass")): - to_collect[1] = self.trash_space_taken.get("glass") - self.trash_space_taken['glass'] += to_collect[1] - self.trash_collected += to_collect[1] - - if(rubbish[2] > GC_CAPACITY - self.trash_space_taken.get("metal")): - to_collect[2] = self.trash_space_taken.get("metal") - self.trash_space_taken['metal'] += to_collect[2] - self.trash_collected += to_collect[2] - house.give_away_rubbish(to_collect[0], to_collect[1], to_collect[2]) def get_collect_data(self):