コード例 #1
0
ファイル: Main.py プロジェクト: SarienFates/MMRandomizer
def copy_world(world):
    # ToDo: Not good yet
    ret = World(world.bridge, world.open_forest, world.open_door_of_time, world.place_dungeon_items, world.check_beatable_only, world.hints)
    ret.seed = world.seed
    ret.can_take_damage = world.can_take_damage
    create_regions(ret)
    create_dungeons(ret)

    # connect copied world
    for region in world.regions:
        copied_region = ret.get_region(region.name)
        for entrance in region.entrances:
            ret.get_entrance(entrance.name).connect(copied_region)

    # fill locations
    for location in world.get_locations():
        if location.item is not None:
            item = Item(location.item.name, location.item.advancement, location.item.priority, location.item.type)
            ret.get_location(location.name).item = item
            item.location = ret.get_location(location.name)
        if location.event:
            ret.get_location(location.name).event = True

    # copy remaining itempool. No item in itempool should have an assigned location
    for item in world.itempool:
        ret.itempool.append(Item(item.name, item.advancement, item.priority, item.type))

    # copy progress items in state
    ret.state.prog_items = list(world.state.prog_items)

    set_rules(ret)

    return ret
コード例 #2
0
def create_item_with_correct_settings(world: MultiWorld, player: int,
                                      name: str) -> Item:
    data = item_table[name]
    if data.useful:
        classification = ItemClassification.useful
    elif data.progression:
        classification = ItemClassification.progression
    else:
        classification = ItemClassification.filler
    item = Item(name, classification, data.code, player)

    if not item.advancement:
        return item

    if (name == 'Tablet'
            or name == 'Library Keycard V') and not is_option_enabled(
                world, player, "DownloadableItems"):
        item.classification = ItemClassification.filler
    elif name == 'Oculus Ring' and not is_option_enabled(
            world, player, "FacebookMode"):
        item.classification = ItemClassification.filler
    elif (name == 'Kobo' or name == 'Merchant Crow') and not is_option_enabled(
            world, player, "GyreArchives"):
        item.classification = ItemClassification.filler

    return item
コード例 #3
0
def copy_world(world):
    # ToDo: Not good yet
    ret = World(world.shuffle, world.logic, world.mode, world.difficulty, world.timer, world.progressive, world.goal, world.algorithm, world.place_dungeon_items, world.check_beatable_only, world.shuffle_ganon, world.quickswap, world.fastmenu, world.disable_music, world.keysanity, world.retro, world.custom, world.customitemarray)
    ret.required_medallions = list(world.required_medallions)
    ret.swamp_patch_required = world.swamp_patch_required
    ret.ganon_at_pyramid = world.ganon_at_pyramid
    ret.treasure_hunt_count = world.treasure_hunt_count
    ret.treasure_hunt_icon = world.treasure_hunt_icon
    ret.sewer_light_cone = world.sewer_light_cone
    ret.light_world_light_cone = world.light_world_light_cone
    ret.dark_world_light_cone = world.dark_world_light_cone
    ret.seed = world.seed
    ret.can_access_trock_eyebridge = world.can_access_trock_eyebridge
    ret.can_take_damage = world.can_take_damage
    ret.difficulty_requirements = world.difficulty_requirements
    ret.fix_fake_world = world.fix_fake_world
    ret.lamps_needed_for_dark_rooms = world.lamps_needed_for_dark_rooms
    create_regions(ret)
    create_dungeons(ret)

    copy_dynamic_regions_and_locations(world, ret)

    for shop in world.shops:
        copied_shop = ret.get_region(shop.region.name).shop
        copied_shop.active = shop.active
        copied_shop.inventory = copy.copy(shop.inventory)

    # connect copied world
    for region in world.regions:
        copied_region = ret.get_region(region.name)
        copied_region.is_light_world = region.is_light_world
        copied_region.is_dark_world = region.is_dark_world
        for entrance in region.entrances:
            ret.get_entrance(entrance.name).connect(copied_region)

    # fill locations
    for location in world.get_locations():
        if location.item is not None:
            item = Item(location.item.name, location.item.advancement, location.item.priority, location.item.type)
            ret.get_location(location.name).item = item
            item.location = ret.get_location(location.name)
        if location.event:
            ret.get_location(location.name).event = True

    # copy remaining itempool. No item in itempool should have an assigned location
    for item in world.itempool:
        ret.itempool.append(Item(item.name, item.advancement, item.priority, item.type))

    # copy progress items in state
    ret.state.prog_items = list(world.state.prog_items)

    set_rules(ret)

    return ret
コード例 #4
0
ファイル: __init__.py プロジェクト: dewiniaid/Archipelago
def gen_factorio(world: MultiWorld, player: int):
    static_nodes = world._static_nodes = {"automation", "logistics"}  # turn dynamic/option?
    for tech_name, tech_id in tech_table.items():
        tech_item = Item(tech_name, tech_name in advancement_technologies, tech_id, player)
        tech_item.game = "Factorio"
        if tech_name in static_nodes:
            loc = world.get_location(tech_name, player)
            loc.item = tech_item
            loc.locked = True
            loc.event = tech_item.advancement
        else:
            world.itempool.append(tech_item)
    set_rules(world, player)
コード例 #5
0
ファイル: __init__.py プロジェクト: KonoTyran/Archipelago
    def generate_basic(self):
        item_table_copy = list(item_table)
        self.world.random.shuffle(item_table_copy)

        item_pool = []
        for i in range(100):
            item = Item(
                item_table_copy[i], ItemClassification.progression
                if i < 20 else ItemClassification.filler,
                self.item_name_to_id[item_table_copy[i]], self.player)
            item.game = 'ArchipIDLE'
            item_pool.append(item)

        self.world.itempool += item_pool
コード例 #6
0
def ItemFactory(items):
    ret = []
    singleton = False
    if isinstance(items, str):
        items = [items]
        singleton = True
    for item in items:
        if item in item_table:
            advancement, priority, key, crystal, code, altar_hint, altar_credit, sickkid_credit, zora_credit, witch_credit, fluteboy_credit = item_table[
                item]
            if item == 'Bottle':
                # randomly fill bottle
                code = [0x16, 0x2B, 0x2C, 0x2D, 0x3C, 0x3D,
                        0x48][random.randint(0, 6)]
            ret.append(
                Item(item, advancement, priority, key, crystal, code,
                     altar_hint, altar_credit, sickkid_credit, zora_credit,
                     witch_credit, fluteboy_credit))
        else:
            logging.getLogger('').warning('Unknown Item: %s' % item)
            return None

    if singleton:
        return ret[0]
    else:
        return ret
コード例 #7
0
ファイル: __init__.py プロジェクト: KonoTyran/Archipelago
    def create_regions(self):
        locations = get_options(self.world, 'locations', self.player)
        rules = get_options(self.world, 'rules', self.player)
        menu_region = self.ff1_locations.create_menu_region(
            self.player, locations, rules)
        terminated_event = Location(self.player, CHAOS_TERMINATED_EVENT,
                                    EventId, menu_region)
        terminated_item = Item(CHAOS_TERMINATED_EVENT, True, EventId,
                               self.player)
        terminated_event.place_locked_item(terminated_item)

        items = get_options(self.world, 'items', self.player)
        goal_rule = generate_rule([[
            name for name in items.keys()
            if name in FF1_PROGRESSION_LIST and name != "Shard"
        ]], self.player)
        if "Shard" in items.keys():

            def goal_rule_and_shards(state):
                return goal_rule(state) and state.has("Shard", self.player, 32)

            terminated_event.access_rule = goal_rule_and_shards

        menu_region.locations.append(terminated_event)
        self.world.regions += [menu_region]
コード例 #8
0
def copy_world(world):
    # ToDo: Not good yet
    ret = World(world.shuffle, world.logic, world.mode, world.difficulty,
                world.timer, world.progressive, world.goal, world.algorithm,
                world.place_dungeon_items, world.check_beatable_only,
                world.shuffle_ganon, world.quickswap, world.fastmenu,
                world.keysanity)
    ret.required_medallions = list(world.required_medallions)
    ret.swamp_patch_required = world.swamp_patch_required
    ret.ganon_at_pyramid = world.ganon_at_pyramid
    ret.treasure_hunt_count = world.treasure_hunt_count
    ret.treasure_hunt_icon = world.treasure_hunt_icon
    ret.sewer_light_cone = world.sewer_light_cone
    ret.light_world_light_cone = world.light_world_light_cone
    ret.dark_world_light_cone = world.dark_world_light_cone
    ret.seed = world.seed
    ret.can_access_trock_eyebridge = world.can_access_trock_eyebridge
    create_regions(ret)
    create_dungeons(ret)

    # connect copied world
    for region in world.regions:
        for entrance in region.entrances:
            ret.get_entrance(entrance.name).connect(ret.get_region(
                region.name))

    # fill locations
    for location in world.get_locations():
        if location.item is not None:
            item = Item(location.item.name, location.item.advancement,
                        location.item.priority, location.item.type)
            ret.get_location(location.name).item = item
            item.location = ret.get_location(location.name)
        if location.event:
            ret.get_location(location.name).event = True

    # copy remaining itempool. No item in itempool should have an assigned location
    for item in world.itempool:
        ret.itempool.append(
            Item(item.name, item.advancement, item.priority, item.type))

    # copy progress items in state
    ret.state.prog_items = list(world.state.prog_items)

    set_rules(ret)

    return ret
