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,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):