def set_up_take_anys(world, player):
    # these are references, do not modify these lists in-place
    if world.mode[player] == 'inverted':
        take_any_locs = take_any_locations_inverted
    else:
        take_any_locs = take_any_locations

    regions = world.random.sample(take_any_locs, 5)

    old_man_take_any = Region("Old Man Sword Cave", RegionType.Cave,
                              'the sword cave', player)
    world.regions.append(old_man_take_any)
    world.dynamic_regions.append(old_man_take_any)

    reg = regions.pop()
    entrance = world.get_region(reg, player).entrances[0]
    connect_entrance(world, entrance.name, old_man_take_any.name, player)
    entrance.target = 0x58
    old_man_take_any.shop = TakeAny(old_man_take_any, 0x0112, 0xE2, True, True,
                                    total_shop_slots)
    world.shops.append(old_man_take_any.shop)

    swords = [
        item for item in world.itempool
        if item.type == 'Sword' and item.player == player
    ]
    if swords:
        sword = world.random.choice(swords)
        world.itempool.remove(sword)
        world.itempool.append(ItemFactory('Rupees (20)', player))
        old_man_take_any.shop.add_inventory(0,
                                            sword.name,
                                            0,
                                            0,
                                            create_location=True)
    else:
        old_man_take_any.shop.add_inventory(0, 'Rupees (300)', 0, 0)

    for num in range(4):
        take_any = Region("Take-Any #{}".format(num + 1), RegionType.Cave,
                          'a cave of choice', player)
        world.regions.append(take_any)
        world.dynamic_regions.append(take_any)

        target, room_id = world.random.choice([(0x58, 0x0112), (0x60, 0x010F),
                                               (0x46, 0x011F)])
        reg = regions.pop()
        entrance = world.get_region(reg, player).entrances[0]
        connect_entrance(world, entrance.name, take_any.name, player)
        entrance.target = target
        take_any.shop = TakeAny(take_any, room_id, 0xE3, True, True,
                                total_shop_slots + num + 1)
        world.shops.append(take_any.shop)
        take_any.shop.add_inventory(0, 'Blue Potion', 0, 0)
        take_any.shop.add_inventory(1, 'Boss Heart Container', 0, 0)

    world.initialize_regions()
示例#2
0
def set_up_take_anys(world, player):
    if world.mode == 'inverted' and 'Dark Sanctuary Hint' in take_any_locations:
        take_any_locations.remove('Dark Sanctuary Hint')

    regions = random.sample(take_any_locations, 5)

    old_man_take_any = Region("Old Man Sword Cave", RegionType.Cave,
                              'the sword cave', player)
    world.regions.append(old_man_take_any)
    world.dynamic_regions.append(old_man_take_any)

    reg = regions.pop()
    entrance = world.get_region(reg, player).entrances[0]
    connect_entrance(world, entrance, old_man_take_any, player)
    entrance.target = 0x58
    old_man_take_any.shop = Shop(old_man_take_any, 0x0112, ShopType.TakeAny,
                                 0xE2, True)
    world.shops.append(old_man_take_any.shop)
    old_man_take_any.shop.active = True

    swords = [
        item for item in world.itempool
        if item.type == 'Sword' and item.player == player
    ]
    if swords:
        sword = random.choice(swords)
        world.itempool.remove(sword)
        world.itempool.append(ItemFactory('Rupees (20)', player))
        old_man_take_any.shop.add_inventory(0,
                                            sword.name,
                                            0,
                                            0,
                                            create_location=True)
    else:
        old_man_take_any.shop.add_inventory(0, 'Rupees (300)', 0, 0)

    for num in range(4):
        take_any = Region("Take-Any #{}".format(num + 1), RegionType.Cave,
                          'a cave of choice', player)
        world.regions.append(take_any)
        world.dynamic_regions.append(take_any)

        target, room_id = random.choice([(0x58, 0x0112), (0x60, 0x010F),
                                         (0x46, 0x011F)])
        reg = regions.pop()
        entrance = world.get_region(reg, player).entrances[0]
        connect_entrance(world, entrance, take_any, player)
        entrance.target = target
        take_any.shop = Shop(take_any, room_id, ShopType.TakeAny, 0xE3, True)
        world.shops.append(take_any.shop)
        take_any.shop.active = True
        take_any.shop.add_inventory(0, 'Blue Potion', 0, 0)
        take_any.shop.add_inventory(1, 'Boss Heart Container', 0, 0)

    world.intialize_regions()
 def testInvalidEntrances(self):
     for entrance_name in [
             'Desert Palace Entrance (East)', 'Spectacle Rock Cave',
             'Spectacle Rock Cave (Bottom)'
     ]:
         entrance = self.world.get_entrance(entrance_name, 1)
         connect_entrance(self.world, entrance, 'Inverted Big Bomb Shop', 1)
         with self.assertRaises(Exception):
             set_inverted_big_bomb_rules(self.world, 1)
         entrance.connected_region.entrances.remove(entrance)
         entrance.connected_region = None
 def testInvertedBombRulesAreComplete(self):
     entrances = list(Inverted_LW_Entrances +
                      Inverted_LW_Dungeon_Entrances +
                      Inverted_LW_Single_Cave_Doors +
                      Inverted_Old_Man_Entrances + Inverted_DW_Entrances +
                      Inverted_DW_Dungeon_Entrances +
                      Inverted_DW_Single_Cave_Doors)
     must_exits = list(Inverted_LW_Entrances_Must_Exit +
                       Inverted_LW_Dungeon_Entrances_Must_Exit)
     for entrance_name in (entrances + must_exits):
         if entrance_name not in [
                 'Desert Palace Entrance (East)', 'Spectacle Rock Cave',
                 'Spectacle Rock Cave (Bottom)'
         ]:
             entrance = self.world.get_entrance(entrance_name, 1)
             connect_entrance(self.world, entrance_name,
                              'Inverted Big Bomb Shop', 1)
             set_inverted_big_bomb_rules(self.world, 1)
             entrance.connected_region.entrances.remove(entrance)
             entrance.connected_region = None
