Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a handful of __repr__ methods to improve debuggability #2078

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 "%s %s: %s" % (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 @@ -191,6 +191,9 @@ def __str__(self) -> str:
def __unicode__(self) -> str:
return '%s' % self.name

def __repr__(self) -> str:
return "%s %s" % (self.world.__repr__(), self.name)


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

def __repr__(self) -> str:
return "%s %s with %s" % (self.world.__repr__(), self.name, self.item.__repr__() if self.item else "<empty>")


@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 __str__(self) -> str:

def __unicode__(self) -> str:
return '%s' % self.name

def __repr__(self) -> str:
return "%s %s" % (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 @@ -1361,3 +1361,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)