import random class Player: def __init__(self, name: str): self.name = name print(f"Player's Name is {name} and initialize all his attributes") self.hp = 75 self.mp = 50 self.coin = 20 self.items = [] self.frames = [] def reduce_hp(self, amount: int): print(f'Reduce {amount} HP') self.hp = max(0, self.hp-amount) def add_hp(self, amount: int): print(f'Add {amount} HP') self.hp += amount def reduce_mp(self, amount: int): print(f'Reduce {amount} MP') self.mp = max(0, self.mp-amount) def add_mp(self, amount: int): print(f'Add {amount} MP') self.mp += amount def reduce_coin(self, amount: int): print(f'Reduce {amount} Coin') self.coin = max(0, self.coin-amount) def add_coin(self, amount: int): print(f'Add {amount} Coin') self.coin += amount def add_item(self, item): print(f'Add {item} to the item bag') self.items.append(item) def use_item(self, item): if item not in self.items: print(f'Could not use {item}') else: self.items.remove(item) print(f'Used up {item} and there are {len(item)} items left') def get_attribute(self) -> dict: return {'hp': self.hp, 'mp': self.mp, 'coin': self.coin} def set_name(self, name: str): self.name = name def append_file(self, filelist: list[str]): self.frames += filelist def get_images(self): return self.frames