1
- from BaseClasses import MultiWorld , Item
1
+ import os
2
+ import pkgutil
3
+ import json
4
+
5
+ from BaseClasses import MultiWorld , Item , Location
2
6
from typing import Optional , List
3
7
from worlds .AutoWorld import World
4
- from .Data import category_table
5
- from .Items import ManualItem
6
- from .Locations import ManualLocation
7
8
from .hooks .Helpers import before_is_category_enabled , before_is_item_enabled , before_is_location_enabled
8
9
9
10
from typing import Union
10
11
12
+ # blatantly copied from the minecraft ap world because why not
13
+ def load_data_file (* args ) -> dict :
14
+ fname = os .path .join ("data" , * args )
15
+
16
+ try :
17
+ filedata = json .loads (pkgutil .get_data (__name__ , fname ).decode ())
18
+ except :
19
+ filedata = []
20
+
21
+ return filedata
22
+
11
23
def is_option_enabled (multiworld : MultiWorld , player : int , name : str ) -> bool :
12
24
return get_option_value (multiworld , player , name ) > 0
13
25
@@ -28,6 +40,7 @@ def clamp(value, min, max):
28
40
return value
29
41
30
42
def is_category_enabled (multiworld : MultiWorld , player : int , category_name : str ) -> bool :
43
+ from .Data import category_table
31
44
"""Check if a category has been disabled by a yaml option."""
32
45
hook_result = before_is_category_enabled (multiworld , player , category_name )
33
46
if hook_result is not None :
@@ -56,7 +69,7 @@ def is_item_name_enabled(multiworld: MultiWorld, player: int, item_name: str) ->
56
69
57
70
return is_item_enabled (multiworld , player , item )
58
71
59
- def is_item_enabled (multiworld : MultiWorld , player : int , item : ManualItem ) -> bool :
72
+ def is_item_enabled (multiworld : MultiWorld , player : int , item : Item ) -> bool :
60
73
"""Check if an item has been disabled by a yaml option."""
61
74
hook_result = before_is_item_enabled (multiworld , player , item )
62
75
if hook_result is not None :
@@ -72,7 +85,7 @@ def is_location_name_enabled(multiworld: MultiWorld, player: int, location_name:
72
85
73
86
return is_location_enabled (multiworld , player , location )
74
87
75
- def is_location_enabled (multiworld : MultiWorld , player : int , location : ManualLocation ) -> bool :
88
+ def is_location_enabled (multiworld : MultiWorld , player : int , location : Location ) -> bool :
76
89
"""Check if a location has been disabled by a yaml option."""
77
90
hook_result = before_is_location_enabled (multiworld , player , location )
78
91
if hook_result is not None :
0 commit comments