#DEFINES FUNCTIONS
#DEFINES PROCEDURES

#DEFINES EXCEPTIONS/CLASSES

#DEF VARIABLES AND OBJECTS
sHostName = socket.gethostname()
dPlayers = {}

#RUNS THE MAIN PROGRAM
if __name__ == "__main__":
    print("Welcome to rpsMultiplayer")
    print("The server has been started on the hostname", sHostName)

    iPlayerCount = int(input("How many players will there be?"))
    print("You can tell the players to connect to the server now")

    for i in range(iPlayerCount):
        while True:
            sDataReceived, sIpAdressClient = net.fsReceive()
            if sDataReceived.startswith("Register Player "):
                if sDataReceived[16:] not in dPlayers:
                    dPlayers.update({sDataReceived[16:]:sIpAdressClient})
                    net.fSend("Player registered", sIpAdressClient,)
                    break
                else:
                    net.fSend("Error: Playername Already Registered", sIpAdressClient)
            else:
                net.fSend("Error: Expecting registration of players", sIpAdressClient)
    print(dPlayers)
        #logs the concatenated list
        logging.debug(sOutput)
else:
    def log(*parameters):
        '''Dummy log function'''

#DEFINES CONSTANTS

#DEFINES WRAPPER FUNCTIONS

#DEFINES FUNCTIONS
#DEFINES PROCEDURES

#DEFINES EXCEPTIONS/CLASSES

#DEF VARIABLES AND OBJECTS
sUniqueID = str(random.randrange(1000000,9999999))

#RUNS THE MAIN PROGRAM
if __name__ == "__main__":
    print("Welcome to rpsMultiplayer")
    sPlayerName = input("Input your playername: ")[:12]
    sServerHostName = input(
        "please input the hostname of the server you want to join: ")
    print("Connecting to ", sServerHostName, sep="")
    net.fSend("Register Player " + sUniqueID + " " + sPlayerName,
              socket.gethostbyname(sServerHostName))
    print("Connection Established")