コード例 #9
0
def setup_events(world: MultiWorld, player: int, locked_locations: typing.List[str], location_cache: typing.List[Location]):
    for location in location_cache:
        if location.address is None:
            item = Item(location.name, ItemClassification.progression, None, player)

            locked_locations.append(location.name)

            location.place_locked_item(item)
コード例 #10
0
def setup_events(player: int, locked_locations: List[str],
                 location_cache: List[Location]):
    for location in location_cache:
        if location.address == EventId:
            item = Item(location.name, ItemClassification.progression, EventId,
                        player)

            locked_locations.append(location.name)

            location.place_locked_item(item)
コード例 #11
0
def ItemFactory(items, world=None):
    ret = []
    singleton = False
    if isinstance(items, str):
        items = [items]
        singleton = True
    for item in items:
        if item in item_table:
            advancement, priority, type, code, index, object, model = item_table[
                item]
            new_item = Item(item, advancement, priority, type, code, index,
                            object, model)
            if world:
                new_item.world = world
            ret.append(new_item)
        else:
            raise KeyError('Unknown Item: %s', item)

    if singleton:
        return ret[0]
    return ret
コード例 #12
0
ファイル: TestFill.py プロジェクト: KonoTyran/Archipelago
def generate_items(count: int,
                   player_id: int,
                   advancement: bool = False,
                   code: int = None) -> List[Item]:
    items = []
    item_type = "prog" if advancement else ""
    for i in range(count):
        name = "player" + str(player_id) + "_" + item_type + "item" + str(i)
        items.append(
            Item(
                name, ItemClassification.progression if advancement else
                ItemClassification.filler, code, player_id))
    return items
コード例 #13
0
def ItemFactory(items, player):
    from BaseClasses import Item
    ret = []
    singleton = False
    if isinstance(items, str):
        items = [items]
        singleton = True
    for item in items:
        if item in item_table:
            ret.append(Item(item, *item_table[item], player))
        else:
            raise Exception(f"Unknown item {item}")

    if singleton:
        return ret[0]
    return ret
コード例 #14
0
def ItemFactory(items):
    ret = []
    singleton = False
    if isinstance(items, str):
        items = [items]
        singleton = True
    for item in items:
        if item in item_table:
            advancement, priority, type, code, index = item_table[item]
            ret.append(Item(item, advancement, priority, type, code, index))
        else:
            logging.getLogger('').warning('Unknown Item: %s', item)
            return None

    if singleton:
        return ret[0]
    return ret
コード例 #15
0
def ItemFactory(items, player):
    ret = []
    singleton = False
    if isinstance(items, str):
        items = [items]
        singleton = True
    for item in items:
        if item in item_table:
            advancement, priority, type, code, pedestal_hint, pedestal_credit, sickkid_credit, zora_credit, witch_credit, fluteboy_credit, hint_text = item_table[
                item]
            ret.append(
                Item(item, advancement, priority, type, code, pedestal_hint,
                     pedestal_credit, sickkid_credit, zora_credit,
                     witch_credit, fluteboy_credit, hint_text, player))
        else:
            logging.getLogger('').warning('Unknown Item: %s', item)
            return None

    if singleton:
        return ret[0]
    return ret
