// Controlador public static void Controller(Client client, P_211 rcv) { if (!Regex.IsMatch(rcv.Name, @"^[A-Za-z0-9-]{4,12}$")) { client.Close("Nome inválido!"); } else if (rcv.Slot < 0 || rcv.Slot > 3) { client.Close( ); } else if (!Regex.IsMatch(rcv.Password, @"^[A-Za-z0-9]{4,10}$")) { client.Close( ); } else { // Retorna character da conta ref Character character = ref client.Account.Characters [rcv.Slot]; // Verifica se está vaziu if (character == null) { client.Close( ); } else { // Envia os pacotes de apagar personagem client.Send(P_112.New(client)); client.Send(P_101.New($"Personagem [{rcv.Name}] deletado!")); } }
// Controlador public static void Controller(Client client, P_211 rcv) { if (!Regex.IsMatch(rcv.Name, @"^[A-Za-z0-9-]{4,12}$")) { client.Close("Nome inválido!"); } else if (rcv.Slot < 0 || rcv.Slot > 3) { client.Close(); } else if (!Regex.IsMatch(rcv.Password, @"^[A-Za-z0-9]{4,10}$")) { client.Close(); } else { Character character = client.Account.Characters[rcv.Slot]; // Verifica se está vaziu if (character == null) { client.Close(); } else if (client.Account.Numeric.Equals(rcv.Password)) { if (UserMobDAO.DeleteCharFile(character)) { client.Character = null; client.Account.Characters[rcv.Slot] = null; UserAccountDAO.CreateOrUpdateAccount(client.Account); // Envia os pacotes de apagar personagem client.Send(P_112.New(client)); client.Send(P_101.New($"Personagem [{rcv.Name}] deletado!")); } else { client.Send(P_101.New($"Erro ao deletar o personagem [{rcv.Name}]!")); } } else { client.Send(P_101.New($"Senha numérica invalida!")); } } }