def create_no_logic_connections(player, world, connections):
    for entrance, parent_region, target_region, *rule_override in connections:
        parent = world.get_region(parent_region, player)
        target = world.get_region(target_region, player)
        connection = Entrance(player, entrance, parent)
        parent.exits.append(connection)
        connection.connect(target)
Beispiel #2
0
    def create_regions(self):
        player = self.player
        menu = Region("Menu", RegionType.Generic, "Menu", player, self.world)
        crash = Entrance(player, "Crash Land", menu)
        menu.exits.append(crash)
        nauvis = Region("Nauvis", RegionType.Generic, "Nauvis", player,
                        self.world)

        skip_silo = self.world.silo[self.player].value == Silo.option_spawn
        for tech_name, tech_id in base_tech_table.items():
            if skip_silo and tech_name == "rocket-silo":
                continue
            tech = Location(player, tech_name, tech_id, nauvis)
            nauvis.locations.append(tech)
            tech.game = "Factorio"
        location = Location(player, "Rocket Launch", None, nauvis)
        nauvis.locations.append(location)
        location.game = "Factorio"
        event = FactorioItem("Victory", ItemClassification.progression, None,
                             player)
        event.game = "Factorio"
        self.world.push_item(location, event, False)
        location.event = location.locked = True
        for ingredient in self.world.max_science_pack[
                self.player].get_allowed_packs():
            location = Location(player, f"Automate {ingredient}", None, nauvis)
            location.game = "Factorio"
            nauvis.locations.append(location)
            event = FactorioItem(f"Automated {ingredient}",
                                 ItemClassification.progression, None, player)
            self.world.push_item(location, event, False)
            location.event = location.locked = True
        crash.connect(nauvis)
        self.world.regions += [menu, nauvis]
Beispiel #3
0
def connect_regions(world: MultiWorld, player: int, source: str, target: str, rule):
    sourceRegion = world.get_region(source, player)
    targetRegion = world.get_region(target, player)

    connection = Entrance(player,'', sourceRegion)
    connection.access_rule = rule

    sourceRegion.exits.append(connection)
    connection.connect(targetRegion)
def create_owg_connections(player, world, connections, default_rule):
    for entrance, parent_region, target_region, *rule_override in connections:
        parent = world.get_region(parent_region, player)
        target = world.get_region(target_region, player)
        connection = Entrance(player, entrance, parent)
        parent.exits.append(connection)
        connection.connect(target)
        rule = rule_override[0] if len(rule_override) > 0 else default_rule
        connection.access_rule = rule
Beispiel #5
0
def factorio_create_regions(world: MultiWorld, player: int):
    menu = Region("Menu", None, "Menu", player)
    crash = Entrance(player, "Crash Land", menu)
    menu.exits.append(crash)
    nauvis = Region("Nauvis", None, "Nauvis", player)
    nauvis.world = menu.world = world
    for tech_name, tech_id in tech_table.items():
        tech = Location(player, tech_name, tech_id, nauvis)
        nauvis.locations.append(tech)
        tech.game = "Factorio"
    crash.connect(nauvis)
    world.regions += [menu, nauvis]
Beispiel #6
0
    def create_regions(self):
        self.create_locations(self.player)
        startRegion = self.create_region(self.world, self.player, 'Menu')
        self.world.regions.append(startRegion)

        for region in self.smz3World.Regions:
            currentRegion = self.create_region(self.world, self.player, region.Name, region.locationLookup.keys(), [region.Name + "->" + 'Menu'])
            self.world.regions.append(currentRegion)
            entrance = self.world.get_entrance(region.Name + "->" + 'Menu', self.player)
            entrance.connect(startRegion)
            exit = Entrance(self.player, 'Menu' + "->" + region.Name, startRegion)
            startRegion.exits.append(exit)
            exit.connect(currentRegion)
Beispiel #7
0
    def create_regions(self):
        world = self.world
        menu = self.create_region("Menu")
        world.regions.append(menu)
        start = Entrance(self.player, "Start Game", menu)
        menu.exits.append(start)

        # workaround for now, remove duplicate locations
        already_placed_locations = set()

        for region_name, locations in locations_by_region.items():
            locations -= already_placed_locations
            already_placed_locations |= locations
            region = self.create_region(region_name)
            if region_name == "SunkenGladesRunaway":  # starting point
                start.connect(region)
            region.locations = {Location(self.player, location, lookup_name_to_id[location], region)
                                for location in locations}
            world.regions.append(region)

        for region_name, exits in connectors.items():
            parent = world.get_region(region_name, self.player)
            for exit in exits:
                connection = Entrance(self.player, exit, parent)
                connection.connect(world.get_region(exit, self.player))
                parent.exits.append(connection)
