World¶
- class worlds.AutoWorld.World(multiworld: MultiWorld, player: int)¶
Bases:
object
A World object encompasses a game’s Items, Locations, Rules and additional data or functionality required. A Game should have its own subclass of World in which it defines the required data structures.
- all_item_and_group_names: ClassVar[FrozenSet[str]] = frozenset({'Everything'})¶
gets automatically populated with all item and item group names
- collect(state: CollectionState, item: Item) bool ¶
Called when an item is collected in to state. Useful for things such as progressive items or currency.
- collect_item(state: CollectionState, item: Item, remove: bool = False) str | None ¶
Collect an item name into state. For speed reasons items that aren’t logically useful get skipped. Collect None to skip item. :param state: CollectionState to collect into :param item: Item to decide on if it should be collected into state :param remove: indicate if this is meant to remove from state instead of adding.
- connect_entrances() None ¶
Method to finalize the source and target regions of the World’s entrances
- classmethod create_group(multiworld: MultiWorld, new_player_id: int, players: Set[int]) World ¶
Creates a group, which is an instance of World that is responsible for multiple others. An example case is ItemLinks creating these.
- create_item(name: str) Item ¶
Create an item for this world type and player. Warning: this may be called with self.world = None, for example by MultiServer
- create_items() None ¶
Method for creating and submitting items to the itempool. Items and Regions must not be created and submitted to the MultiWorld after this step. If items need to be placed during pre_fill use get_prefill_items.
- create_regions() None ¶
Method for creating and connecting regions for the World.
- explicit_indirect_conditions: bool = True¶
If True, the world implementation is supposed to use MultiWorld.register_indirect_condition() correctly. If False, everything is rechecked at every step, which is slower computationally, but may be desirable in complex/dynamic worlds.
- extend_hint_information(hint_data: Dict[int, Dict[int, str]])¶
Fill in additional entrance information text into locations, which is displayed when hinted. structure is {player_id: {location_id: text}} You will need to insert your own player_id.
- fill_hook(progitempool: List['Item'], usefulitempool: List['Item'], filleritempool: List['Item'], fill_locations: List['Location']) None ¶
Special method that gets called as part of distribute_items_restrictive (main fill).
- fill_slot_data() Mapping[str, Any] ¶
What is returned from this function will be in the slot_data field in the Connected network package. It should be a dict with str keys, and should be serializable with json.
This is a way the generator can give custom data to the client. The client will receive this as JSON in the Connected response.
The generation does not wait for generate_output to complete before calling this. threading.Event can be used if you need to wait for something from generate_output.
- game: ClassVar[str]¶
name the game
- generate_basic() None ¶
Useful for randomizing things that don’t affect logic but are better to be determined before the output stage. i.e. checking what the player has marked as priority or randomizing enemies
- generate_early() None ¶
Run before any general steps of the MultiWorld other than options. Useful for getting and adjusting option results and determining layouts for entrance rando etc. start inventory gets pushed after this step.
- generate_output(output_directory: str) None ¶
This method gets called from a threadpool, do not use multiworld.random here. If you need any last-second randomization, use self.random instead.
- classmethod get_data_package_data() GamesPackage ¶
- get_filler_item_name() str ¶
Called when the item pool needs to be filled with additional items to match location count.
- get_pre_fill_items() List['Item'] ¶
Used to return items that need to be collected when creating a fresh all_state, but don’t exist in the multiworld itempool.
Hide World Type from various views. Does not remove functionality.
- hint_blacklist: ClassVar[FrozenSet[str]] = frozenset({})¶
any names that should not be hintable
- item_id_to_name: ClassVar[Dict[int, str]] = {}¶
automatically generated reverse lookup of item id to name
- item_name_groups: ClassVar[Dict[str, Set[str]]] = {'Everything': frozenset({})}¶
maps item group names to sets of items. Example: {“Weapons”: {“Sword”, “Bow”}}
- item_name_to_id: ClassVar[Dict[str, int]] = {}¶
map item names to their IDs
- item_names: ClassVar[Set[str]] = frozenset({})¶
set of all potential item names
- location_id_to_name: ClassVar[Dict[int, str]] = {}¶
automatically generated reverse lookup of location id to name
- location_name_groups: ClassVar[Dict[str, Set[str]]] = {'Everywhere': frozenset({})}¶
maps location group names to sets of locations. Example: {“Sewer”: {“Sewer Key Drop 1”, “Sewer Key Drop 2”}}
- location_name_to_id: ClassVar[Dict[str, int]] = {}¶
map location names to their IDs
- location_names: ClassVar[Set[str]] = frozenset({})¶
set of all potential location names
- modify_multidata(multidata: Dict[str, Any]) None ¶
For deeper modification of server multidata.
- multiworld: MultiWorld¶
autoset on creation. The MultiWorld object for the currently generating multiworld.
- options: PerGameCommonOptions¶
resulting options for the player of this world
- options_dataclass¶
link your Options mapping
alias of
PerGameCommonOptions
- origin_region_name: str = 'Menu'¶
Name of the Region from which accessibility is tested.
- player: int¶
autoset on creation. The player number for this World
- property player_name: str¶
- post_fill() None ¶
Optional Method that is called after regular fill. Can be used to do adjustments before output generation. This happens before progression balancing, so the items may not be in their final locations yet.
- pre_fill() None ¶
Optional method that is supposed to be used for special fill stages. This is run after plando.
- random: Random¶
This world’s random object. Should be used for any randomization needed in world for this player slot.
- remove(state: CollectionState, item: Item) bool ¶
Called when an item is removed from to state. Useful for things such as progressive items or currency.
- required_client_version: Tuple[int, int, int] = (0, 1, 6)¶
override this if changes to a world break forward-compatibility of the client The base version of (0, 1, 6) is provided for backwards compatibility and does not need to be updated in the future. Protocol level compatibility check moved to MultiServer.min_client_version.
- required_server_version: Tuple[int, int, int] = (0, 5, 0)¶
update this if the resulting multidata breaks forward-compatibility of the server
- set_rules() None ¶
Method for setting the rules on the World’s regions and locations.
- settings: ClassVar['Group' | None]¶
loaded settings from host.yaml
- settings_key: ClassVar[str] = 'autoworld_options'¶
name of the section in host.yaml for world-specific settings, will default to {folder}_options
- classmethod stage_assert_generate(multiworld: MultiWorld) None ¶
Checks that a game is capable of generating, such as checking for some base file like a ROM. This gets called once per present world type. Not run for unittests since they don’t produce output.
- topology_present: bool = False¶
indicate if this world has any meaningful layout/pathing
- write_spoiler(spoiler_handle: TextIO) None ¶
Write to the spoiler “middle”, this is after the per-player options and before locations, meant for useful or interesting info.
- write_spoiler_end(spoiler_handle: TextIO) None ¶
Write to the end of the spoiler
- write_spoiler_header(spoiler_handle: TextIO) None ¶
Write to the spoiler header. If individual it’s right at the end of that player’s options, if as stage it’s right under the common header before per-player options.
- zip_path: ClassVar[pathlib.Path | None] = None¶
If loaded from a .apworld, this is the Path to it.