def fill_world(world, plando, text_patches):
    mm_medallion = 'Ether'
    tr_medallion = 'Quake'
    logger = logging.getLogger('')
    with open(plando, 'r') as plandofile:
        for line in plandofile.readlines():
            if line.startswith('#'):
                continue
            if ':' in line:
                line = line.lstrip()

                if line.startswith('!'):
                    if line.startswith('!mm_medallion'):
                        _, medallionstr = line.split(':', 1)
                        mm_medallion = medallionstr.strip()
                    elif line.startswith('!tr_medallion'):
                        _, medallionstr = line.split(':', 1)
                        tr_medallion = medallionstr.strip()
                    elif line.startswith('!mode'):
                        _, modestr = line.split(':', 1)
                        world.mode = modestr.strip()
                    elif line.startswith('!logic'):
                        _, logicstr = line.split(':', 1)
                        world.logic = logicstr.strip()
                    elif line.startswith('!goal'):
                        _, goalstr = line.split(':', 1)
                        world.goal = goalstr.strip()
                    elif line.startswith('!light_cone_sewers'):
                        _, sewerstr = line.split(':', 1)
                        world.sewer_light_cone = sewerstr.strip().lower(
                        ) == 'true'
                    elif line.startswith('!light_cone_lw'):
                        _, lwconestr = line.split(':', 1)
                        world.light_world_light_cone = lwconestr.strip().lower(
                        ) == 'true'
                    elif line.startswith('!light_cone_dw'):
                        _, dwconestr = line.split(':', 1)
                        world.dark_world_light_cone = dwconestr.strip().lower(
                        ) == 'true'
                    elif line.startswith('!fix_trock_doors'):
                        _, trdstr = line.split(':', 1)
                        world.fix_trock_doors = trdstr.strip().lower(
                        ) == 'true'
                    elif line.startswith('!fix_trock_exit'):
                        _, trfstr = line.split(':', 1)
                        world.fix_trock_exit = trfstr.strip().lower() == 'true'
                    elif line.startswith('!fix_gtower_exit'):
                        _, gtfstr = line.split(':', 1)
                        world.fix_gtower_exit = gtfstr.strip().lower(
                        ) == 'true'
                    elif line.startswith('!fix_pod_exit'):
                        _, podestr = line.split(':', 1)
                        world.fix_palaceofdarkness_exit = podestr.strip(
                        ).lower() == 'true'
                    elif line.startswith('!fix_skullwoods_exit'):
                        _, swestr = line.split(':', 1)
                        world.fix_skullwoods_exit = swestr.strip().lower(
                        ) == 'true'
                    elif line.startswith('!check_beatable_only'):
                        _, chkbtstr = line.split(':', 1)
                        world.check_beatable_only = chkbtstr.strip().lower(
                        ) == 'true'
                    elif line.startswith('!ganon_death_pyramid_respawn'):
                        _, gnpstr = line.split(':', 1)
                        world.ganon_at_pyramid = gnpstr.strip().lower(
                        ) == 'true'
                    elif line.startswith('!save_quit_boss'):
                        _, sqbstr = line.split(':', 1)
                        world.save_and_quite_from_boss = sqbstr.strip().lower(
                        ) == 'true'
                    elif line.startswith('!text_'):
                        textname, text = line.split(':', 1)
                        text_patches.append([
                            textname.lstrip('!text_').strip(), 'text',
                            text.strip()
                        ])
                    elif line.startswith('!credits_'):
                        textname, text = line.split(':', 1)
                        text_patches.append([
                            textname.lstrip('!credits_').strip(), 'credits',
                            text.strip()
                        ])
                    continue

                locationstr, itemstr = line.split(':', 1)
                location = world.get_location(locationstr.strip())
                if location is None:
                    logger.warn('Unknown location: %s' % locationstr)
                    continue
                else:
                    item = ItemFactory(itemstr.strip())
                    if item is not None:
                        world.push_item(location, item)
                    if item.key:
                        location.event = True
            elif '<=>' in line:
                entrance, exit = line.split('<=>', 1)
                connect_two_way(world, entrance.strip(), exit.strip())
            elif '=>' in line:
                entrance, exit = line.split('=>', 1)
                connect_entrance(world, entrance.strip(), exit.strip())
            elif '<=' in line:
                entrance, exit = line.split('<=', 1)
                connect_exit(world, exit.strip(), entrance.strip())

    world.required_medallions = (mm_medallion, tr_medallion)

    # set up Agahnim Events
    world.get_location('Agahnim 1').event = True
    world.get_location('Agahnim 1').item = ItemFactory('Beat Agahnim 1')
    world.get_location('Agahnim 2').event = True
    world.get_location('Agahnim 2').item = ItemFactory('Beat Agahnim 2')