import json
from Classes.Objects.Player import Player

class Player:
    __users:list
    
    def __init__(self):
        self.__users = []
    
    def createUser(self, user:json):
        self.__users.append(user)

    def createUser(self, user:json):
        if self.getUser(user["username"]) == None:
            self.__users.append(Player(user["username"]))

    def removeUser(self, user:int):
        self.__users.remove(user)

    def removeUser(self, user:str):
        self.__users.remove(user)

    def getUsers(self) -> list:
        return self.__users

    def getUser(self, user:int) -> (any | None):
        for user in self.__users:
            if int(user["id"]) == user:
                return user
            
    def getUser(self, user:str) -> (any | None):
        for user in self.__users:
            if user["name"] == user:
                return user