Skip to content

Commit

Permalink
Fix displaying moves of the '???' type in console... once again (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzi authored Oct 23, 2024
1 parent 0c66f27 commit 9af8423
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions modules/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"dragon": "#7038f8",
"dark": "#705848",
"steel": "#b8b8d0",
"question_marks": "#68a090",
# This is the '???' type, but because we cannot just use that as a colour name,
# it has been renamed. This is done by the `Type` class' `safe_name` property.
"unknown": "#68a090",
}
)

Expand Down Expand Up @@ -102,7 +104,7 @@ def percentage(value, total) -> str:

def print_stats(stats: "GlobalStats", encounter: "EncounterInfo") -> None:
pokemon = encounter.pokemon
type_colour = pokemon.species.types[0].name.lower()
type_colour = pokemon.species.types[0].safe_name.lower()
if pokemon.gender is not None and not pokemon.species.name.startswith("Nidoran"):
gender_code = "♂" if pokemon.gender == "male" else "♀"
gender_label = "[cyan]Male ♂[/]" if pokemon.gender == "male" else "[pink]Female ♀[/]"
Expand Down Expand Up @@ -155,7 +157,7 @@ def print_stats(stats: "GlobalStats", encounter: "EncounterInfo") -> None:
for learned_move in pokemon.moves:
if learned_move is not None:
move = learned_move.move
move_list.append(f"[{move.type.name.lower()}]{move.name}[/]")
move_list.append(f"[{move.type.safe_name.lower()}]{move.name}[/]")
move_list = f"\n[bold]Moves:[/] {', '.join(move_list)}"

# EV Yield
Expand Down
4 changes: 4 additions & 0 deletions modules/pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ def is_special(self) -> bool:
def kind(self) -> str:
return "Physical" if self.is_physical else "Special"

@property
def safe_name(self) -> str:
return "Unknown" if self.name == "???" else self.name

def __str__(self):
return self.name

Expand Down

0 comments on commit 9af8423

Please sign in to comment.