Beispiel #8
0
def create_region(world: MultiWorld,
                  player: int,
                  name: str,
                  locat: WitnessPlayerLocations,
                  region_locations=None,
                  exits=None):
    """
    Create an Archipelago Region for The Witness
    """

    ret = Region(name, RegionType.Generic, name, player)
    ret.world = world
    if region_locations:
        for location in region_locations:
            loc_id = locat.CHECK_LOCATION_TABLE[location]

            check_hex = -1
            if location in StaticWitnessLogic.CHECKS_BY_NAME:
                check_hex = int(
                    StaticWitnessLogic.CHECKS_BY_NAME[location]["checkHex"], 0)
            location = WitnessLocation(player, location, loc_id, ret,
                                       check_hex)

            ret.locations.append(location)
    if exits:
        for single_exit in exits:
            ret.exits.append(Entrance(player, single_exit, ret))

    return ret
Beispiel #9
0
 def ChecksFinderRegion(region_name: str, exits=[]):
     ret = Region(region_name, RegionType.Generic, region_name, self.player, self.world)
     ret.locations = [ChecksFinderAdvancement(self.player, loc_name, loc_data.id, ret)
         for loc_name, loc_data in advancement_table.items()
         if loc_data.region == region_name]
     for exit in exits:
         ret.exits.append(Entrance(self.player, exit, ret))
     return ret
Beispiel #10
0
    def connect(self, world: MultiWorld, player: int, source: str, target: str, player_logic: WitnessPlayerLogic,
                panel_hex_to_solve_set=None):
        """
        connect two regions and set the corresponding requirement
        """
        source_region = world.get_region(source, player)
        target_region = world.get_region(target, player)

        connection = Entrance(
            player,
            source + " to " + target + " via " + str(panel_hex_to_solve_set),
            source_region
        )

        connection.access_rule = self.make_lambda(panel_hex_to_solve_set, world, player, player_logic)

        source_region.exits.append(connection)
        connection.connect(target_region)
Beispiel #11
0
 def MCRegion(region_name: str, exits=[]):
     ret = Region(region_name, None, region_name, self.player,
                  self.world)
     ret.locations = [
         MinecraftAdvancement(self.player, loc_name, loc_data.id, ret)
         for loc_name, loc_data in advancement_table.items()
         if loc_data.region == region_name
     ]
     for exit in exits:
         ret.exits.append(Entrance(self.player, exit, ret))
     return ret
Beispiel #12
0
 def create_region(self, world: MultiWorld, player: int, name: str, locations=None, exits=None):
     ret = Region(name, RegionType.LightWorld, name, player)
     ret.world = world
     if locations:
         for loc in locations:
             location = self.locations[loc]
             location.parent_region = ret
             ret.locations.append(location)
     if exits:
         for exit in exits:
             ret.exits.append(Entrance(player, exit, ret))
     return ret
Beispiel #13
0
    def generate_region(
            self,
            parent: Region,
            size: int,
            access_rule: CollectionRule = lambda state: True) -> Region:
        region_tag = "_region" + str(len(self.regions))
        region_name = "player" + str(self.id) + region_tag
        region = Region("player" + str(self.id) + region_tag,
                        RegionType.Generic, "Region Hint", self.id, self.world)
        self.locations += generate_locations(size, self.id, None, region,
                                             region_tag)

        entrance = Entrance(self.id, region_name + "_entrance", parent)
        parent.exits.append(entrance)
        entrance.connect(region)
        entrance.access_rule = access_rule

        self.regions.append(region)
        self.world.regions.append(region)

        return region
Beispiel #14
0
def create_region(world: MultiWorld, player: int, name: str, location_names=None, exits=None) -> Region:
    ret = Region(name, RegionType.Generic, name, player)
    ret.world = world
    if location_names:
        for location in location_names:
            loc_id = HKWorld.location_name_to_id.get(location, None)
            location = HKLocation(player, location, loc_id, ret)
            ret.locations.append(location)
    if exits:
        for exit in exits:
            ret.exits.append(Entrance(player, exit, ret))
    return ret
