Esempio n. 1
0
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()
 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_name,
                          '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