コード例 #16
0
def copy_world(world):
    # ToDo: Not good yet
    ret = World(world.players, world.shuffle, world.logic, world.mode,
                world.swords, world.difficulty, world.difficulty_adjustments,
                world.timer, world.progressive, world.goal, world.algorithm,
                world.accessibility, world.shuffle_ganon, world.retro,
                world.custom, world.customitemarray, world.hints)
    ret.teams = world.teams
    ret.player_names = copy.deepcopy(world.player_names)
    ret.remote_items = world.remote_items.copy()
    ret.required_medallions = world.required_medallions.copy()
    ret.swamp_patch_required = world.swamp_patch_required.copy()
    ret.ganon_at_pyramid = world.ganon_at_pyramid.copy()
    ret.powder_patch_required = world.powder_patch_required.copy()
    ret.ganonstower_vanilla = world.ganonstower_vanilla.copy()
    ret.treasure_hunt_count = world.treasure_hunt_count.copy()
    ret.treasure_hunt_icon = world.treasure_hunt_icon.copy()
    ret.sewer_light_cone = world.sewer_light_cone.copy()
    ret.light_world_light_cone = world.light_world_light_cone
    ret.dark_world_light_cone = world.dark_world_light_cone
    ret.seed = world.seed
    ret.can_access_trock_eyebridge = world.can_access_trock_eyebridge.copy()
    ret.can_access_trock_front = world.can_access_trock_front.copy()
    ret.can_access_trock_big_chest = world.can_access_trock_big_chest.copy()
    ret.can_access_trock_middle = world.can_access_trock_middle.copy()
    ret.can_take_damage = world.can_take_damage
    ret.difficulty_requirements = world.difficulty_requirements.copy()
    ret.fix_fake_world = world.fix_fake_world.copy()
    ret.lamps_needed_for_dark_rooms = world.lamps_needed_for_dark_rooms
    ret.mapshuffle = world.mapshuffle.copy()
    ret.compassshuffle = world.compassshuffle.copy()
    ret.keyshuffle = world.keyshuffle.copy()
    ret.bigkeyshuffle = world.bigkeyshuffle.copy()
    ret.crystals_needed_for_ganon = world.crystals_needed_for_ganon.copy()
    ret.crystals_needed_for_gt = world.crystals_needed_for_gt.copy()
    ret.open_pyramid = world.open_pyramid.copy()
    ret.boss_shuffle = world.boss_shuffle.copy()
    ret.enemy_shuffle = world.enemy_shuffle.copy()
    ret.enemy_health = world.enemy_health.copy()
    ret.enemy_damage = world.enemy_damage.copy()
    ret.beemizer = world.beemizer.copy()
    ret.timer = world.timer.copy()
    ret.shufflepots = world.shufflepots.copy()

    for player in range(1, world.players + 1):
        if world.mode[player] != 'inverted':
            create_regions(ret, player)
        else:
            create_inverted_regions(ret, player)
        create_shops(ret, player)
        create_dungeons(ret, player)

    copy_dynamic_regions_and_locations(world, ret)

    # copy bosses
    for dungeon in world.dungeons:
        for level, boss in dungeon.bosses.items():
            ret.get_dungeon(dungeon.name, dungeon.player).bosses[level] = boss

    for shop in world.shops:
        copied_shop = ret.get_region(shop.region.name, shop.region.player).shop
        copied_shop.inventory = copy.copy(shop.inventory)

    # connect copied world
    for region in world.regions:
        copied_region = ret.get_region(region.name, region.player)
        copied_region.is_light_world = region.is_light_world
        copied_region.is_dark_world = region.is_dark_world
        for exit in copied_region.exits:
            old_connection = world.get_entrance(exit.name,
                                                exit.player).connected_region
            exit.connect(
                ret.get_region(old_connection.name, old_connection.player))

    # fill locations
    for location in world.get_locations():
        if location.item is not None:
            item = Item(location.item.name,
                        location.item.advancement,
                        location.item.priority,
                        location.item.type,
                        player=location.item.player)
            ret.get_location(location.name, location.player).item = item
            item.location = ret.get_location(location.name, location.player)
            item.world = ret
        if location.event:
            ret.get_location(location.name, location.player).event = True
        if location.locked:
            ret.get_location(location.name, location.player).locked = True

    # copy remaining itempool. No item in itempool should have an assigned location
    for item in world.itempool:
        ret.itempool.append(
            Item(item.name,
                 item.advancement,
                 item.priority,
                 item.type,
                 player=item.player))

    for item in world.precollected_items:
        ret.push_precollected(ItemFactory(item.name, item.player))

    # copy progress items in state
    ret.state.prog_items = world.state.prog_items.copy()
    ret.state.stale = {player: True for player in range(1, world.players + 1)}

    for player in range(1, world.players + 1):
        set_rules(ret, player)

    return ret
コード例 #17
0
ファイル: __init__.py プロジェクト: KonoTyran/Archipelago
 def create_item(self, name: str) -> Item:
     return Item(name, ItemClassification.progression,
                 self.item_name_to_id[name], self.player)
コード例 #18
0
ファイル: Items.py プロジェクト: KonoTyran/Archipelago
 def generate_item(self, name: str, player: int) -> Item:
     item = self._get_item_table_lookup().get(name)
     return Item(name, item.classification,
                 item.code, player)
コード例 #19
0
def create_item_with_correct_settings(world: MultiWorld, player: int, name: str) -> Item:
    data = item_table[name]

    item = Item(name, data.classification, data.code, player)

    return item
コード例 #20
0
ファイル: __init__.py プロジェクト: KonoTyran/Archipelago
 def create_item(self, name: str) -> Item:
     return Item(name,
                 ItemClassification.progression if not name.startswith("EX") else ItemClassification.filler,
                 item_table[name], self.player)
コード例 #21
0
 def create_item(self, name: str) -> Item:
     if name == "Nothing":
         return Item(name, ItemClassification.filler, -1, self.player)
     raise KeyError(name)