Core: cleanup BaseClasses.Location
This is just cleanup and has virtually no performance impact.
This commit is contained in:
parent
04eef669f9
commit
181cc47079
|
@ -1064,26 +1064,25 @@ class LocationProgressType(IntEnum):
|
||||||
|
|
||||||
|
|
||||||
class Location:
|
class Location:
|
||||||
# If given as integer, then this is the shop's inventory index
|
game: str = "Generic"
|
||||||
shop_slot: Optional[int] = None
|
player: int
|
||||||
shop_slot_disabled: bool = False
|
name: str
|
||||||
|
address: Optional[int]
|
||||||
|
parent_region: Optional[Region]
|
||||||
event: bool = False
|
event: bool = False
|
||||||
locked: bool = False
|
locked: bool = False
|
||||||
game: str = "Generic"
|
|
||||||
show_in_spoiler: bool = True
|
show_in_spoiler: bool = True
|
||||||
crystal: bool = False
|
|
||||||
progress_type: LocationProgressType = LocationProgressType.DEFAULT
|
progress_type: LocationProgressType = LocationProgressType.DEFAULT
|
||||||
always_allow = staticmethod(lambda item, state: False)
|
always_allow = staticmethod(lambda item, state: False)
|
||||||
access_rule = staticmethod(lambda state: True)
|
access_rule = staticmethod(lambda state: True)
|
||||||
item_rule = staticmethod(lambda item: True)
|
item_rule = staticmethod(lambda item: True)
|
||||||
item: Optional[Item] = None
|
item: Optional[Item] = None
|
||||||
parent_region: Optional[Region]
|
|
||||||
|
|
||||||
def __init__(self, player: int, name: str = '', address: int = None, parent=None):
|
def __init__(self, player: int, name: str = '', address: Optional[int] = None, parent: Optional[Region] = None):
|
||||||
self.name: str = name
|
self.player = player
|
||||||
self.address: Optional[int] = address
|
self.name = name
|
||||||
|
self.address = address
|
||||||
self.parent_region = parent
|
self.parent_region = parent
|
||||||
self.player: int = player
|
|
||||||
|
|
||||||
def can_fill(self, state: CollectionState, item: Item, check_access=True) -> bool:
|
def can_fill(self, state: CollectionState, item: Item, check_access=True) -> bool:
|
||||||
return self.always_allow(state, item) or (self.item_rule(item) and (not check_access or self.can_reach(state)))
|
return self.always_allow(state, item) or (self.item_rule(item) and (not check_access or self.can_reach(state)))
|
||||||
|
|
|
@ -207,10 +207,10 @@ def ShopSlotFill(world):
|
||||||
shops_per_sphere.append(current_shops_slots)
|
shops_per_sphere.append(current_shops_slots)
|
||||||
candidates_per_sphere.append(current_candidates)
|
candidates_per_sphere.append(current_candidates)
|
||||||
for location in sphere:
|
for location in sphere:
|
||||||
if location.shop_slot is not None:
|
if isinstance(location, ALttPLocation) and location.shop_slot is not None:
|
||||||
if not location.shop_slot_disabled:
|
if not location.shop_slot_disabled:
|
||||||
current_shops_slots.append(location)
|
current_shops_slots.append(location)
|
||||||
elif not location.locked and not location.item.name in blacklist_words:
|
elif not location.locked and location.item.name not in blacklist_words:
|
||||||
current_candidates.append(location)
|
current_candidates.append(location)
|
||||||
if cumu_weights:
|
if cumu_weights:
|
||||||
x = cumu_weights[-1]
|
x = cumu_weights[-1]
|
||||||
|
|
|
@ -6,14 +6,19 @@ from BaseClasses import Location, Item, ItemClassification
|
||||||
|
|
||||||
class ALttPLocation(Location):
|
class ALttPLocation(Location):
|
||||||
game: str = "A Link to the Past"
|
game: str = "A Link to the Past"
|
||||||
|
crystal: bool
|
||||||
|
player_address: Optional[int]
|
||||||
|
_hint_text: Optional[str]
|
||||||
|
shop_slot: Optional[int] = None
|
||||||
|
"""If given as integer, shop_slot is the shop's inventory index."""
|
||||||
|
shop_slot_disabled: bool = False
|
||||||
|
|
||||||
def __init__(self, player: int, name: str = '', address=None, crystal: bool = False,
|
def __init__(self, player: int, name: str, address: Optional[int] = None, crystal: bool = False,
|
||||||
hint_text: Optional[str] = None, parent=None,
|
hint_text: Optional[str] = None, parent=None, player_address: Optional[int] = None):
|
||||||
player_address=None):
|
|
||||||
super(ALttPLocation, self).__init__(player, name, address, parent)
|
super(ALttPLocation, self).__init__(player, name, address, parent)
|
||||||
self.crystal = crystal
|
self.crystal = crystal
|
||||||
self.player_address = player_address
|
self.player_address = player_address
|
||||||
self._hint_text: str = hint_text
|
self._hint_text = hint_text
|
||||||
|
|
||||||
|
|
||||||
class ALttPItem(Item):
|
class ALttPItem(Item):
|
||||||
|
|
Loading…
Reference in New Issue