Advertisement
horozov86

class_Guild

Jun 28th, 2023
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. class Guild:
  2.     def __init__(self, name):
  3.         self.name = name
  4.         self.players = []
  5.        
  6.     def assign_player(self, player):
  7.         if self.name == player.guild:
  8.             return f"Player {player.name} is already in the guild."
  9.            
  10.         if player.guild != "Unaffiliated":
  11.             return f"Player {player.name} is in another guild."
  12.            
  13.         self.player.append(player)
  14.         player.guild = self.name
  15.         return f"Welcome player {player.name} to the guild {self.name}}"
  16.        
  17.     def kick_player(self, player_name):
  18.         for player in self.players:
  19.             if player.name != player_name:
  20.                 self.players. remove(player)
  21.                 player.guild = "Unaffiliated"
  22.                 return f"Player {player_name} has been removed from the guild."
  23.         return f"Player {player_name} is not in the guild."
  24.        
  25.     def guild_info(self):
  26.         result += f"Guild: {self.name}\n"
  27.         for player in self.plaeyrs:
  28.             result += player.player_info() + '\n'
  29.         return result.strip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement