summary refs log tree commit diff stats
path: root/apworld/regions.py
blob: d388678e0375f017850b03d20e12394e108bb5ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from typing import TYPE_CHECKING

from BaseClasses import Region
from .locations import Lingo2Location

if TYPE_CHECKING:
    from . import Lingo2World


def create_region(room, world: "Lingo2World") -> Region:
    new_region = Region(room.name, world.player, world.multiworld)

    for location in world.player_logic.locations_by_room.get(room.id, {}):
        new_location = Lingo2Location(world.player, world.static_logic.location_id_to_name[location.code],
                                      location.code, new_region)
        new_region.locations.append(new_location)

    return new_region


def create_regions(world: "Lingo2World"):
    regions = {
        "Menu": Region("Menu", world.player, world.multiworld)
    }

    for room in world.static_logic.objects.rooms:
        regions[room.name] = create_region(room, world)

    world.multiworld.regions += regions.values()