Exemple #1
0
    private static void Register(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;
        }
        else if (File.Exists(Directories.Accounts.FullName + User + Directories.Format))
        {
            Sending.Alert(Index, "Already registered with this name.");
            return;
        }

        // Cria a conta
        Lists.Player[Index].User     = User;
        Lists.Player[Index].Password = Password;

        // Salva a conta
        Write.Player(Index);

        // Abre a janela de seleção de personagens
        Sending.Classes(Index);
        Sending.CreateCharacter(Index);
    }
Exemple #2
0
    private static void Character_Create(byte Index, NetIncomingMessage Data)
    {
        // Verifica se o Player já criou o máximo de personagens possíveis
        if (Player.EncontrarCharacter(Index, string.Empty) == 0)
        {
            Sending.Alert(Index, "You can only have " + Lists.Server_Data.Max_Characters + " characters.", false);
            return;
        }

        // Abre a janela de seleção de personagens
        Sending.Classes(Index);
        Sending.CreateCharacter(Index);
    }
Exemple #3
0
    private static void CreateCharacter(byte Index, NetIncomingMessage Data)
    {
        byte Character = Player.EncontrarCharacter(Index, string.Empty);

        // Lê os Data
        string Name = Data.ReadString().Trim();

        // Verifica se está tudo certo
        if (Name.Length < Game.Min_Character || Name.Length > Game.Max_Character)
        {
            Sending.Alert(Index, "The character name must contain " + Game.Min_Character + " and " + Game.Max_Character + " characters.", false);
            return;
        }
        if (Name.Contains(";") || Name.Contains(":"))
        {
            Sending.Alert(Index, "Cannot contain ';' and ':' in the Character name.", false);
            return;
        }
        if (Read.Characters_Names().Contains(";" + Name + ":"))
        {
            Sending.Alert(Index, "A character with this name already exists.", false);
            return;
        }

        // Define o Character que será usado
        Lists.TempPlayer[Index].Used = Character;

        // Define os valores iniciais do Character
        Player.Character(Index).Name      = Name;
        Player.Character(Index).Level     = 1;
        Player.Character(Index).Classe    = Data.ReadByte();
        Player.Character(Index).Genre     = Data.ReadBoolean();
        Player.Character(Index).Attribute = Lists.Classe[Player.Character(Index).Classe].Attribute;
        Player.Character(Index).Map       = Lists.Classe[Player.Character(Index).Classe].Appearance_Map;
        Player.Character(Index).Direction = (Game.Location)Lists.Classe[Player.Character(Index).Classe].Appearance_Direction;
        Player.Character(Index).X         = Lists.Classe[Player.Character(Index).Classe].Appearance_X;
        Player.Character(Index).Y         = Lists.Classe[Player.Character(Index).Classe].Appearance_Y;
        for (byte i = 0; i <= (byte)Game.Vital.Amount - 1; i++)
        {
            Player.Character(Index).Vital[i] = Player.Character(Index).MaxVital(i);
        }

        // Salva a conta
        Write.Character(Name);
        Write.Player(Index);

        // Entra no Game
        Player.Entrar(Index);
    }
Exemple #4
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);
    }
Exemple #5
0
    private static void Character_Delete(byte Index, NetIncomingMessage Data)
    {
        byte   Character = Data.ReadByte();
        string Name      = Lists.Player[Index].Character[Character].Name;

        // Verifica se o Character existe
        if (string.IsNullOrEmpty(Name))
        {
            return;
        }

        // Deleta o Character
        Sending.Alert(Index, "The character '" + Name + "' has been deleted.", false);
        Write.Characters(Read.Characters_Names().Replace(":;" + Name + ":", ":"));
        Clean.Player_Character(Index, Character);

        // Salva o Character
        Sending.Characters(Index);
        Write.Player(Index);
    }