-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathLocations.py
66 lines (49 loc) · 2.01 KB
/
Locations.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from BaseClasses import Location
from .Data import location_table
from .Game import starting_index
######################
# Generate location lookups
######################
count = starting_index
victory_names: list[str] = []
# add sequential generated ids to the lists
for key, _ in enumerate(location_table):
if "victory" in location_table[key] and location_table[key]["victory"]:
victory_names.append(location_table[key]["name"])
if "id" in location_table[key]:
item_id = location_table[key]["id"]
if item_id >= count:
count = item_id
else:
raise ValueError(f"{location_table[key]['name']} has an invalid ID. ID must be at least {count + 1}")
location_table[key]["id"] = count
if not "region" in location_table[key]:
location_table[key]["region"] = "Manual" # all locations are in the same region for Manual
count += 1
if not victory_names:
# Add the game completion location, which will have the Victory item assigned to it automatically
location_table.append({
"id": count + 1,
"name": "__Manual Game Complete__",
"region": "Manual",
"requires": []
# "category": custom_victory_location["category"] if "category" in custom_victory_location else []
})
victory_names.append("__Manual Game Complete__")
location_id_to_name: dict[int, str] = {}
location_name_to_location: dict[str, dict] = {}
location_name_groups: dict[str, list[str]] = {}
for item in location_table:
location_id_to_name[item["id"]] = item["name"]
location_name_to_location[item["name"]] = item
for c in item.get("category", []):
if c not in location_name_groups:
location_name_groups[c] = []
location_name_groups[c].append(item["name"])
# location_id_to_name[None] = "__Manual Game Complete__"
location_name_to_id = {name: id for id, name in location_id_to_name.items()}
######################
# Location classes
######################
class ManualLocation(Location):
game = "Manual"