Exemplo n.º 1
0
        }         // Choice

        public static void RndChoice(CharacterCombat character, int race)
        {
            switch (race)
            {
            case 1:
                Races.Combine(character, "Dwarf");
                break;

            case 2:
                Races.Combine(character, "Elf");
                break;

            case 3:
                Races.Combine(character, "Gnome");
                break;

            case 4:
                Races.Combine(character, "HalfElf");
                break;

            case 5:
                Races.Combine(character, "Halfling");
                break;

            case 6:
                Races.Combine(character, "HalfOrc");
                break;

            case 7:
                Races.Combine(character, "Human");
                break;

            default:
                Console.WriteLine("I don't know how you got there, but that should really happen.. Try again maybe?");
                break;
            }
        }// RndChoice
Exemplo n.º 2
0
        public static CharacterCombat Generate()
        {
            int chosenClass;
            int level;
            int race;
            int feat;
            int res = 0;

            string[] races     = { "Dwarf", "Elf", "Gnome", "Half Elf", "Halfling", "Half Orc", "Human" };
            string[] stats     = { "Strength", "Dexterity", "Constitution", "Intelligence", "Wisdom", "Charisma" };
            DiceRoll dice      = new DiceRoll();
            dynamic  character = null;

            Console.WriteLine("Welcome to the Random Generator option! Stand by while we let our monke.... our skilled engineer create your new class!");

            // Choosing a class randomly
            chosenClass = dice.Roll(11);

            // Choosing a level randomly
            level = dice.Roll(5);

            // Select a race randomly
            race = dice.Roll(7);

            Console.WriteLine("\n----------------------------------------");

            switch (chosenClass)
            {
            case 1:
                character = new Barbarian(level);
                character.UpdateBaseInfo(1, "Barbarian");
                Console.WriteLine("You are a level " + level + " " + races.GetValue(race - 1) + " Barbarian!");
                break;

            case 2:
                character = new Bard(level);
                character.UpdateBaseInfo(1, "Bard");
                Console.WriteLine("You are a level " + level + " " + races.GetValue(race - 1) + " Bard!");
                break;

            case 3:
                character = new Cleric(level);
                character.UpdateBaseInfo(1, "Cleric");
                Console.WriteLine("You are a level " + level + " " + races.GetValue(race - 1) + " Cleric!");
                break;

            case 4:
                character = new Druid(level);
                character.UpdateBaseInfo(1, "Druid");
                Console.WriteLine("You are a level " + level + " " + races.GetValue(race - 1) + " Druid!");
                break;

            case 5:
                character = new Fighter(level);
                character.UpdateBaseInfo(1, "Fighter");
                Console.WriteLine("You are a level " + level + " " + races.GetValue(race - 1) + " Fighter!");
                break;

            case 6:
                character = new Monk(level);
                character.UpdateBaseInfo(1, "Monk");
                Console.WriteLine("You are a level " + level + " " + races.GetValue(race - 1) + " Monk!");
                break;

            case 7:
                character = new Paladin(level);
                character.UpdateBaseInfo(1, "Paladin");
                Console.WriteLine("You are a level " + level + " " + races.GetValue(race - 1) + " Paladin!");
                break;

            case 8:
                character = new Ranger(level);
                character.UpdateBaseInfo(1, "Ranger");
                Console.WriteLine("You are a level " + level + " " + races.GetValue(race - 1) + " Ranger!");
                break;

            case 9:
                character = new Rogue(level);
                character.UpdateBaseInfo(1, "Rogue");
                Console.WriteLine("You are a level " + level + " " + races.GetValue(race - 1) + " Rogue!");
                break;

            case 10:
                character = new Sorcerer(level);
                character.UpdateBaseInfo(1, "Sorcerer");
                Console.WriteLine("You are a level " + level + " " + races.GetValue(race - 1) + " Sorcerer!");
                break;

            case 11:
                character = new Wizard(level);
                character.UpdateBaseInfo(1, "Wizard");
                Console.WriteLine("You are a level " + level + " " + races.GetValue(race - 1) + " Wizard!");
                break;

            default:
                Console.WriteLine("Seems like I've encountered a problem. Try again!");
                break;
            }// Switch Case

            character.UpdateBaseInfo(3, level.ToString());

            Console.WriteLine("\n----------------------------------------");
            Console.WriteLine("How do you want to create your statistics? \n1- Generate it randomly\n2- Insert my own numbers\n");

            do
            {
                try
                {
                    level = Convert.ToInt32(Console.ReadLine()); // Level is now useless, so I will reuse it
                }
                catch (FormatException)
                {
                    Console.WriteLine("It seems like you tried to insert one or more letters instead of an integer. You can't do that!");
                    Console.WriteLine();
                }
                catch (OverflowException)
                {
                    Console.WriteLine("It seems like something went wrong. Try contacting the developer, but he won't know much more.");
                    Console.WriteLine();
                }
                finally
                {
                    if (level > 0 && level < 3)
                    {
                        res = 1;
                        Console.WriteLine("Nice! We will now proceed!\n");
                    }
                    else
                    {
                        Console.WriteLine("There was a problem selecting your input. Please, try again.");
                    }
                }
            }while (res == 0);

            if (level == 1)
            {
                for (int i = 0; i < stats.Length; i++)
                {
                    // Rolling 4 dices
                    int[] roll = new int[4];
                    roll[0] = dice.Roll(6);
                    roll[1] = dice.Roll(6);
                    roll[2] = dice.Roll(6);
                    roll[3] = dice.Roll(6);

                    // Removing the lowest value
                    int numToRemove = roll.Min();
                    int numIndex    = Array.IndexOf(roll, numToRemove);
                    roll = roll.Where((val, idx) => idx != numIndex).ToArray();

                    // Calculating stat value
                    int value = roll.Sum();

                    // Adding stat value
                    Console.WriteLine("\n---------------------------------");
                    Console.WriteLine("Your " + stats[i] + " is " + value + ".");
                    character.ChangeBaseStat(stats[i], value);
                }// For Cycle
            }
            else if (level == 2)
            {
                character.InsertBaseStat();
            }

            // Implementing the race
            Races.RndChoice(character, race);

            // Generating HP
            Console.WriteLine("\n---------------------------------");
            character.HPrnd();

            // Managing additional feats
            feat = character.GetBonusFeat();
            FeatsManager featManager = new FeatsManager();

            for (int i = 0; i < feat; i++)
            {
                string name = featManager.RandomFeat();
                character.AddFeat(name);
            }

            Console.WriteLine("\n---------------------------------");
            Console.WriteLine("Those are your feats!\n");
            character.PrintTalents();

            Console.WriteLine("\n---------------------------------");
            Console.WriteLine("Spells!");
            character.PrintCastableSpells();


            return(character);
        }
        public static CharacterCombat Generate()
        {
            int      chosenClass = 0;
            int      level       = 0;
            int      res         = 0;
            int      feat        = 0;
            dynamic  character   = new CharacterCombat();
            DiceRoll dice        = new DiceRoll();

            int[] rolledStats = new int[6];

            //Starting by choosing the class
            Console.WriteLine("Welcome to the Guided Generation! My name is... well, I don't have a name, but it's fine anyway!");
            Console.WriteLine("Now I will walk you through che creation of a new D&D character! Now, where did i put.....");
            Console.WriteLine("...");
            Console.WriteLine("Yes, found it. First, I need to know what class you want to be. Classes are what specialize you, and we have a lot of them!.");
            Console.WriteLine("Do you want to be a mighty Paladin? We got it! A wise Wizard? Check. A sneaky Rogue? Just don't try to steal my code...");
            Console.WriteLine("Now now, let's start. We have those classes avaibles, so pick carefully:\n1- Barbarian\n2- Bard\n3- Cleric\n4- Druid\n5- Fighter\n6- Monk\n7- Paladin\n8- Ranger\n9- Rogue\n10- Sorcerer\n11- Wizard\nYour choice is: ");
            do
            {
                try
                {
                    chosenClass = Convert.ToInt32(Console.ReadLine());
                }
                catch (FormatException)
                {
                    Console.WriteLine("It seems like you tried to insert one or more letters instead of an integer. You can't do that!");
                    Console.WriteLine();
                }
                catch (OverflowException)
                {
                    Console.WriteLine("It seems like something went wrong. Try contacting the developer, but he won't know much more.");
                    Console.WriteLine();
                }
                finally
                {
                    if (chosenClass > 0 && chosenClass < 12)
                    {
                        res = 1;
                        Console.WriteLine("Ah, that is an amazing class! Now I will need to ask you a few more questions..");
                    }
                    else
                    {
                        Console.WriteLine("There was a problem selecting your class. Please, try again.");
                    }
                }
            } // Class
            while (res == 0);

            // Level choice
            Console.WriteLine("\n----------------------------------------");
            res = 0;
            Console.WriteLine("Enter your character level! You can select any level from 1 to 5!");
            do
            {
                try
                {
                    level = Convert.ToInt32(Console.ReadLine());
                }
                catch (FormatException)
                {
                    Console.WriteLine("It seems like you tried to insert one or more letters instead of an integer. You can't do that!");
                    Console.WriteLine();
                }
                catch (OverflowException)
                {
                    Console.WriteLine("It seems like something went wrong. Try contacting the developer, but he won't know much more.");
                    Console.WriteLine();
                }
                finally
                {
                    if (level > 0 && level < 6)
                    {
                        res = 1;
                        Console.WriteLine("Nice! We will now proceed!\n");
                    }
                    else
                    {
                        Console.WriteLine("There was a problem selecting your Level. Please, try again.");
                    }
                }
            } // Level
            while (res == 0);

            //Updating the base class CharacterCombat to the proper selected class
            switch (chosenClass)
            {
            case 1:
                character = new Barbarian(level);
                character.UpdateBaseInfo(1, "Barbarian");
                character.UpdateBaseInfo(3, level.ToString());
                break;

            case 2:
                character = new Bard(level);
                character.UpdateBaseInfo(1, "Bard");
                character.UpdateBaseInfo(3, level.ToString());
                break;

            case 3:
                character = new Cleric(level);
                character.UpdateBaseInfo(1, "Cleric");
                character.UpdateBaseInfo(3, level.ToString());
                break;

            case 4:
                character = new Druid(level);
                character.UpdateBaseInfo(1, "Druid");
                character.UpdateBaseInfo(3, level.ToString());
                break;

            case 5:
                character = new Fighter(level);
                character.UpdateBaseInfo(1, "Fighter");
                character.UpdateBaseInfo(3, level.ToString());
                break;

            case 6:
                character = new Monk(level);
                character.UpdateBaseInfo(1, "Monk");
                character.UpdateBaseInfo(3, level.ToString());
                break;

            case 7:
                character = new Paladin(level);
                character.UpdateBaseInfo(1, "Paladin");
                character.UpdateBaseInfo(3, level.ToString());
                break;

            case 8:
                character = new Ranger(level);
                character.UpdateBaseInfo(1, "Ranger");
                character.UpdateBaseInfo(3, level.ToString());
                break;

            case 9:
                character = new Rogue(level);
                character.UpdateBaseInfo(1, "Rogue");
                character.UpdateBaseInfo(3, level.ToString());
                break;

            case 10:
                character = new Sorcerer(level);
                character.UpdateBaseInfo(1, "Sorcerer");
                character.UpdateBaseInfo(3, level.ToString());
                break;

            case 11:
                character = new Wizard(level);
                character.UpdateBaseInfo(1, "Wizard");
                character.UpdateBaseInfo(3, level.ToString());
                break;

            default:
                Console.WriteLine("Seems like I've encountered a problem. Try again!");
                break;
            }// Switch Case

            //Base Statistics Insertion
            Console.WriteLine("\n----------------------------------------");
            Console.WriteLine("How do you want to insert your statistics? \n1- Generate random numbers for me to insert\n2- Insert my own numbers\n");

            res = 0;
            do
            {
                try
                {
                    level = Convert.ToInt32(Console.ReadLine()); // Level is now useless, so I will reuse it
                }
                catch (FormatException)
                {
                    Console.WriteLine("It seems like you tried to insert one or more letters instead of an integer. You can't do that!");
                    Console.WriteLine();
                }
                catch (OverflowException)
                {
                    Console.WriteLine("It seems like something went wrong. Try contacting the developer, but he won't know much more.");
                    Console.WriteLine();
                }
                finally
                {
                    if (level > 0 && level < 3)
                    {
                        res = 1;
                        Console.WriteLine("Nice! We will now proceed!\n");
                    }
                    else
                    {
                        Console.WriteLine("There was a problem selecting your input. Please, try again.");
                    }
                }
            } // Level
            while (res == 0);

            if (level == 1)
            {
                for (int i = 0; i < 6; i++)
                {
                    // Rolling 4 dices
                    int[] roll = new int[4];
                    roll[0] = dice.Roll(6);
                    roll[1] = dice.Roll(6);
                    roll[2] = dice.Roll(6);
                    roll[3] = dice.Roll(6);

                    // Removing the lowest value
                    int numToRemove = roll.Min();
                    int numIndex    = Array.IndexOf(roll, numToRemove);
                    roll = roll.Where((val, idx) => idx != numIndex).ToArray();

                    rolledStats[i] = roll.Sum();
                }// For Cycle

                Console.WriteLine("Those are your stats to allocate!\n");
                foreach (int item in rolledStats)
                {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                character.InsertBaseStat();
            }
            else if (level == 2)
            {
                character.InsertBaseStat();
            }


            //Race choice
            Console.WriteLine("\n----------------------------------------");
            Races.Choice(character);

            //Hp update
            Console.WriteLine("\n----------------------------------------");
            character.HPInfo();


            //Feats managing
            int          featsNumber = character.GetBonusFeat();
            FeatsManager featList    = new FeatsManager();

            for (int i = 0; i < character.GetBonusFeat(); i++)
            {
                Console.WriteLine("\n----------------------------------------");
                Console.WriteLine("Current Feat(s): ");
                character.PrintTalents();
                res = 0;
                Console.WriteLine("\n----------------------------------------");
                Console.WriteLine("\n" + featsNumber + " feat(s) remaining.");
                Console.WriteLine("You can now: \n1- Search your feat\n2- Insert your feat\n3- Print the feat list\nYour choice: ");
                do
                {
                    try
                    {
                        feat = Convert.ToInt32(Console.ReadLine());
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("It seems like you tried to insert one or more letters instead of an integer. You can't do that!");
                        Console.WriteLine();
                    }
                    catch (OverflowException)
                    {
                        Console.WriteLine("It seems like something went wrong. Try contacting the developer, but he won't know much more.");
                        Console.WriteLine();
                    }
                    finally
                    {
                        if (feat > 0 && feat < 4)
                        {
                            res = 1;
                        }
                    }
                } // Feat
                while (res == 0);

                if (feat == 1)
                {
                    Console.WriteLine("Searching feat: ");
                    featList.SearchFeat(Console.ReadLine());
                    featList.PrintInfo();
                    featList.PrintReq();
                    featList.PrintBonus();
                }
                else if (feat == 2)
                {
                    Console.WriteLine("Ok, I will now let you add the feat! Be sure to write it properly, as this part of the program doesn't have a validation... yet.");
                    character.AddFeat(Console.ReadLine());
                    featsNumber--;
                }
                else
                {
                    featList.PrintList();
                }
            }// For Cycle
            Console.WriteLine("Total Feat(s)!");
            character.PrintTalents();

            // Print Spells
            Console.WriteLine("\n----------------------------------------");
            Console.WriteLine("Spells!");
            character.PrintCastableSpells();

            return(character);
        }
Exemplo n.º 4
0
        }// Combine

        public static void Choice(CharacterCombat character)
        {
            int res = 0;

            Console.WriteLine("Please, select a race. We currently have those:");
            Console.WriteLine("\n1- Dwarf\n2- Elf\n3- Gnome\n4- Half Elf\n5- Halfling\n6- Half Orc\n7- Human\nYour choice is: ");
            do
            {
                int race = 0;
                try
                {
                    race = Convert.ToInt32(Console.ReadLine());
                }
                catch (FormatException)
                {
                    Console.WriteLine("It seems like you tried to insert one or more letters instead of an integer. You can't do that!");
                    Console.WriteLine();
                }
                catch (OverflowException)
                {
                    Console.WriteLine("It seems like something went wrong. Try contacting the developer, but he won't know much more.");
                    Console.WriteLine();
                }
                finally
                {
                    if (race < 1 || race > 7)
                    {
                        Console.WriteLine("Seems like your choice is invalid. Please, try again.");
                    }
                    else
                    {
                        res = 1;
                        switch (race)
                        {
                        case 1:
                            Console.WriteLine("Ah, so you choose Dwarf. A fine choice my friend, the programmer is very pleased.");
                            Races.Combine(character, "Dwarf");
                            break;

                        case 2:
                            Console.WriteLine("Uhm, it seems like you went for Elf. Oh well, I can't really say no, but I mean..");
                            Races.Combine(character, "Elf");
                            break;

                        case 3:
                            Console.WriteLine("Gnome. Not quite a Dwarf, but almost!");
                            Races.Combine(character, "Gnome");
                            break;

                        case 4:
                            Console.WriteLine("Half Elf. You are only half as bad as an Elf, so I can allow it.");
                            Races.Combine(character, "HalfElf");
                            break;

                        case 5:
                            Console.WriteLine("Ehy there you cute little fellas! Halfling it is then!");
                            Races.Combine(character, "Halfling");
                            break;

                        case 6:
                            Console.WriteLine("Half the Strength of a Human, half the Intelligence of an Orc! Or was it the other way around..?");
                            Races.Combine(character, "HalfOrc");
                            break;

                        case 7:
                            Console.WriteLine("So you went for the basic, Human! Nothing bad with that, I mean they are kinda overpowered.");
                            Races.Combine(character, "Human");
                            break;

                        default:
                            Console.WriteLine("I don't know how you got there, but that should really happen.. Try again maybe?");
                            res = 0;
                            break;
                        }
                    }
                } // Try Catch
            }     // Do
            while (res == 0);
        }         // Choice