// See https://aka.ms/new-console-template for more information using Modèle; using System; using System.Reflection.PortableExecutable; ///Déclaration du STUB UserBase ub = new UserBase(); /* void testMonstre() { //Création non permanente d'une liste de caractéristiques (pour tests) -> PEUT-ÊTRE EN FAIRE UNE CLASSE PLUS TARD??? List charact = new List(); charact.AddRange(new List { "Caractéristique 1", "C2", "C3", "ENCORE UNE CARACTÉRISTIQUE", "Again and again" }); //Création non permanente d'une liste d'apparences (pour tests) -> PEUT-ÊTRE EN FAIRE UNE CLASSE PLUS TARD AUSSI??? List appear = new List(); appear.AddRange(new List { "Wow1", "Wow2", "Wow3", "ENCORE UNE APPARENCE" }); Monstre monstre = new Monstre(1, "Warden", "Le Warden est une entité conçue pour vous traquer. Il est comme un GPS vivant capable d'optimiser ses déplacements pour vous contrer," + " sachant que s'il n'arrive pas à vous coincer, il pourra toujours utiliser son attaque... [Plus]", charact, appear); Console.WriteLine(monstre.IntroduceTest()); Console.WriteLine(); Console.WriteLine("Liste de mes caractéristiques :"); monstre.CharacteristicsList.ForEach(Console.WriteLine); Console.WriteLine(); Console.WriteLine("Liste de mes apparences :"); monstre.AppearanceList.ForEach(Console.WriteLine); Console.WriteLine(); Console.WriteLine(); Monstre monstre2 = new Monstre(423, "Mouton", "Je suis un animal présent dans la campagne.", charact, appear); Console.WriteLine(monstre2.IntroduceTest()); }*/ int menuPrincipal(){ string? choix; Console.WriteLine("Menu - Connexion / Inscription"); Console.WriteLine("\t1 - Connexion\n\t2 - Inscription\n\t3 - Connexion plus tard\n"); choix = Console.ReadLine(); if ( choix == "1") { Console.Clear(); Console.WriteLine("Choix 1"); menuConnexion(); return 1; } else if ( choix == "2") { Console.Clear(); Console.WriteLine("Choix 2"); return 2; } else if (choix == "3") { Console.Clear(); Console.WriteLine("Choix 3"); searchPage(); return 3; } else { Console.WriteLine("Écris un nombre compris entre 1 et 3"); // Pq ? il écrit ça à chaque fin de prog } return 0; } string ReadPassword() { string psswrd = ""; ConsoleKeyInfo info = Console.ReadKey(true); while (info.Key != ConsoleKey.Enter) { if (info.Key != ConsoleKey.Backspace) { Console.Write("*"); psswrd += info.KeyChar; } else if (info.Key == ConsoleKey.Backspace) { if (!string.IsNullOrEmpty(psswrd)) { // Supprime un élément de la liste de char de psswrd psswrd = psswrd.Substring(0, psswrd.Length - 1); // get the location of the cursor int pos = Console.CursorLeft; // move the cursor to the left by one character Console.SetCursorPosition(pos - 1, Console.CursorTop); // replace it with space Console.Write(" "); // move the cursor to the left by one character again Console.SetCursorPosition(pos - 1, Console.CursorTop); } } info = Console.ReadKey(true); } // Ajoute un alinéa parce que l'utlisateur a validé Console.WriteLine("Vous arrivez sur la page d'accueil"); searchPage(); return psswrd; } int menuConnexion() { string? id; string? psswd; Console.WriteLine("Identifiant : "); id = Console.ReadLine(); Console.WriteLine("Mot de passe : "); psswd = ReadPassword(); int nbRetries = 0; int exists = ub.checkIfExists(id, psswd); while (exists == 0) { if(nbRetries >= 3) { return -1; } Console.Clear(); Console.WriteLine("Erreur, identifiant ou mot de passe incorrect."); nbRetries++; Console.WriteLine(""); Console.WriteLine("Identifiant : "); id = Console.ReadLine(); Console.WriteLine("Mot de passe : "); psswd = ReadPassword(); exists = ub.checkIfExists(id, psswd); } return 0; } int searchPage() { Console.WriteLine("Bienvenue sur la page d'accueil"); Console.WriteLine("1 - Déconnexion"); string? choix; choix = Console.ReadLine(); if ( choix == "1") { menuPrincipal(); return 1; } else { Console.WriteLine("Entrer un chiffre correct"); searchPage(); } return 0; } int codeRetour = menuPrincipal();