Example #1
0
        private void CharacterVsCharacter(Character avatar1, Character avatar2, bool heroAttacksFirst)
        {
            Random random = new Random();
            short  damage;

            if (!loadingMessageShown)
            {
                loadingMessageShown = true;
                SpecialMessage.LoadingMessage("Selecting who has the first turn (at random)");
                if (heroAttacksFirst)
                {
                    ColorWriter.SpaceWriteLine("Gray", "The Hero attacks first!\n");
                }
                else
                {
                    ColorWriter.SpaceWriteLine("Gray", "The Villain attacks first!\n");
                }
                System.Threading.Thread.Sleep(1000);
            }
            //avatar1 attacks avatar2
            if (avatar2.Health > 0 && avatar1.Health > 0)
            {
                damage = (short)(avatar1.Attack * (random.Next(60, 101) / 100f));
                ColorWriter.SpaceWrite("Cyan", avatar1.Name);
                ColorWriter.SpaceWrite("Gray", "attacks");
                ColorWriter.SpaceWrite("Yellow", avatar2.Name);
                ColorWriter.SpaceWrite("Gray", "and deals");
                ColorWriter.SpaceWrite("Magenta", damage.ToString());
                ColorWriter.SpaceWriteLine("Gray", "points of damage");
                avatar2.Health = (short)(avatar2.Health - damage);
                ColorWriter.Write("Yellow", "\n " + avatar2.Name);
                ColorWriter.SpaceWrite("Gray", "Hp =");
                if (avatar2.Health > 0)
                {
                    ColorWriter.SpaceWriteLine("Green", avatar2.Health + "\n");
                }
                else
                {
                    ColorWriter.SpaceWriteLine("Red", avatar2.Health + "\n");
                }
            }
            if (avatar2.Health <= 0)
            {
                SpecialMessage.DefeatMessage(avatar2.Name + " was defeated!");
            }
            else
            {
                System.Threading.Thread.Sleep(2000);
            }
            //avatar2 attacks avatar1
            if (avatar2.Health > 0 && avatar1.Health > 0)
            {
                damage = (short)(avatar2.Attack * (random.Next(60, 101) / 100f));
                ColorWriter.SpaceWrite("Yellow", avatar2.Name);
                ColorWriter.SpaceWrite("Gray", "attacks");
                ColorWriter.SpaceWrite("Cyan", avatar1.Name);
                ColorWriter.SpaceWrite("Gray", "and deals");
                ColorWriter.SpaceWrite("Magenta", damage.ToString());
                ColorWriter.SpaceWriteLine("Gray", "points of damage");
                avatar1.Health = (short)(avatar1.Health - damage);
                ColorWriter.Write("Cyan", "\n " + avatar1.Name);
                ColorWriter.SpaceWrite("Gray", "Hp =");
                if (avatar1.Health > 0)
                {
                    ColorWriter.SpaceWriteLine("Green", avatar1.Health + "\n");
                }
                else
                {
                    ColorWriter.SpaceWriteLine("Red", avatar1.Health + "\n");
                }
            }
            if (avatar1.Health <= 0)
            {
                SpecialMessage.DefeatMessage(avatar1.Name + " was defeated!");
            }
            else
            {
                System.Threading.Thread.Sleep(2000);
            }
        }
Example #2
0
        public void FightMenu()
        {
            loadingMessageShown = false;
            if (idSelectedPlanet != 0 && idSelectedVillain != 0)
            {
                IdToObject("Planet");
                while (true)
                {
                    Console.Clear();
                    ColorWriter.SpaceWriteLine("Yellow", "Black", "Fight Menu\n");
                    ColorWriter.SpaceWrite("Yellow", "Black", "1");
                    ColorWriter.SpaceWriteLine("Gray", "Villain vs Hero\n");
                    ColorWriter.SpaceWrite("Yellow", "Black", "2");
                    ColorWriter.SpaceWriteLine("Gray", "Villain vs Avengers\n");
                    ColorWriter.SpaceWrite("Yellow", "Select an option: ");
                    byte option     = 0;
                    bool errorGiven = false;
                    try
                    {
                        option = byte.Parse(Console.ReadLine());
                    }
                    catch (Exception)
                    {
                        SpecialMessage.ErrorMessage("Wrong type of value given!\n Expected Byte");
                        errorGiven = true;
                    }
                    switch (option)
                    {
                    case 1:
                        if (idSelectedHero != 0)
                        {
                            FightController(1);
                        }
                        else
                        {
                            SpecialMessage.ErrorMessage("No hero selected!");
                        }
                        goto exit;

                    case 2:
                        if (avengersList.Any())
                        {
                            FightController(2);
                        }
                        else
                        {
                            SpecialMessage.ErrorMessage("Avengers team empty!");
                        }
                        goto exit;

                    default:
                        if (!errorGiven)
                        {
                            SpecialMessage.ErrorMessage("No option of value: " + option + " found!");
                        }
                        break;
                    }
                }
            }
            else
            {
                SpecialMessage.ErrorMessage("Please select a Planet and a Villain!");
            }
            exit :;
            CharacterDeserializer();
            AvengersRejuvenator();
            Console.Clear();
        }
