Esempio n. 1
0
        public static Tuple <bool, Player> getUsernameAndPassword()
        {
            Tuple <bool, Player> userInfo;
            bool valid;

            StandardMessages.getUsername();
            string username = Console.ReadLine();

            StandardMessages.getPassword();
            string password = Console.ReadLine();

            //ADD GET CURRENT ROOM AS PROPERTY OF PLAYER HERE

            bool verify = InputValidation.VerifyUsername(username) && InputValidation.VerifyPassword(password);

            if (verify == true)
            {
                Console.WriteLine("You are logged in.");
                //eventually print character info and stats here//CAN ADD ROOM PROPERTY HERE
                Player newPlayer = getPlayer(username, password);
                valid    = true;
                userInfo = new Tuple <bool, Player>(valid, newPlayer);
            }
            else
            {
                Console.WriteLine("Incorrect Information. Try again.");
                valid = false;
                Player newPlayer = null;
                userInfo = new Tuple <bool, Player>(valid, newPlayer);
            }

            return(userInfo);
        }
Esempio n. 2
0
        public static Tuple <bool, Player> createPlayer()
        {
            Tuple <bool, Player> loginPlayer;

            StandardMessages.getUsername();
            string username = Console.ReadLine();

            if (InputValidation.VerifyUsername(username) == true)
            {
                //if username is already used prompts user to try to login or select a new username
                StandardMessages.usernameTaken();
                Console.WriteLine("Would you like to try to login? (Y/N)");
                string login = Console.ReadLine().ToLower();

                char[] letter = login.ToCharArray();

                switch (letter[0])
                {
                case 'y':
                    loginPlayer = LoginMenu();
                    return(loginPlayer);

                case 'n':
                    loginPlayer = createPlayer();
                    return(loginPlayer);

                default:
                    Console.WriteLine("Invalid Input");
                    break;
                }

                return(null);
            }

            else
            {
                StandardMessages.createPassword();
                string password = Console.ReadLine();
                while (!InputValidation.ValidatePassword(password))
                {
                    //prompts user to keep trying password until reqs met
                    StandardMessages.createPassword();
                    password = Console.ReadLine();
                }
                StandardMessages.selectClass();
                string characterClass = Console.ReadLine();
                Tuple <string, int> characterClassTuple;

                while (!InputValidation.CharacterClassValidation(characterClass))
                {
                    //prompts user to enter a class choice that is given
                    StandardMessages.selectClass();
                    characterClass = Console.ReadLine();
                }

                characterClassTuple = Enums.getCharacterInfo(characterClass);

                StandardMessages.selectRace();
                string race = Console.ReadLine();
                Tuple <string, int> raceTuple;

                while (!InputValidation.characterRaceValidation(race))
                {
                    //prompts user to enter a race choice that is given
                    StandardMessages.selectRace();
                    race = Console.ReadLine();
                }

                raceTuple = Enums.getRaceInfo(race);

                Rooms         currentLocation = World.GetRoomByName("Troy");     //This defaults the player to Troy
                bool          isalive         = true;                            //defaults to alive
                int           gold_reward     = 0;
                Weapons       weapon          = World.GetWeaponByName("dagger"); //defaults to null
                List <IItems> inventory       = new List <IItems>();
                inventory.Add(World.GetWeaponByName("dagger"));
                //Create player object
                Player newPlayer = new Player(username, password, characterClassTuple.Item1, raceTuple.Item1, currentLocation, characterClassTuple.Item2, raceTuple.Item2, isalive, weapon, gold_reward, inventory);
                Player.sendToLoginFile(newPlayer);
                //Send the properties to the text file
                Player.sendToPlayerFile(newPlayer);
                loginPlayer = new Tuple <bool, Player>(true, newPlayer);
                return(loginPlayer);
            }
        }