Esempio n. 1
0
    private static void Connect(byte Index, NetIncomingMessage Data)
    {
        // Lê os Data
        string User     = Data.ReadString().Trim();
        string Password = Data.ReadString();

        // Check if everything is okay
        if (User.Length < Game.Min_Character || User.Length > Game.Max_Character || Password.Length < Game.Min_Character || Password.Length > Game.Max_Character)
        {
            Sending.Alert(Index, "The user name and password must contain " + Game.Min_Character + " and" + Game.Max_Character + " characters.");
            return;
        }
        if (!File.Exists(Directories.Accounts.FullName + User + Directories.Format))
        {
            Sending.Alert(Index, "This username is not registered.");
            return;
        }
        if (Player.MultipleAccounts(User))
        {
            Sending.Alert(Index, "There's already someone connected to that account.");
            return;
        }
        else if (Password != Read.Player_Password(User))
        {
            Sending.Alert(Index, "The password is incorrect.");
            return;
        }

        // Carrega os Data do Player
        Read.Player(Index, User);

        // Envia os Data das classes
        Sending.Classes(Index);

        // Se o Player não tiver nenhum Character então abrir o painel de criação de Character
        if (!Player.PossuiCharacters(Index))
        {
            Sending.CreateCharacter(Index);
            return;
        }

        // Abre a janela de seleção de personagens
        Sending.Characters(Index);
        Sending.Conectar(Index);
    }