Exemplo n.º 1
0
        void ChooseSkill(Player player, Enemy randomEnemy)
        {
            Console.Clear();
            Console.WriteLine(border);
            Console.WriteLine("||                SKILLS");
            Console.WriteLine(border);
            for (int i = 0; i < player.GetSkills().Count; i++)
            {
                string sName     = player.GetSkills()[i].GetName();
                string sElement  = player.GetSkills()[i].GetElementText();
                string sLevel    = player.GetSkills()[i].GetLevelText();
                int    sDamage   = player.GetSkills()[i].GetDamage();
                int    sManaCost = player.GetSkills()[i].GetManaCost();
                if (player.GetSkills()[i].GetSkillType() == 3)
                {
                    int sHealAmount = em.GetEffect(player.GetSkills()[i].GetEffectID()).GetHealAmount();
                    Console.WriteLine("|| [{0}] {1}{2} | {3} | Base Heal: {4} | Mana Cost: {5}", i + 1, sName, sLevel, sElement, sHealAmount, sManaCost);
                }
                else
                {
                    Console.WriteLine("|| [{0}] {1}{2} | {3} | Base Damage: {4} | Mana Cost: {5}", i + 1, sName, sLevel, sElement, sDamage, sManaCost);
                }
            }
            Console.WriteLine(border);
            Console.WriteLine("|| Mana: {0}", player.GetMana());
            Console.WriteLine(border);
            Console.WriteLine("|| Choose a Skill by typing the Number of the Skill.");
            Console.WriteLine("|| Or press Enter to return to the Fight");
            Console.WriteLine(border);

            string input = Console.ReadLine();
            int    slot;

            if (input == "")
            {
                StartBattle(player, randomEnemy);
            }
            else
            {
                if (Int32.TryParse(input, out slot))
                {
                    slot = Convert.ToInt32(input);
                }
                else
                {
                    Console.WriteLine("Pls enter a valid number!");
                    Console.ReadLine();
                    ChooseSkill(player, randomEnemy);
                }

                if (slot < 0 || slot > player.GetSkills().Count)
                {
                    Console.WriteLine("Pls enter a valid number!");
                    Console.ReadLine();
                    ChooseSkill(player, randomEnemy);
                }

                if (player.GetSkills()[slot - 1].GetManaCost() > player.GetMana())
                {
                    Console.WriteLine(border);
                    Console.WriteLine("|| Not enough Mana!");
                    Console.WriteLine(border);
                    Console.WriteLine("|| ");
                    Console.WriteLine("|| Press Enter to continue");
                    Console.WriteLine(border);

                    Console.ReadLine();
                    ChooseSkill(player, randomEnemy);
                }
                else
                {
                    if (player.GetSkills()[slot - 1].GetSkillType() == 3)
                    {
                        player.UseSkill(slot - 1);
                        Console.WriteLine(border);
                        Console.WriteLine("|| Press Enter to Continue");
                        Console.ReadLine();
                        ChooseSkill(player, randomEnemy);
                    }
                    else
                    {
                        if (player.GetSpeed() > randomEnemy.GetSpeed())
                        {
                            Attack(player.UseSkill(slot - 1), 1, player.GetSkills()[slot - 1], player, randomEnemy);
                            if (!randomEnemy.IsDead())
                            {
                                EnemyAttack(player, randomEnemy);
                                if (player.IsDead())
                                {
                                    GameOver();
                                }
                            }


                            Console.WriteLine("|| Press Enter to Continue");

                            Console.ReadLine();
                            StartBattle(player, randomEnemy);
                        }
                        else
                        {
                            if (!randomEnemy.IsDead())
                            {
                                EnemyAttack(player, randomEnemy);
                                if (player.IsDead())
                                {
                                    GameOver();
                                }
                            }
                            Attack(player.UseSkill(slot - 1), 1, player.GetSkills()[slot - 1], player, randomEnemy);

                            Console.WriteLine("|| Press Enter to Continue");

                            Console.ReadLine();
                            StartBattle(player, randomEnemy);
                        }
                    }
                }
            }
        }