Archipelago/worlds/saving_princess/Regions.py

111 lines
3.7 KiB
Python
Raw Normal View History

Saving Princess: implement new game (#3238) * Saving Princess: initial commit * settings -> options Co-authored-by: Scipio Wright <scipiowright@gmail.com> * settings -> options Co-authored-by: Scipio Wright <scipiowright@gmail.com> * replace RegionData class with List[str] RegionData was only wrapping a List[str], so we can directly use List[str] * world: MultiWorld -> multiworld: MultiWorld * use world's random instead of multiworld's * use state's has_any and has_all where applicable * remove unused StartInventory import * reorder PerGameCommonOptions * fix relative AutoWorld import Co-authored-by: Scipio Wright <scipiowright@gmail.com> * clean up double spaces * local commands -> Local Commands Co-authored-by: Nicholas Saylor <79181893+nicholassaylor@users.noreply.github.com> * remove redundant which items section Co-authored-by: Nicholas Saylor <79181893+nicholassaylor@users.noreply.github.com> * game info rework * clean up item count redundancy * add game to readme and codeowners * fix get_region_entrance return type * world.multiworld.get -> world.get * add more events added events for the boss kills that open the gate, as well as for system power being restored these only apply if expanded pool is not selected * add client/autoupdater to launcher * reorder commands in game info * update docs with automated installation info * add quick links to doc * Update setup_en.md * remove standalone saving princess client * doc fixes * code improvements and redundant default removal as suggested by @Exempt-Medic this includes the removal of events from the item/location name to id, as well as checking for the player name being ASCII * add option to change launch coammnd the LaunchCommand option is filled to either the executable or wine with the necessary arguments based on Utils.is_windows * simplify valid install check * mod installer improvements now deletes possible existing files before installing the mod * add option groups and presets * add required client version * update docs about cheat items pop-ups items sent directly by the server (such as with starting inventory) now have pop-ups just like any other item * add Steam Input issue to faq * Saving Princess: BRAINOS requires all weapons * Saving Princess: Download dll and patch together Previously, gm-apclientpp.dll was downloaded from its own repo With this update, the dll is instead extracted from the same zip as the game's patch * Saving Princess: Add URI launch support * Saving Princess: goal also requires all weapons given it's past brainos * Saving Princess: update docs automatic connection support was added, docs now reflect this * Saving Princess: extend([item]) -> append(item) * Saving Princess: automatic connection validation also parses the slot, password and host:port into parameters for the game * Saving Princess: change subprocess .run to .Popen This keeps the game from freezing the launcher while it is running --------- Co-authored-by: Scipio Wright <scipiowright@gmail.com> Co-authored-by: Nicholas Saylor <79181893+nicholassaylor@users.noreply.github.com> Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
2024-12-07 10:29:27 +00:00
from typing import List, Dict
from BaseClasses import MultiWorld, Region, Entrance
from . import Locations
from .Constants import *
region_dict: Dict[str, List[str]] = {
REGION_MENU: [],
REGION_CAVE: [
LOCATION_CAVE_AMMO,
LOCATION_CAVE_RELOAD,
LOCATION_CAVE_HEALTH,
LOCATION_CAVE_WEAPON,
EP_LOCATION_CAVE_MINIBOSS,
EP_LOCATION_CAVE_BOSS,
EVENT_LOCATION_GUARD_GONE,
],
REGION_VOLCANIC: [
LOCATION_VOLCANIC_RELOAD,
LOCATION_VOLCANIC_HEALTH,
LOCATION_VOLCANIC_AMMO,
LOCATION_VOLCANIC_WEAPON,
EP_LOCATION_VOLCANIC_BOSS,
EVENT_LOCATION_CLIFF_GONE,
],
REGION_ARCTIC: [
LOCATION_ARCTIC_AMMO,
LOCATION_ARCTIC_RELOAD,
LOCATION_ARCTIC_HEALTH,
LOCATION_ARCTIC_WEAPON,
LOCATION_JACKET,
EP_LOCATION_ARCTIC_BOSS,
EVENT_LOCATION_ACE_GONE,
],
REGION_HUB: [
LOCATION_HUB_AMMO,
LOCATION_HUB_HEALTH,
LOCATION_HUB_RELOAD,
EP_LOCATION_HUB_CONSOLE,
EP_LOCATION_HUB_NINJA_SCARE,
],
REGION_SWAMP: [
LOCATION_SWAMP_AMMO,
LOCATION_SWAMP_HEALTH,
LOCATION_SWAMP_RELOAD,
LOCATION_SWAMP_SPECIAL,
EP_LOCATION_SWAMP_BOSS,
EVENT_LOCATION_SNAKE_GONE,
],
REGION_ELECTRICAL: [
EP_LOCATION_ELEVATOR_NINJA_FIGHT,
LOCATION_ELECTRICAL_WEAPON,
EP_LOCATION_ELECTRICAL_MINIBOSS,
EP_LOCATION_ELECTRICAL_EXTRA,
EVENT_LOCATION_POWER_ON,
],
REGION_ELECTRICAL_POWERED: [
LOCATION_ELECTRICAL_RELOAD,
LOCATION_ELECTRICAL_HEALTH,
LOCATION_ELECTRICAL_AMMO,
EP_LOCATION_ELECTRICAL_BOSS,
EP_LOCATION_ELECTRICAL_FINAL_BOSS,
EVENT_LOCATION_VICTORY,
],
}
def set_region_locations(region: Region, location_names: List[str], is_pool_expanded: bool):
location_pool = {**Locations.location_dict_base, **Locations.location_dict_events}
if is_pool_expanded:
location_pool = {**Locations.location_dict_expanded, **Locations.location_dict_event_expanded}
region.locations = [
Locations.SavingPrincessLocation(
region.player,
name,
Locations.location_dict[name].code,
region
) for name in location_names if name in location_pool.keys()
]
def create_regions(multiworld: MultiWorld, player: int, is_pool_expanded: bool):
for region_name, location_names in region_dict.items():
region = Region(region_name, player, multiworld)
set_region_locations(region, location_names, is_pool_expanded)
multiworld.regions.append(region)
connect_regions(multiworld, player)
def connect_regions(multiworld: MultiWorld, player: int):
# and add a connection from the menu to the hub region
menu = multiworld.get_region(REGION_MENU, player)
hub = multiworld.get_region(REGION_HUB, player)
connection = Entrance(player, f"{REGION_HUB} entrance", menu)
menu.exits.append(connection)
connection.connect(hub)
# now add an entrance from every other region to hub
for region_name in [REGION_CAVE, REGION_VOLCANIC, REGION_ARCTIC, REGION_SWAMP, REGION_ELECTRICAL]:
connection = Entrance(player, f"{region_name} entrance", hub)
hub.exits.append(connection)
connection.connect(multiworld.get_region(region_name, player))
# and finally, the connection between the final region and its powered version
electrical = multiworld.get_region(REGION_ELECTRICAL, player)
connection = Entrance(player, f"{REGION_ELECTRICAL_POWERED} entrance", electrical)
electrical.exits.append(connection)
connection.connect(multiworld.get_region(REGION_ELECTRICAL_POWERED, player))