summary refs log tree commit diff stats
path: root/apworld
diff options
context:
space:
mode:
Diffstat (limited to 'apworld')
-rw-r--r--apworld/__init__.py38
-rw-r--r--apworld/locations.py5
-rw-r--r--apworld/options.py8
-rw-r--r--apworld/player_logic.py24
-rw-r--r--apworld/regions.py28
-rw-r--r--apworld/requirements.txt1
-rw-r--r--apworld/static_logic.py9
7 files changed, 113 insertions, 0 deletions
diff --git a/apworld/__init__.py b/apworld/__init__.py new file mode 100644 index 0000000..013910e --- /dev/null +++ b/apworld/__init__.py
@@ -0,0 +1,38 @@
1"""
2Archipelago init file for Lingo 2
3"""
4from worlds.AutoWorld import WebWorld, World
5from .options import Lingo2Options
6from .player_logic import Lingo2PlayerLogic
7from .regions import create_regions
8from .static_logic import Lingo2StaticLogic
9
10
11class Lingo2WebWorld(WebWorld):
12 rich_text_options_doc = True
13 theme = "grass"
14
15
16class Lingo2World(World):
17 """
18 Lingo 2 is a first person indie puzzle game where you solve word puzzles in a labyrinthe world. Compared to its
19 predecessor, Lingo 2 has new mechanics, more areas, and a unique progression system where you have to unlock letters
20 before using them in puzzle solutions.
21 """
22 game = "Lingo 2"
23 web = Lingo2WebWorld()
24
25 options_dataclass = Lingo2Options
26 options: Lingo2Options
27
28 item_name_to_id = {}
29 location_name_to_id = {}
30
31 static_logic = Lingo2StaticLogic()
32 player_logic: Lingo2PlayerLogic
33
34 def generate_early(self):
35 self.player_logic = Lingo2PlayerLogic(self)
36
37 def create_regions(self):
38 create_regions(self)
diff --git a/apworld/locations.py b/apworld/locations.py new file mode 100644 index 0000000..818be39 --- /dev/null +++ b/apworld/locations.py
@@ -0,0 +1,5 @@
1from BaseClasses import Location
2
3
4class Lingo2Location(Location):
5 game: str = "Lingo 2" \ No newline at end of file
diff --git a/apworld/options.py b/apworld/options.py new file mode 100644 index 0000000..f33f5af --- /dev/null +++ b/apworld/options.py
@@ -0,0 +1,8 @@
1from dataclasses import dataclass
2
3from Options import PerGameCommonOptions
4
5
6@dataclass
7class Lingo2Options(PerGameCommonOptions):
8 pass
diff --git a/apworld/player_logic.py b/apworld/player_logic.py new file mode 100644 index 0000000..f54573f --- /dev/null +++ b/apworld/player_logic.py
@@ -0,0 +1,24 @@
1from typing import TYPE_CHECKING, NamedTuple
2
3if TYPE_CHECKING:
4 from . import Lingo2World
5
6
7class PlayerLocation(NamedTuple):
8 name: str
9 code: int | None
10
11
12class Lingo2PlayerLogic:
13 locations_by_room: dict[int, list[PlayerLocation]]
14
15 def __init__(self, world: "Lingo2World"):
16 self.locations_by_room = {}
17
18 code = 1
19 for door in world.static_logic.objects.doors:
20 if not door.HasField("room_id"):
21 continue
22
23 self.locations_by_room.setdefault(door.room_id, []).append(PlayerLocation(door.name, code))
24 code += 1
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 @@
1from typing import TYPE_CHECKING
2
3from BaseClasses import Region
4from .locations import Lingo2Location
5
6if TYPE_CHECKING:
7 from . import Lingo2World
8
9
10def 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
20def 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()
diff --git a/apworld/requirements.txt b/apworld/requirements.txt new file mode 100644 index 0000000..b701d11 --- /dev/null +++ b/apworld/requirements.txt
@@ -0,0 +1 @@
protobuf>=5.29.3 \ No newline at end of file
diff --git a/apworld/static_logic.py b/apworld/static_logic.py new file mode 100644 index 0000000..6c38f1f --- /dev/null +++ b/apworld/static_logic.py
@@ -0,0 +1,9 @@
1from .generated import data_pb2 as data_pb2
2import pkgutil
3
4class Lingo2StaticLogic:
5 def __init__(self):
6 file = pkgutil.get_data(__name__, "generated/data.binpb")
7
8 self.objects = data_pb2.AllObjects()
9 self.objects.ParseFromString(bytearray(file))