Exemple #1
0
 private void CreatePlayer()
 {
     // Cleare Console & Set Header
     Console.Clear();
     _menu.NewTitle("Create Player");
     // Prompt Username
     _username = Validation.ValidateString("Please enter a username: "******"It seems that username already exists\r\nPlease enter a username: "******"Are you a DM, or an Adventurer?: ", 1);
     // Validate
     while (!(_type.ToLower() == "dm" || _type.ToLower() == "adventurer"))
     {
         _type = Validation.ValidateString("I'm sorry, that wasn't right. Please choose a type: DM or Adventurer: ", 1);
     }
     // If DM is == Input, Create DM
     if (_type.ToLower() == "dm")
     {
         // Collect User Input
         _campaign  = Validation.ValidateString("What is your campaign name?: ", 1);
         _partySize = Validation.ValidateInt("How many adventurers are in your campaign?: ", 1);
         // Instantiate new DM
         _dm = new DM(_username, _campaign, _partySize);
         // Add to Player List
         _players.Add(_dm);
         Console.WriteLine($"{_campaign}, the campaign with {_partySize} members created by {_username}");
     }
     // Otherwise, Create Adventurer
     else
     {
         // Collect User Input
         _charName = Validation.ValidateString("What is your character's name?: ", 1);
         // Display Race
         _menu = new Menu("Human", "Elf", "Dwarf", "Orc");
         _menu.MinDisplay();
         _charRace = Validation.ValidateString("What is your character's race?: ", 1);
         SelectRace(_charRace);
         // Display Class
         _menu = new Menu("Rogue", "Bard", "Wizard", "Fighter");
         _menu.MinDisplay();
         _charClass = Validation.ValidateString("What is your character's class?: ", 1);
         SelectClass(_charClass);
         // Instantiate Adventurer
         _adventurer = new Adventurer(_username, _charName, _charRace, _charClass);
         // Add Randomly Generated Character Stats.
         RollStats();
         // Add to Player List
         _players.Add(_adventurer);
         Console.WriteLine($"{_charName}, the {_charRace} {_charClass} has been created for {_username}");
     }
     Utility.Continue("Press any key to continue");
     MainMenu();
 }
Exemple #2
0
        private void LoadData()
        {
            using (StreamReader sr = new StreamReader(_directory + _file))
            {
                // While Still Lines in File
                while (sr.Peek() > -1)
                {
                    string   line = sr.ReadLine();
                    string[] data = line.Split(',');
                    //  If There Aren't 3 values in Array, Create an Adventurer
                    if (data.Length != 3)
                    {
                        // Set Index of Data to Value
                        _username  = data[0];
                        _charName  = data[1];
                        _charRace  = data[2];
                        _charClass = data[3];
                        // Instantiate Temp Player
                        Adventurer player = new Adventurer(_username, _charName, _charRace, _charClass);
                        // Add to Player List
                        _players.Add(player);
                        // Create Diction
                        player.CharStats = new Dictionary <string, int>();
                        // Split Final Index Into 6 Integers
                        string[] stats = data[4].Split('.');

                        // Parse Each Index to Int. Add Key and Value to Dictionary
                        int strength = int.Parse(stats[0]);
                        player.CharStats.Add("Strength", strength);
                        int dexterity = int.Parse(stats[1]);
                        player.CharStats.Add("Dexterity", dexterity);
                        int constitution = int.Parse(stats[2]);
                        player.CharStats.Add("Constitution", constitution);
                        int wisdom = int.Parse(stats[3]);
                        player.CharStats.Add("Wisdom", wisdom);
                        int intelligence = int.Parse(stats[4]);
                        player.CharStats.Add("Intelligence", intelligence);
                        int charisma = int.Parse(stats[5]);
                        player.CharStats.Add("Charisma", charisma);
                    }
                    // Otherwise, Create a DM
                    else
                    {
                        _username  = data[0];
                        _campaign  = data[1];
                        _partySize = int.Parse(data[2]);
                        DM player1 = new DM(_username, _campaign, _partySize);
                        _players.Add(player1);
                    }
                }
            }
        }
Exemple #3
0
 public Assignment()
 {
     // Set Private Fields
     _dm         = null;
     _adventurer = null;
     _players    = new List <Player>();
     _removeChar = false;
     // Create File & Directory
     CreateData();
     // Load Existing File
     LoadData();
     MainMenu();
 }