Beispiel #15
0
    def create_regions(self):
        # TODO: generate *some* regions from locations' requirements?
        r = Region('Menu', RegionType.Generic, 'Menu', self.player, self.world)
        r.exits = [Entrance(self.player, 'New Game', r)]
        self.world.regions += [r]

        r = Region('Ingame', RegionType.Generic, 'Ingame', self.player, self.world)
        r.locations = [SoELocation(self.player, loc.name, self.location_name_to_id[loc.name], r)
                       for loc in _locations]
        r.locations.append(SoELocation(self.player, 'Done', None, r))
        self.world.regions += [r]

        self.world.get_entrance('New Game', self.player).connect(self.world.get_region('Ingame', self.player))
Beispiel #16
0
def _create_region(name, type, locations=None, exits=None):
    ret = Region(name, type)
    if locations is None:
        locations = []
    if exits is None:
        exits = []

    for exit in exits:
        ret.exits.append(Entrance(exit, ret))
    for location in locations:
        address, address2, default, type = location_table[location]
        ret.locations.append(Location(location, address, address2, default, type, ret))
    return ret
Beispiel #17
0
def create_region(world: MultiWorld, player: int, name: str, locations=None, exits=None):
    ret = Region(name, None, name, player)
    ret.world = world
    if locations:
        for location in locations:
            loc_id = lookup_name_to_id.get(location, 0)
            location = HKLocation(player, location, loc_id, ret)
            ret.locations.append(location)
    if exits:
        for exit in exits:
            ret.exits.append(Entrance(player, exit, ret))

    return ret
Beispiel #18
0
def connect(world: MultiWorld,
            player: int,
            used_names: Dict[str, int],
            source: str,
            target: str,
            rule: Optional[Callable] = None):
    sourceRegion = world.get_region(source, player)
    targetRegion = world.get_region(target, player)

    if target not in used_names:
        used_names[target] = 1
        name = target
    else:
        used_names[target] += 1
        name = target + (' ' * used_names[target])

    connection = Entrance(player, name, sourceRegion)

    if rule:
        connection.access_rule = rule

    sourceRegion.exits.append(connection)
    connection.connect(targetRegion)
Beispiel #19
0
def create_region(name, locations=None, exits=None):
    ret = Region(name)
    if locations is None:
        locations = []
    if exits is None:
        exits = []

    for exit in exits:
        ret.exits.append(Entrance(exit, ret))
    for location in locations:
        address, crystal, hint_text = location_table[location]
        ret.locations.append(
            Location(location, address, crystal, hint_text, ret))
    return ret
Beispiel #20
0
def create_region(world: MultiWorld,
                  player: int,
                  name: str,
                  locations=None,
                  exits=None):
    ret = Region(name, RegionType.Generic, name, player)
    ret.world = world
    if locations:
        for location in locations:
            loc_id = location_table.get(location, 0)
            location = SpireLocation(player, location, loc_id, ret)
            ret.locations.append(location)
    if exits:
        for exit in exits:
            ret.exits.append(Entrance(player, exit, ret))

    return ret
Beispiel #21
0
def create_region(world: MultiWorld,
                  player: int,
                  name: str,
                  locations=None,
                  exits=None):
    # Shamelessly stolen from the ROR2 definition, lol
    ret = Region(name, RegionType.Generic, name, player)
    ret.world = world
    if locations:
        for location in locations:
            loc_id = location_table.get(location, 0)
            location = LegacyLocation(player, location, loc_id, ret)
            ret.locations.append(location)
    if exits:
        for exit in exits:
            ret.exits.append(Entrance(player, exit, ret))

    return ret
Beispiel #22
0
def create_region(world: MultiWorld,
                  player: int,
                  name: str,
                  locations=None,
                  exits=None):
    ret = Region(name, RegionType.Generic, name, player)
    ret.world = world
    if locations:
        for location in locations:
            loc_id = locations_lookup_name_to_id.get(location, 0)
            locationObj = RaftLocation(player, location, loc_id, ret)
            ret.locations.append(locationObj)
    if exits:
        for exit in exits:
            ret.exits.append(
                Entrance(player, getConnectionName(name, exit), ret))

    return ret
Beispiel #23
0
def create_region(world: MultiWorld,
                  player: int,
                  name: str,
                  locations=None,
                  exits=None):
    region = Region(name, RegionType.Generic, name, player)
    region.world = world
    if locations:
        for location_name in locations.keys():
            location = ArchipIDLELocation(player, location_name,
                                          locations[location_name], region)
            region.locations.append(location)

    if exits:
        for _exit in exits:
            region.exits.append(Entrance(player, _exit, region))

    return region
