-
Notifications
You must be signed in to change notification settings - Fork 0
/
seedparser.py
60 lines (46 loc) · 1.77 KB
/
seedparser.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
import collections
import json
import re
sample_folderpath = 'resources/seeds'
sample_filepath = sample_folderpath + '/alttpr_none_standard_ganon_4jleEwaNQjBJlRA.json'
def getJson(filepath : str):
with open(filepath) as file:
seed_json : dict = json.load(file)
return seed_json
def getLocationMap() -> dict:
return get_sample().location_map
def get_sample():
return Seed(sample_filepath)
pattern = 'ganon_(.+)\.json'
def getGuid(filepath : str):
seed_guid = re.search(pattern, filepath).group(1)
return seed_guid
def remid(oldstr : str):
newstr = oldstr.split(':')[0]
return newstr
class Seed():
seed_guid = ''
seed_json = ''
def __init__(self, filepath : str):
self.seed_guid = getGuid(filepath)
self.seed_json = getJson(filepath)
self.seed_metadata = self.seed_json.pop("meta")
self.seed_number = self.seed_metadata['world_id']
self.playthrough = self.seed_json.pop("playthrough")
self.shops = self.seed_json.pop("Shops")
self.starting_gear = self.seed_json.pop("Equipped")
self.other_stuff = self.seed_json.pop("Special")
self.bosses = self.seed_json.pop('Bosses')
self.playthrough = json.dumps(self.playthrough)
# self.items = collections.defaultdict(list)
self.locations = {}
for region, dic in self.seed_json.items():
for key, value in dic.items():
self.locations[remid(key)] = remid(value)
# self.items[remid(value)].extend([remid(key)])
# self.location_map = {}
# self.reverse_map = {}
# for item in self.locations.keys():
# trimmed = re.sub('\W','', item)
# self.location_map[item] = trimmed
# self.reverse_map[trimmed] = item