from DataModels.Cell import Cell from DataModels.Road import Road from DataModels.House import House from DataModels.Dump import Dump from config import GRID_WIDTH, GRID_HEIGHT # PODAC TUTAJ X I Y DO MOVEMENT (ZAIMPORTOWAC TO NAJPIERW) class GC(Cell): moves_made = 0 def __init__(self, x, y, max_rubbish, yellow=0, green=0, blue=0): Cell.__init__(self, x, y, max_rubbish, yellow, green, blue) def check_moves(self, direction, environment, x = None, y = None): if((x,y) == (None, None)): x = self.x y = self.y print(environment) return ([dir for dir in self.movement(environment)[0] if self.movement(environment)[0][dir] != (x,y) and dir != self.movement(environment)[1][direction]]) def move(self, direction, environment): self.x, self.y = self.movement(environment)[0][direction] self.update_rect(self.x, self.y) self.moves_made = self.moves_made + 1 print(self.check_moves(direction, environment)) def collect(self, enviromnent): x, y = [self.x, self.y] coordinates = [(x, y - 1), (x, y + 1), (x - 1, y), (x + 1, y)] for coordinate in coordinates: if coordinate[0]<0 or coordinate[1]<0: continue try: item = enviromnent[coordinate[0]][coordinate[1]] except: continue if(type(item) == House or type(item) == Dump): item.return_trash(self) self.update_image() def get_moves_made(self): return self.moves_made