Skip to content
6 changes: 3 additions & 3 deletions worlds/crosscode/codegen/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def generate_mod_files(self):
},
"unlocks": {
"byId": {
item_id: data.combo_id
item_id: data.item.combo_id
for item_id, data in self.lists.shop_unlock_by_id.items()
},
"byShop": {},
Expand Down Expand Up @@ -323,10 +323,10 @@ def get_codes(name: str) -> list[int]:
)

for shop_name, data in self.lists.shop_unlock_by_shop.items():
data_out["shops"]["unlocks"]["byShop"][shop_name] = data.combo_id
data_out["shops"]["unlocks"]["byShop"][shop_name] = data.item.combo_id

for (shop_name, item_id), data in self.lists.shop_unlock_by_shop_and_id.items():
data_out["shops"]["unlocks"]["byShopAndId"][shop_name][item_id] = data.combo_id
data_out["shops"]["unlocks"]["byShopAndId"][shop_name][item_id] = data.item.combo_id

try:
os.mkdir(self.data_out_dir)
Expand Down
14 changes: 7 additions & 7 deletions worlds/crosscode/codegen/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class ListInfo:
shop_data: dict[str, ShopData]
per_shop_locations: dict[str, dict[int, LocationData]]
global_shop_locations: dict[int, LocationData]
shop_unlock_by_id: dict[int, ItemData]
shop_unlock_by_shop: dict[str, ItemData]
shop_unlock_by_shop_and_id: dict[tuple[str, int], ItemData]
shop_unlock_by_id: dict[int, ItemPoolEntry]
shop_unlock_by_shop: dict[str, ItemPoolEntry]
shop_unlock_by_shop_and_id: dict[tuple[str, int], ItemPoolEntry]
global_slot_region_conditions_list: dict[str, list[Condition]]

progressive_chains: dict[str, ProgressiveItemChain]
Expand Down Expand Up @@ -332,14 +332,14 @@ def __add_shop(self, shop_display_name: str, raw_shop: dict[str, typing.Any]):
real_name = dbentry["name"]["en_US"]

metadata = raw_shop.get("metadata", {})
metadata["shops"] = True
metadata["shop"] = True
access_info = self.json_parser.parse_location_access_info(raw_shop)

shop_locs = self.per_shop_locations[shop_display_name]

by_shop_name = f"Shop Unlock: {shop_base_name}"
by_shop_item = self.__add_shop_unlock_item(by_shop_name)
self.shop_unlock_by_shop[shop_name] = by_shop_item
self.shop_unlock_by_shop[shop_name] = ItemPoolEntry(by_shop_item, 1, metadata)
self.descriptions[by_shop_item.combo_id] = {
"en_US": f"Unlocks \\c[3]all item slots\\c[0] in the shop \\c[3]{real_name}\\c[0]."
}
Expand Down Expand Up @@ -374,7 +374,7 @@ def __add_shop(self, shop_display_name: str, raw_shop: dict[str, typing.Any]):

by_shop_and_id_name = f"Slot Unlock: {item_name} ({shop_display_name})"
by_shop_and_id_item = self.__add_shop_unlock_item(by_shop_and_id_name)
self.shop_unlock_by_shop_and_id[shop_name, item_id] = by_shop_and_id_item
self.shop_unlock_by_shop_and_id[shop_name, item_id] = ItemPoolEntry(by_shop_and_id_item, 1, metadata)

