-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtable.py
205 lines (167 loc) · 5.72 KB
/
table.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
from parse import get_table_info
from db.option import Option
from models.options.OptionSet import OptionSet
from models.options.MysteryOptionSet import MysteryOptionSet
class Table:
instance = None
default_db = {}
db = {}
info = {}
def __init__(self):
if Table.instance is None:
Table.instance = self
else:
self = Table.instance
def __getitem__(self, key):
return self.db[key]
def generate_pairs(self, **kwargs):
table_data = []
# Options
optionset = kwargs.get("options")
option_dbtuples = optionset.get_dbtuples()
for option_data in option_dbtuples:
if isinstance(option_data, dict) and "key" in option_data:
option_data_value = option_data.get("value")
if isinstance(option_data_value, int) and option_data_value < 0:
option_data_value = 0x100000000 + option_data_value
table_data.append({
"key": option_data.get("key"),
"value": option_data_value,
})
# temp fix for multiworld
table_data.append({
"key": 0xAF050000,
"value": 0x00000000
})
# Quizzes
quizzes = kwargs.get("quiz_data")
for key, value in quizzes:
table_data.append({
"key": key,
"value": value
})
# Items
placed_items = kwargs.get("items")
for node in placed_items:
if node.key_name_item is not None and node.current_item is not None:
assert not node.current_item.unplaceable # sanity check
table_data.append({
"key": node.get_item_key(),
"value": node.current_item.value,
})
# Item Prices
if ( node.key_name_price is not None
and ( node.key_name_price.startswith("ShopPrice")
or node.key_name_price.startswith("RewardAmount")
)
):
table_data.append({
"key": node.get_price_key(),
"value": node.current_item.base_price
})
# Blocks
placed_blocks = kwargs.get("blocks")
for key, value in placed_blocks:
table_data.append({
"key": key,
"value": value
})
# Entrances
entrances = kwargs.get("entrances")
for key, value in entrances:
table_data.append({
"key": key,
"value": value
})
# Battle IDs
battles = kwargs.get("battle_list")
for key, value in battles:
table_data.append({
"key": key,
"value": value
})
# Actor Attributes
actor_attributes = kwargs.get("actor_data")
for key, value in actor_attributes:
table_data.append({
"key": key,
"value": value
})
palettes = kwargs.get("palettes")
for key, value in palettes:
table_data.append({
"key": key,
"value": value
})
# Move Costs
move_costs = kwargs.get("move_costs")
for key, value in move_costs:
table_data.append({
"key": key,
"value": value
})
# Audio
music_list = kwargs.get("music_list")
for key, value in music_list:
table_data.append({
"key": key,
"value": value
})
# Map mirroring
mapmirror_list = kwargs.get("mapmirror_list")
for key, value in mapmirror_list:
table_data.append({
"key": key,
"value": value
})
# Puzzles & Minigames
puzzle_list = kwargs.get("puzzle_list")
for key, value in puzzle_list:
table_data.append({
"key": key,
"value": value
})
table_data.sort(key=lambda pair: pair["key"])
return table_data
def generate_palettes_pairs(self, **kwargs):
table_data = []
palettes = kwargs.get("palettes")
for key, value in palettes:
table_data.append({
"key": key,
"value": value
})
table_data.sort(key=lambda pair: pair["key"])
return table_data
def generate_cosmetics_pairs(self, **kwargs):
table_data = []
cosmetic_options = kwargs.get("cosmetics")
for option in cosmetic_options:
table_data.append({
"key": Option.get(Option.name == option).get_key(),
"value": cosmetic_options[option]
})
table_data.sort(key=lambda pair: pair["key"])
return table_data
def generate_audio_option_pairs(self, **kwargs):
table_data = []
cosmetic_options = kwargs.get("audio_options")
for option in cosmetic_options:
table_data.append({
"key": Option.get(Option.name == option).get_key(),
"value": cosmetic_options[option]
})
table_data.sort(key=lambda pair: pair["key"])
return table_data
def generate_music_pairs(self, **kwargs):
table_data = []
music_list = kwargs.get("music_list")
for key, value in music_list:
table_data.append({
"key": key,
"value": value
})
table_data.sort(key=lambda pair: pair["key"])
return table_data
def create(self):
self.info = get_table_info()