Advertisement
horozov86

class_Player

Jun 28th, 2023
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. class Player:
  2.     def __init(self, name, hp, mp):
  3.         self.name = name
  4.         seld.hp = hp
  5.         self.mp = mp
  6.         self.skills = {}
  7.         self.guild = "Unaffiliated"
  8.        
  9.     def add_skill(self, skill_name, mana_cost):
  10.         if skill_name in self.skills:
  11.             return "Skill already added
  12.        self.skills[skill_name] = mana_cost
  13.        return f"Skill {skill_name} added to the collection of the player {self.name}"
  14.        
  15.    def player_info(self):
  16.        result = f"Name: {self.name}\n"
  17.        result += f"Guild: {self.guild}\n"
  18.        result += f"HP: {self.hp}\n"
  19.        result += f"MP: {self.mp}\n"
  20.        for s, m in self.skills.items():
  21.            result += f"==={s} - {m}\n"
  22.            
  23.        return result.strip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement