Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions worlds/minecraft/Constants.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import json
import pkgutil


def load_data_file(*args) -> dict:
fname = "/".join(["data", *args])
return json.loads(pkgutil.get_data(__name__, fname).decode())

# For historical reasons, these values are different.
# They remain different to ensure datapackage consistency.
# Do not separate other games' location and item IDs like this.
item_id_offset: int = 45000
location_id_offset: int = 42000

item_info = load_data_file("items.json")
item_name_to_id = {name: item_id_offset + index \
for index, name in enumerate(item_info["all_items"])}
item_name_to_id["Bee Trap"] = item_id_offset + 100 # historical reasons
item_name_to_id = {name: index \
for index, name in enumerate(item_info["all_items"], start=1)}

location_info = load_data_file("locations.json")
location_name_to_id = {name: location_id_offset + index \
for index, name in enumerate(location_info["all_locations"])}
location_name_to_id = {name: index \
for index, name in enumerate(location_info["all_locations"], start=1)}

exclusion_info = load_data_file("excluded_locations.json")

Expand Down
2 changes: 0 additions & 2 deletions worlds/minecraft/data/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"all_items": [
"Archery",
"Progressive Resource Crafting",
"Resource Blocks",
"Brewing",
"Enchanting",
"Bucket",
Expand Down Expand Up @@ -56,7 +55,6 @@
"progression_items": [
"Archery",
"Progressive Resource Crafting",
"Resource Blocks",
"Brewing",
"Enchanting",
"Bucket",
Expand Down
6 changes: 3 additions & 3 deletions worlds/minecraft/test/TestDataLoad.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .. import Constants


class TestDataLoad(unittest.TestCase):

def test_item_data(self):
Expand All @@ -25,7 +26,7 @@ def test_location_data(self):

# Every location has a region and every region's locations are in all_locations
all_locations: set = set(location_info['all_locations'])
all_locs_2: set = set()
all_locs_2: set = set()
for v in location_info['locations_by_region'].values():
all_locs_2.update(v)
assert all_locations == all_locs_2
Expand All @@ -49,12 +50,11 @@ def test_region_data(self):
for v in region_info['mandatory_connections']:
assert v[0] in all_entrances
assert v[1] in all_regions

for v in region_info['default_connections']:
assert v[0] in all_entrances
assert v[1] in all_regions

for k, v in region_info['illegal_connections'].items():
assert k in all_regions
assert set(v) <= all_entrances