Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Testing Monsters");
            Elf Nareth     = new Elf("Nareth", elfLvl, 28);
            Orc Brothnagar = new Orc("Broth'nagar", orcLvl, 8);

            Console.WriteLine("Elf " + Nareth.Name + " starting level: " + Nareth.Level);
            Console.WriteLine("Orc " + Brothnagar.Name + " starting level: " + Brothnagar.Level);
            Console.WriteLine();
            Console.WriteLine("Elf " + Nareth.Name + " starting health: " + Nareth.Health);
            Console.WriteLine("Orc " + Brothnagar.Name + " starting health: " + Brothnagar.Health);
            Console.WriteLine();

            while (Nareth.Health >= 0 && Brothnagar.Health >= 0)
            {
                if (Nareth.Health > 0)
                {
                    Brothnagar.TakeDamage(Nareth.Attack(Brothnagar.Armor));

                    Console.WriteLine("Nareth attacked Broth'Nagar for " + Nareth.Damage + " damage.");
                    Console.WriteLine("Broth'nagar's health: " + Brothnagar.Health + ", Nareth's health: " + Nareth.Health);
                    Console.WriteLine();
                }
                if (Brothnagar.Health > 0)
                {
                    Nareth.TakeDamage(Brothnagar.Attack(Nareth.Armor));

                    Console.WriteLine("Broth'Nagar attacked Nareth for " + Brothnagar.Damage + " damage.");
                    Console.WriteLine("Broth'nagar's health: " + Brothnagar.Health + ", Nareth's health: " + Nareth.Health);
                    Console.WriteLine();
                }
            }

            if (Nareth.Health <= 0)
            {
                Console.WriteLine("Brothnagar won!");
            }
            else if (Brothnagar.Health <= 0)
            {
                Console.WriteLine("Nareth won!");
            }
        }
Esempio n. 2
0
        static void Main()
        {
            Elf legolas = new Elf("legolas", 10);
            Orc ugluk   = new Orc("ugluk", 8);

            Console.WriteLine("The Orc's Health:" + ugluk.Health.ToString());
            Console.WriteLine("The Elf's Health:" + legolas.Health.ToString());

            /*for (ugluk.Health && legolas.Health; ugluk.Health && legolas.Health > 0; IAttacker<>.Battle())
             * {
             *  Console.WriteLine("The ugluk's Health:" + Orc.Health.ToString());
             *  Console.WriteLine("The legolas's Health:" + Elf.Health.ToString());
             * }*/

            while (legolas.Health > 0 && ugluk.Health > 0)
            {
                ugluk.TakeDamage(legolas.Attack(ugluk.Armor));
                legolas.TakeDamage(ugluk.Attack(legolas.Armor));
                Console.WriteLine("The Orc's Health:" + ugluk.Health.ToString());
                Console.WriteLine("The Elf's Health:" + legolas.Health.ToString());
            }

            if (ugluk.Health < 0)
            {
                Console.WriteLine("legolas wins!");
            }

            else if (legolas.Health < 0)
            {
                Console.WriteLine("ugluk wins!");
            }
            else
            {
                Console.WriteLine("error");
            }
        }