Correct out of bounds errors and add missing arguments to range call
This commit is contained in:
		@@ -29,15 +29,17 @@ class Generator:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @staticmethod
 | 
					    @staticmethod
 | 
				
			||||||
    def room_fits(level, y, x, room, door_y, door_x, dy, dx):
 | 
					    def room_fits(level, y, x, room, door_y, door_x, dy, dx):
 | 
				
			||||||
        if level[y][x] != Tile.EMPTY or level[y-dy][x-dx] != Tile.FLOOR:
 | 
					 | 
				
			||||||
            return False
 | 
					 | 
				
			||||||
        lh, lw = len(level), len(level[0])
 | 
					        lh, lw = len(level), len(level[0])
 | 
				
			||||||
        rh, rw = len(room), len(room[0])
 | 
					        rh, rw = len(room), len(room[0])
 | 
				
			||||||
 | 
					        if not(0 < y+dy < lh and 0 < x+dx < lw):
 | 
				
			||||||
 | 
					            return False
 | 
				
			||||||
 | 
					        if level[y][x] != Tile.EMPTY or level[y+dy][x+dx] != Tile.FLOOR:
 | 
				
			||||||
 | 
					            return False
 | 
				
			||||||
        for ry in range(rh):
 | 
					        for ry in range(rh):
 | 
				
			||||||
            for rx in range(rw):
 | 
					            for rx in range(rw):
 | 
				
			||||||
                if room[ry][rx] == Tile.FLOOR:
 | 
					                if room[ry][rx] == Tile.FLOOR:
 | 
				
			||||||
                    ly, lx = y + ry - door_y, x + rx - door_x
 | 
					                    ly, lx = y + ry - door_y, x + rx - door_x
 | 
				
			||||||
                    if not(0 <= ly <= rh and 0 <= lx <= rw) or \
 | 
					                    if not(0 <= ly < lh and 0 <= lx < lw) or \
 | 
				
			||||||
                            level[ly][lx] == Tile.FLOOR:
 | 
					                            level[ly][lx] == Tile.FLOOR:
 | 
				
			||||||
                        return False
 | 
					                        return False
 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user