public void CreateCharacter()
        {
            Console.WriteLine($"\n What type of character would you like to create \n (1) Super Hero \n (2) Vilan");

            do
            {
                input = Console.ReadLine();
                if (ValidationLogic.CheckDegit(input))
                {
                    input1 = ValidationLogic.ConvertValue(input);
                    if (input1 == 1)
                    {
                        AddCharacter(superHero);
                        break;
                    }
                    else if (input1 == 2)
                    {
                        AddCharacter(vilan);
                        break;
                    }
                    else
                    {
                        ValidationLogic.InvalidOption();
                    }
                }
                else
                {
                    ValidationLogic.InvalidIpnut();
                }
            } while (true);
        }
        public static SuperPower AcceptPowers()
        {
            SuperPower superPower = new SuperPower();

            Console.WriteLine("Enter super power");
            superPower.Power = Console.ReadLine();
            Console.WriteLine("Enter power impact");
            superPower.Impact = ValidationLogic.ConvertValue(Console.ReadLine());
            return(superPower);
        }
Example #3
0
        public void GetFigthers(List <Character> fighter, List <Character> challenger)
        {
            Console.WriteLine($"\n Select your fight to with from the following :");
            ListCharacters(fighter);
            do
            {
                input = ReadLines();
                if (ValidationLogic.CheckDegit(input))
                {
                    input1 = ValidationLogic.ConvertValue(input);
                    if (!(fighter.Find(x => x.Id == input1) == null))
                    {
                        fighterId = input1;
                        Console.WriteLine($"\n Select Oponent from the following To fight with");
                        ListCharacters(challenger);

                        break;
                    }
                    else
                    {
                        ValidationLogic.InvalidOption();
                    }
                }
                //ValidationLogic.InvalidIpnut();
            } while (true);
            //after selecting fighter and oponent

            do
            {
                input = ReadLines();
                if (ValidationLogic.CheckDegit(input))
                {
                    input1 = ValidationLogic.ConvertValue(input);
                    if (!(challenger.Find(x => x.Id == input1) == null))
                    {
                        challengerId = input1;
                        //now fight can begit
                        if (GetStrenght(fighterId, fighter) < GetStrenght(challengerId, challenger))
                        {
                            Console.WriteLine("\n ---------------------------Game Over-----------------------------------------------------------------\n" +
                                              "Sorry you lost yuor challenger was more powerfull than you");
                            break;
                        }
                        else
                        {
                            Console.WriteLine($"\n ---------------------------Game Over-----------------------------------------------------------------\n " +
                                              $"Congratulations you won!!!!!!!!!!!!");
                            break;
                        }
                    }
                }
            } while (true);
        }
Example #4
0
        public void Start()
        {
            Console.WriteLine($"Who would you like to be \n (1) Vilan \n (2) SuperHero");
            do
            {
                input = Console.ReadLine();
                if (input.All(Char.IsDigit))
                {
                    input1 = ValidationLogic.ConvertValue(input);
                    break;
                }
                ValidationLogic.InvalidIpnut();
            } while (true);

            if (input1 == 1)
            {
                GetFigthers(Vilans1, Heros1);
            }
            else if (input1 == 2)
            {
                GetFigthers(Heros1, Vilans1);
            }
        }
        public void AddCharacter(Character character)
        {
            Console.WriteLine("Enter character name");
            character.Name = Console.ReadLine();
            Console.WriteLine("Eneter Health rarting from between 1 and 100");
            do
            {
                input = Console.ReadLine();
                if (ValidationLogic.CheckDegit(input))
                {
                    input1 = ValidationLogic.ConvertValue(input);
                    if (input1 > 0 && input1 <= 100)
                    {
                        character.Health = input1;
                        break;
                    }
                    else
                    {
                        ValidationLogic.InvalidIpnut();
                    }
                }
                ValidationLogic.InvalidIpnut();
            } while (true);


            Console.WriteLine("Eneter ability rarting from between 1 and 100");
            input = Console.ReadLine();
            if (input.All(Char.IsDigit))
            {
                int.TryParse(input, out input1);
                if (input1 > 0 && input1 <= 100)
                {
                    character.Ability = input1;
                }
            }

            Console.WriteLine("Eneter strength rarting from between 1 and 100");
            input = Console.ReadLine();
            if (input.All(Char.IsDigit))
            {
                int.TryParse(input, out input1);
                if (input1 > 0 && input1 <= 100)
                {
                    character.Strenght = input1;
                }
            }

            Console.WriteLine("Eneter 1 to add super power and 2 to finish");
            input  = Console.ReadLine();
            input1 = ValidationLogic.ConvertValue(input);
            while (input1 != 2)
            {
                character.SuperPowers.Add(SuperPowrLogic.AcceptPowers());
                input1 = ValidationLogic.ConvertValue(Console.ReadLine());
            }

            if (ValidationLogic.CheckDegit(input))
            {
                input1 = ValidationLogic.ConvertValue(input);
                if (input1 >= 0 && input1 <= 100)
                {
                    character.Strenght = input1;
                }
            }
            Console.WriteLine($"\n Character created.....\n Overall Power : {character.CalcImpact()} \n Attack Power : {character.CalcImpact()}" +
                              $"\n Defence Power : {character.Defend()} \n  Super Powers :");
            character.DisplayPowers();
            character.TotalImpact = character.CalcImpact();
            characters.Add(character);
        }