self.descriptions[by_shop_and_id_item.combo_id] = {
"en_US": f"Unlocks the slot selling \\c[3]{item_name}\\c[0] in \\c[3]{real_name}\\c[0]."
Expand Down Expand Up @@ -406,7 +406,7 @@ def __add_shop(self, shop_display_name: str, raw_shop: dict[str, typing.Any]):

by_id_name = f"Global Slot Unlock: {item_name}"
by_id_item = self.__add_shop_unlock_item(by_id_name)
self.shop_unlock_by_id[item_id] = by_id_item
self.shop_unlock_by_id[item_id] = ItemPoolEntry(by_id_item, 1, metadata)
self.global_shop_locations[item_id] = global_location

self.locations_data[global_location.name] = global_location
Expand Down
10 changes: 7 additions & 3 deletions worlds/crosscode/codegen/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import typing
import json
import os

from .context import Context

Expand All @@ -26,14 +27,15 @@ def __init__(self, ctx: Context) -> None:
self.map_cache = {}
self.area_cache = {}

def __load_map(self, name: str) -> dict[str, typing.Any]:
def __load_map(self, name: str, dlc: bool) -> dict[str, typing.Any]:
try:
return self.map_cache[name]
except KeyError:
pass

path = name.replace(".", "/")
with open(f"worlds/crosscode/data/assets/data/maps/{path}.json") as f:
in_dlc = dlc and os.path.exists(f"worlds/crosscode/data/assets/extension/post-game/data/maps/{path}.json")
with open(f"worlds/crosscode/data/assets{"/extension/post-game" if in_dlc else ""}/data/maps/{path}.json") as f:
self.map_cache[name] = json.load(f)

return self.map_cache[name]
Expand All @@ -60,8 +62,10 @@ def generate_marker(self, raw_loc: dict[str, typing.Any], mwid: int) -> typing.O
map_id = loc_data.get("mapId", None)
if map_id is None:
return None

meta = raw_loc.get("metadata", {})

map = self.__load_map(map_name)
map = self.__load_map(map_name, meta.get("dlc", False))

raw_entity = None
for entity in map["entities"]:
Expand Down
3 changes: 2 additions & 1 deletion worlds/crosscode/codegen/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import re
import copy
import typing

T = typing.TypeVar("T", dict[str, typing.Any], list[typing.Any])
Expand Down Expand Up @@ -38,7 +39,7 @@ def merge(original: T, addon: T, patch: bool = True) -> T:

# normal key. we just want to get that key and merge it.
elif key not in original:
original[key] = value
original[key] = copy.copy(value)
else:
merge(original[key], addon[key], patch)

Expand Down
2 changes: 1 addition & 1 deletion worlds/crosscode/codegen/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def parse_regions_data(self, raw: dict[str, typing.Any]) -> RegionsData:

region_list = list(regions_seen)

region_list.sort(key=lambda x: float(x.strip(string.ascii_letters)))
region_list.sort()

return RegionsData(start, exclude, region_list, connections, goals)

Expand Down
15 changes: 15 additions & 0 deletions worlds/crosscode/item_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@
from .types.condition import *

item_pools_template: dict[str, list[ItemPoolEntry]] = {
"required_dlc": [
ItemPoolEntry(item=items_dict['Azure Archipelago Pass', 1], quantity=1),
ItemPoolEntry(item=items_dict['Ancient Shade', 1], quantity=1),
ItemPoolEntry(item=items_dict['SP Upgrade', 1], quantity=1),
ItemPoolEntry(item=items_dict["MacGuffin's Coin", 1], quantity=3),
ItemPoolEntry(item=items_dict["Ku'lero Key", 1], quantity=3),
ItemPoolEntry(item=items_dict["Ku'lero Master Key", 1], quantity=1),
ItemPoolEntry(item=items_dict["Champion's Towel", 1], quantity=1),
ItemPoolEntry(item=items_dict['Light Gem', 1], quantity=1),
ItemPoolEntry(item=items_dict['The Last Straw', 1], quantity=1),
ItemPoolEntry(item=items_dict['Asteroid Chunk', 1], quantity=1),
ItemPoolEntry(item=items_dict['Moon Chunk', 1], quantity=1),
ItemPoolEntry(item=items_dict['Meteor Chunk', 1], quantity=1),
ItemPoolEntry(item=items_dict['Rift Spore', 1], quantity=1),
],
"required": [
ItemPoolEntry(item=items_dict['Heat', 1], quantity=1),
ItemPoolEntry(item=items_dict['Cold', 1], quantity=1),
Expand Down
Loading