Core: move multiple Item properties into a single Flag (#638)

This commit is contained in:
Fabian Dill
2022-06-17 03:23:27 +02:00
committed by GitHub
parent 5be00e28dd
commit 6c525e1fe6
45 changed files with 559 additions and 493 deletions

View File

@@ -1,6 +1,7 @@
import typing
from BaseClasses import Item
from BaseClasses import Item, ItemClassification
def oot_data_to_ap_id(data, event):
if event or data[2] is None or data[0] == 'Shop':
@@ -11,6 +12,7 @@ def oot_data_to_ap_id(data, event):
else:
raise Exception(f'Unexpected OOT item type found: {data[0]}')
def ap_id_to_oot_data(ap_id):
offset = 66000
val = ap_id - offset
@@ -19,25 +21,31 @@ def ap_id_to_oot_data(ap_id):
except IndexError:
raise Exception(f'Could not find desired item ID: {ap_id}')
class OOTItem(Item):
game: str = "Ocarina of Time"
def __init__(self, name, player, data, event, force_not_advancement):
(type, advancement, index, special) = data
# "advancement" is True, False or None; some items are not advancement based on settings
if force_not_advancement:
classification = ItemClassification.useful
elif name == "Ice Trap":
classification = ItemClassification.trap
elif name == 'Gold Skulltula Token':
classification = ItemClassification.progression_skip_balancing
elif advancement:
classification = ItemClassification.progression
else:
classification = ItemClassification.filler
adv = bool(advancement) and not force_not_advancement
super(OOTItem, self).__init__(name, adv, oot_data_to_ap_id(data, event), player)
super(OOTItem, self).__init__(name, classification, oot_data_to_ap_id(data, event), player)
self.type = type
self.index = index
self.special = special or {}
self.looks_like_item = None
self.price = special.get('price', None) if special else None
self.internal = False
self.trap = name == 'Ice Trap'
if force_not_advancement:
self.never_exclude = True
if name == 'Gold Skulltula Token':
self.skip_in_prog_balancing = True
# The playthrough calculation calls a function that uses "sweep_for_events(key_only=True)"
# This checks if the item it's looking for is a small key, using the small key property.