from colorama import Fore, Back, Style class Card: def __init__(self, value, suit): self.value = value self.suit = suit self.selected = False self.suit_map = { 0: '♠', 1: '❤', 2: '♣', 3: '♦' } self.value_map = { 1: 'A', 11: 'J', 12: 'Q', 13: 'K' } def display_card(self): return f"{Back.WHITE}{Fore.RED if self.suit in [1,3] else Fore.BLUE}{self.value_map.get(self.value, self.value)}{self.suit_map[self.suit]} {Style.RESET_ALL}" def __repr__(self): s = Back.WHITE if not self.selected else Back.GREEN return f"{s}{Fore.RED if self.suit in [1,3] else Fore.BLUE}{self.value_map.get(self.value, self.value)}{self.suit_map[self.suit]} {Style.RESET_ALL}" def help_text(self, weapon=None): if self.suit in [0, 2]: return f'Attack {self.display_card()} {"barehanded?" if not weapon else "with {}? [b]".format(weapon)}' elif self.suit == 1: return f"Use {self.display_card()} as a health potion?" elif self.suit == 3: return f"Equip {self.display_card()} as a weapon?"