Zmiejszono ilosc copy-paste ifow

This commit is contained in:
Konrad 2019-03-26 21:26:20 +01:00
parent 9ee0cf1f5c
commit 8d5febd918

View File

@ -34,20 +34,18 @@ class Garbage_collector(Cell):
rubbish = house.get_rubbish_data() rubbish = house.get_rubbish_data()
to_collect = rubbish to_collect = rubbish
if(rubbish[0] > GC_CAPACITY - self.trash_space_taken.get("plastic")): dic = {
to_collect[0] = self.trash_space_taken.get("plastic") 0: "plastic",
self.trash_space_taken['plastic'] += to_collect[0] 1: "glass",
self.trash_collected += to_collect[0] 2: "metal"
}
if(rubbish[1] > GC_CAPACITY - self.trash_space_taken.get("glass")): for i in range(0,2):
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")): if(rubbish[0] > GC_CAPACITY - self.trash_space_taken.get(dic[i])):
to_collect[2] = self.trash_space_taken.get("metal") to_collect[0] = self.trash_space_taken.get(dic[i])
self.trash_space_taken['metal'] += to_collect[2] self.trash_space_taken[dic[i]] += to_collect[i]
self.trash_collected += to_collect[2] self.trash_collected += to_collect[i]
house.give_away_rubbish(to_collect[0], to_collect[1], to_collect[2]) house.give_away_rubbish(to_collect[0], to_collect[1], to_collect[2])