def create_door_spoiler(world, player):
    logger = logging.getLogger('')
    queue = deque(world.dungeon_layouts[player].values())
    while (len(queue) > 0):
        builder = queue.popleft()
        done = set()
        start_regions = set(convert_regions(builder.layout_starts, world, player))
        reg_queue = deque(start_regions)
        visited = set(start_regions)
        while (len(reg_queue) > 0):
            next = reg_queue.pop()
            for ext in next.exits:
                door_a = ext.door
                connect = ext.connected_region
                if (door_a and (door_a.type in [DoorType.Normal, DoorType.SpiralStairs]) and (door_a not in done)):
                    done.add(door_a)
                    door_b = door_a.dest
                    if door_b:
                        done.add(door_b)
                        if ((not door_a.blocked) and (not door_b.blocked)):
                            world.spoiler.set_door(door_a.name, door_b.name, 'both', player, builder.name)
                        elif door_a.blocked:
                            world.spoiler.set_door(door_b.name, door_a.name, 'entrance', player, builder.name)
                        elif door_b.blocked:
                            world.spoiler.set_door(door_a.name, door_b.name, 'entrance', player, builder.name)
                        else:
                            logger.warning('This is a bug during door spoiler')
                    else:
                        logger.warning('Door not connected: %s', door_a.name)
                if (connect and (connect.type == RegionType.Dungeon) and (connect not in visited)):
                    visited.add(connect)
                    reg_queue.append(connect)
def create_door_spoiler(world, player):
    logger = logging.getLogger()
    queue = deque(world.dungeon_layouts[player].values())
    while (len(queue) > 0):
        builder = queue.popleft()
        done = set()
        start_regions = set(convert_regions(builder.layout_starts, world, player))
        reg_queue = deque(start_regions)
        visited = set(start_regions)
        while (len(reg_queue) > 0):
            next = reg_queue.pop()
            for ext in next.exits:
                door_a = ext.door
                connect = ext.connected_region
                if (door_a and (door_a.type in [DoorType.Normal, DoorType.SpiralStairs]) and (door_a not in done)):
                    done.add(door_a)
                    door_b = door_a.dest
                    if door_b:
                        done.add(door_b)
                        if ((not door_a.blocked) and (not door_b.blocked)):
                            world.spoiler.set_door(door_a.name, door_b.name, 'both', player, builder.name)
                        elif door_a.blocked:
                            world.spoiler.set_door(door_b.name, door_a.name, 'entrance', player, builder.name)
                        elif door_b.blocked:
                            world.spoiler.set_door(door_a.name, door_b.name, 'entrance', player, builder.name)
                        else:
                            logger.warning('This is a bug during door spoiler')
                    else:
                        logger.warning('Door not connected: %s', door_a.name)
                if (connect and (connect.type == RegionType.Dungeon) and (connect not in visited)):
                    visited.add(connect)
                    reg_queue.append(connect)