diff options
Diffstat (limited to 'apworld/regions.py')
| -rw-r--r-- | apworld/regions.py | 28 |
1 files changed, 28 insertions, 0 deletions
| diff --git a/apworld/regions.py b/apworld/regions.py new file mode 100644 index 0000000..24c2281 --- /dev/null +++ b/apworld/regions.py | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | from typing import TYPE_CHECKING | ||
| 2 | |||
| 3 | from BaseClasses import Region | ||
| 4 | from .locations import Lingo2Location | ||
| 5 | |||
| 6 | if TYPE_CHECKING: | ||
| 7 | from . import Lingo2World | ||
| 8 | |||
| 9 | |||
| 10 | def create_region(room, world: "Lingo2World") -> Region: | ||
| 11 | new_region = Region(room.name, world.player, world.multiworld) | ||
| 12 | |||
| 13 | for location in world.player_logic.locations_by_room.get(room.id, {}): | ||
| 14 | new_location = Lingo2Location(world.player, location.name, location.code, new_region) | ||
| 15 | new_region.locations.append(new_location) | ||
| 16 | |||
| 17 | return new_region | ||
| 18 | |||
| 19 | |||
| 20 | def create_regions(world: "Lingo2World"): | ||
| 21 | regions = { | ||
| 22 | "Menu": Region("Menu", world.player, world.multiworld) | ||
| 23 | } | ||
| 24 | |||
| 25 | for room in world.static_logic.objects.rooms: | ||
| 26 | regions[room.name] = create_region(room, world) | ||
| 27 | |||
| 28 | world.multiworld.regions += regions.values() | ||