Beispiel #24
0
def create_region(world: MultiWorld,
                  player: int,
                  active_locations,
                  name: str,
                  locations=None,
                  exits=None):
    # Shamelessly stolen from the ROR2 definition
    ret = Region(name, None, name, player)
    ret.world = world
    if locations:
        for location in locations:
            loc_id = active_locations.get(location, 0)
            if loc_id:
                location = SA2BLocation(player, location, loc_id, ret)
                ret.locations.append(location)
    if exits:
        for exit in exits:
            ret.exits.append(Entrance(player, exit, ret))

    return ret
Beispiel #25
0
def create_regions(self, world, player: int):
    from . import create_region
    from BaseClasses import Entrance
    from logic.logic import Logic
    from graph.vanilla.graph_locations import locationsDict

    regions = []
    for accessPoint in Logic.accessPoints:
        regions.append(
            create_region(self, world, player, accessPoint.Name, None, [
                accessPoint.Name + "->" + key
                for key in accessPoint.intraTransitions.keys()
            ]))

    world.regions += regions

    # create a region for each location and link each to what the location has access
    # we make them one way so that the filler (and spoiler log) doesnt try to use those region as intermediary path
    # this is required in AP because a location cant have multiple parent regions
    locationRegions = []
    for locationName, value in locationsDict.items():
        locationRegions.append(
            create_region(self, world, player, locationName, [locationName]))
        for key in value.AccessFrom.keys():
            currentRegion = world.get_region(key, player)
            currentRegion.exits.append(
                Entrance(player, key + "->" + locationName, currentRegion))

    world.regions += locationRegions
    #create entrances
    regionConcat = regions + locationRegions
    for region in regionConcat:
        for exit in region.exits:
            exit.connect(
                world.get_region(exit.name[exit.name.find("->") + 2:], player))

    world.regions += [
        create_region(self, world, player, 'Menu', None, ['StartAP'])
    ]
Beispiel #26
0
def underworld_glitch_connections(world, player):
    specrock = world.get_region('Spectacle Rock Cave (Bottom)', player)
    mire = world.get_region('Misery Mire (West)', player)

    kikiskip = Entrance(player, 'Kiki Skip', specrock)
    mire_to_hera = Entrance(player, 'Mire to Hera Clip', mire)
    mire_to_swamp = Entrance(player, 'Hera to Swamp Clip', mire)
    specrock.exits.append(kikiskip)
    mire.exits.extend([mire_to_hera, mire_to_swamp])

    if world.fix_fake_world[player]:
        kikiskip.connect(
            world.get_entrance('Palace of Darkness Exit',
                               player).connected_region)
        mire_to_hera.connect(
            world.get_entrance('Tower of Hera Exit', player).connected_region)
        mire_to_swamp.connect(
            world.get_entrance('Swamp Palace Exit', player).connected_region)
    else:
        kikiskip.connect(
            world.get_region('Palace of Darkness (Entrance)', player))
        mire_to_hera.connect(world.get_region('Tower of Hera (Bottom)',
                                              player))
        mire_to_swamp.connect(
            world.get_region('Swamp Palace (Entrance)', player))
Beispiel #27
0
def connectStartingRegion(world: MultiWorld, player: int):
    menu = world.get_region('Menu', player)
    tutorial = world.get_region('Tutorial', player)
    space_time_continuum = world.get_region('Space time continuum', player)

    if is_option_enabled(world, player, "Inverted"):
        starting_region = world.get_region('Refugee Camp', player)
    else:
        starting_region = world.get_region('Lake desolation', player)

    menu_to_tutorial = Entrance(player, 'Tutorial', menu)
    menu_to_tutorial.connect(tutorial)
    menu.exits.append(menu_to_tutorial)

    tutorial_to_start = Entrance(player, 'Start Game', tutorial)
    tutorial_to_start.connect(starting_region)
    tutorial.exits.append(tutorial_to_start)

    teleport_back_to_start = Entrance(player, 'Teleport back to start',
                                      space_time_continuum)
    teleport_back_to_start.connect(starting_region)
    space_time_continuum.exits.append(teleport_back_to_start)
Beispiel #28
0
def _generate_entrances(player: int, entrance_list: [str], parent: Region):
    return [Entrance(player, entrance, parent) for entrance in entrance_list]