Skip to content

Commit

Permalink
Merge 'Add a handful of __repr__ methods to improve debuggability' (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cjohnson57 committed Nov 29, 2023
2 parents b821966 + 7f3169e commit 8d15cc3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Goals.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def requires(self, item: str) -> bool:
names.append(item_table[item][3]['alias'][0])
return any(i['name'] in names and not i['hintable'] for i in self.items)

def __repr__(self) -> str:
return f"{self.world.__repr__()} {self.name}: {self.hint_text}"


class GoalCategory:
def __init__(self, name: str, priority: int, goal_count: int = 0, minimum_goals: int = 0,
Expand Down
3 changes: 3 additions & 0 deletions Item.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ def goalitem(self) -> bool:
def __str__(self) -> str:
return self.name

def __repr__(self) -> str:
return f"{self.world.__repr__()} {self.name}"


@overload
def ItemFactory(items: str, world: Optional[World] = None, event: bool = False) -> Item:
Expand Down
4 changes: 4 additions & 0 deletions Location.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ def maybe_set_misc_hints(self) -> None:
def __str__(self) -> str:
return self.name

def __repr__(self) -> str:
item_repr = self.item.__repr__() if self.item else "<empty>"
return f"{self.world.__repr__()} {self.name} with {item_repr}"


@overload
def LocationFactory(locations: str) -> Location:
Expand Down
3 changes: 3 additions & 0 deletions Region.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,6 @@ def get_scene(self) -> Optional[str]:

def __str__(self) -> str:
return self.name

def __repr__(self) -> str:
return f"{self.world.__repr__()} {self.name}"
4 changes: 4 additions & 0 deletions World.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,3 +1370,7 @@ def update_useless_areas(self, spoiler: Spoiler) -> None:

if useless_area:
self.empty_areas[area] = area_info


def __repr__(self) -> str:
return "W%d" % (self.id)
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '8.0.6'
__version__ = '8.0.7'

# This is a supplemental version number for branches based off of main dev.
supplementary_version = 0
Expand Down

0 comments on commit 8d15cc3

Please sign in to comment.