Example #3
0
 private void CharacterNewStats(Character character)
 {
     ColorWriter.SpaceWriteLine("Cyan", character.Name);
     ColorWriter.SpaceWrite("Gray", "\u00BB Attack = " + character.Attack);
     if (character.IsVillain)
     {
         character.Attack = (short)(character.Attack + fightingPlanet.Modifiers.VillainAttackModifier);
         if (fightingPlanet.Modifiers.VillainAttackModifier >= 0)
         {
             ColorWriter.Write("Green", "+" + fightingPlanet.Modifiers.VillainAttackModifier);
         }
         else
         {
             ColorWriter.Write("Red", fightingPlanet.Modifiers.VillainAttackModifier.ToString());
         }
         ColorWriter.Write("Gray", " = ");
     }
     else
     {
         character.Attack = (short)(character.Attack + fightingPlanet.Modifiers.HeroAttackModifier);
         if (fightingPlanet.Modifiers.HeroAttackModifier >= 0)
         {
             ColorWriter.Write("Green", "+" + fightingPlanet.Modifiers.HeroAttackModifier);
         }
         else
         {
             ColorWriter.Write("Red", fightingPlanet.Modifiers.HeroAttackModifier.ToString());
         }
         ColorWriter.Write("Gray", " = ");
     }
     ColorWriter.Write("Magenta", character.Attack.ToString());
     ColorWriter.SpaceWriteLine("Yellow", "(Ap)");
     ColorWriter.SpaceWrite("Gray", "\u00BB Health = " + character.Health);
     if (character.IsVillain)
     {
         character.Health = (short)(character.Health + fightingPlanet.Modifiers.VillainHealthModifier);
         if (fightingPlanet.Modifiers.VillainHealthModifier >= 0)
         {
             ColorWriter.Write("Green", "+" + fightingPlanet.Modifiers.VillainHealthModifier);
         }
         else
         {
             ColorWriter.Write("Red", fightingPlanet.Modifiers.VillainHealthModifier.ToString());
         }
         ColorWriter.Write("Gray", " = ");
     }
     else
     {
         character.Health = (short)(character.Health + fightingPlanet.Modifiers.HeroHealthModifier);
         if (fightingPlanet.Modifiers.HeroHealthModifier >= 0)
         {
             ColorWriter.Write("Green", "+" + fightingPlanet.Modifiers.HeroHealthModifier);
         }
         else
         {
             ColorWriter.Write("Red", fightingPlanet.Modifiers.HeroHealthModifier.ToString());
         }
         ColorWriter.Write("Gray", " = ");
     }
     ColorWriter.Write("Green", character.Health.ToString());
     ColorWriter.SpaceWriteLine("Yellow", "(Hp)");
 }
Example #4
0
        private void OptionSelector(string dataName, bool multiple)
        {
            while (true)
            {
                ColorWriter.SpaceWriteLine("Yellow", "Black", dataName + " Selector\n");
                bool errorGiven = false;
                if (dataName == "Planet")
                {
                    foreach (Planet planet in planets.Planet)
                    {
                        ColorWriter.SpaceWrite("Yellow", "Black", planet.Id.ToString());
                        ColorWriter.SpaceWrite("Cyan", planet.Name + '\n');
                        ColorWriter.SpaceWriteLine("DarkGray", " \u2022 " + planet.Description);
                    }
                }
                else
                {
                    foreach (Character character in characters.Character)
                    {
                        if (character.IsVillain && dataName == "Villain")
                        {
                            ColorWriter.SpaceWrite("Yellow", "Black", character.Id.ToString());
                            ColorWriter.SpaceWrite("Cyan", character.Name + '\n');
                            ColorWriter.SpaceWriteLine("DarkGray", " \u2022 " + character.Description);
                        }
                        if (!character.IsVillain && dataName == "Hero")
                        {
                            ColorWriter.SpaceWrite("Yellow", "Black", character.Id.ToString());
                            ColorWriter.SpaceWrite("Cyan", character.Name + '\n');
                            ColorWriter.SpaceWriteLine("DarkGray", " \u2022 " + character.Description);
                        }
                    }
                }
                ColorWriter.Write("Yellow", "\n Select a " + dataName.ToLower() + " : ");
                byte idSelectedEntity = 0;
                try
                {
                    idSelectedEntity = byte.Parse(Console.ReadLine());
                }
                catch (Exception)
                {
                    SpecialMessage.ErrorMessage("Wrong type of value given!\n Expected Byte");
                    errorGiven = true;
                }
                bool entityFound = false;
                if (dataName == "Planet")
                {
                    foreach (Planet planet in planets.Planet)
                    {
                        if (planet.Id == idSelectedEntity)
                        {
                            entityFound      = true;
                            idSelectedPlanet = idSelectedEntity;
                        }
                    }
                }
                else
                {
                    if (dataName == "Villain")
                    {
                        foreach (Character character in characters.Character)
                        {
                            if (character.Id == idSelectedEntity && character.IsVillain)
                            {
                                entityFound       = true;
                                idSelectedVillain = idSelectedEntity;
                            }
                        }
                    }
                    else
                    {
                        if (dataName == "Hero")
                        {
                            foreach (Character character in characters.Character)
                            {
                                if (character.Id == idSelectedEntity && !character.IsVillain)
                                {
                                    entityFound = true;
                                }
                            }
                        }
                    }
                }
                if (entityFound)
                {
                    while (true)
                    {
                        bool errorGiven2 = false;
                        byte option      = 0;
                        if (dataName == "Planet")
                        {
                            Console.Clear();
                            PlanetDetails();
                        }
                        else
                        {
                            if (dataName == "Villain")
                            {
                                CharacterDetails(idSelectedEntity);
                            }
                            else
                            {
                                if (dataName == "Hero")
                                {
                                    CharacterDetails(idSelectedEntity);
                                }
                            }
                        }
                        ColorWriter.WriteLine("Yellow", "\n Options: \n");
                        ColorWriter.SpaceWrite("Yellow", "Black", "1");
                        if (dataName == "Hero" && multiple)
                        {
                            ColorWriter.SpaceWriteLine("Gray", "Add to the Avengers team\n");
                        }
                        else
                        {
                            ColorWriter.SpaceWriteLine("Gray", "Confirm selected " + dataName.ToLower() + '\n');
                        }
                        ColorWriter.SpaceWrite("Yellow", "Black", "2");
                        ColorWriter.SpaceWriteLine("Gray", "Go back to the selection menu");
                        if (dataName == "Hero" && multiple)
                        {
                            Console.WriteLine();
                            ColorWriter.SpaceWrite("Yellow", "Black", "3");
                            ColorWriter.SpaceWriteLine("Gray", "Show the Avengers team\n");

                            ColorWriter.SpaceWrite("Yellow", "Black", "4");
                            ColorWriter.SpaceWriteLine("Gray", "Clear the Avengers team\n");

                            ColorWriter.SpaceWrite("Yellow", "Black", "5");
                            ColorWriter.SpaceWriteLine("Gray", "Confirm Avengers Team");
                        }
                        ColorWriter.Write("Yellow", "\n Select an option: ");
                        try
                        {
                            option = byte.Parse(Console.ReadLine());
                        }
                        catch (Exception)
                        {
                            SpecialMessage.ErrorMessage("Wrong type of value given!\n Expected Byte!");
                            errorGiven2 = true;
                        }
                        switch (option)
                        {
                        case 1:
                            if (dataName == "Hero" && multiple)
                            {
                                AddHeroToAvengers(idSelectedEntity);
                            }
                            else
                            {
                                if (dataName == "Hero" && !multiple)
                                {
                                    idSelectedHero = idSelectedEntity;
                                }
                                goto mainExit;
                            }
                            break;

                        case 2:
                            Console.Clear();
                            goto localExit;

                        case 3:
                            if (dataName == "Hero" && multiple)
                            {
                                ShowAvengersTeam();
                            }
                            else
                            {
                                goto default;
                            }
                            break;

                        case 4:
                            if (dataName == "Hero" && multiple)
                            {
                                if (avengersList.Any())
                                {
                                    avengersList.Clear();
                                    SpecialMessage.SuccessMessage("The Avengers team was cleared!");
                                }
                                else
                                {
                                    SpecialMessage.ErrorMessage("The Avengers team is already empty!");
                                }
                            }
                            else
                            {
                                goto default;
                            }
                            break;

                        case 5:
                            if (dataName == "Hero" && multiple)
                            {
                                goto mainExit;
                            }
                            else
                            {
                                goto default;
                            }

                        default:
                            if (!errorGiven2)
                            {
                                SpecialMessage.ErrorMessage("No option of value = " + option + " was found");
                            }
                            break;
                        }
                    }
                    localExit :;
                }
                else
                {
                    if (!errorGiven)
                    {
                        SpecialMessage.ErrorMessage("No " + dataName.ToLower() + " of id = " + idSelectedEntity + " was found");
                    }
                }
            }
mainExit:
            Console.Clear();
        }