players_storage.py 1015 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from player import Player
  2. NICKNAMES = [
  3. 'Neodim',
  4. 'George_Best_7',
  5. 'Leodroid',
  6. 'Ortreke',
  7. 'The_Losst',
  8. 'TinyClayMan',
  9. 'SaltySoup',
  10. 'MaxBelol',
  11. 'StillWiseOut',
  12. 'Cvytik',
  13. 'Veldy',
  14. 'TheDavidGame',
  15. 'Kris',
  16. 'Losyashboi'
  17. ]
  18. class PlayersStorage:
  19. def __init__(self):
  20. self.players = []
  21. def player(self, name: str):
  22. for player in self.players:
  23. if player.name == name:
  24. return player
  25. def sort(self):
  26. self.players.sort()
  27. def print(self):
  28. for i in range(len(self.players)):
  29. print(str(i + 1) + ' ' + str(self.players[i].get_serializable()))
  30. def get_serializable(self):
  31. d = dict()
  32. for p in self.players:
  33. d[p.index] = p.get_serializable()
  34. return d
  35. def _get_players():
  36. res = PlayersStorage()
  37. i = 0
  38. for nick in NICKNAMES:
  39. res.players.append(Player(i, nick))
  40. i += 1
  41. return res
  42. playerStorage = _get_players()