Example #1
0
        public static void fightHeroAndDragon(Hero me, Dragon oponent)
        {
            // choose 2, 3
            Console.WriteLine("FIGHTING");
            int    round = 0;
            string ara   = "";

            StreamWriter writetext = new StreamWriter("write.txt");

            while (me.isDead() == false && oponent.isDead() == false)
            {
                round += 1;
                // oponent.randAttack();
                me.hitBy(oponent.randAttack());
                oponent.hitBy(me.randAttack());

                Console.WriteLine($"------------------------------- ROUND {round} -------------------------------");

                String meLost     = $"I lost {oponent.randAttack()} lives. \n";
                String meRamining = $"I have remaining {me.getHealth()} lives. \n";

                String oponentLost   = $" Oponent lost {oponent.randAttack()} lives. \n";
                String remainingLost = $"Oponent has remaining {oponent.getHealth()} lives. \n";

                Console.WriteLine(meLost);
                Console.WriteLine(meRamining);

                Console.WriteLine(oponentLost);
                Console.WriteLine(remainingLost);

                ara += meLost;
                ara += meRamining;

                ara += oponentLost;
                ara += remainingLost;


                //  string createText = "Hello and Welcome" + Environment.NewLine;
            }


            ara += "------------------------------------------ \n";

            if (oponent.isDead())
            {
                Console.WriteLine("I won!");
                ara += "I won";
            }
            else
            {
                Console.WriteLine("Oponent won!");
                ara += "Oponent won";
            }


            File.WriteAllText("results.txt", ara);
        }
Example #2
0
        /*-----------------------------------FIGHT BETWEEN DRAGON AND HERO-----------------------------------*/
        // data about the fight will be written in results.txt

        public static void fightHeroAndDragon(Hero me, Dragon oponent)
        {
            // choose 2, 3
            Console.WriteLine("FIGHTING");
            int    round = 0;
            string ara   = "";


            while (me.isDead() == false && oponent.isDead() == false)
            {
                round += 1;
                // oponent.randAttack();
                me.hitBy(oponent.randAttack());
                oponent.hitBy(me.randDefense());

                Console.WriteLine($"------------------------------- ROUND {round} -------------------------------");

                string meLost     = $"I lost {oponent.randAttack()} lives. \n";
                string meRamining = $"I have remaining {me.getHealth()} lives. \n";

                string oponentLost   = $" Oponent lost {me.randDefense()} lives. \n";
                string remainingLost = $"Oponent has remaining {oponent.getHealth()} lives. \n";

                Console.WriteLine(meLost);
                Console.WriteLine(meRamining);

                Console.WriteLine(oponentLost);
                Console.WriteLine(remainingLost);

                ara += meLost;
                ara += meRamining;

                ara += oponentLost;
                ara += remainingLost;
            }


            ara += "------------------------------------------ \n";

            if (oponent.isDead())
            {
                Console.WriteLine("I won!");
                ara += "I won";
            }
            else
            {
                Console.WriteLine("Oponent won!");
                ara += "Oponent won";
            }


            File.WriteAllText("results.txt", ara); // WRITE TO TEXT FILE
        }
Example #3
0
        static bool RealSomeAlive(List <Base> b)
        {
            for (var i = 0; i < b.Count; i++)
            {
                object somebody = convert(b[i]);


                if (somebody is Hero)
                {
                    Hero hra = ((Hero)somebody);
                    if (hra.isDead())
                    {
                        writeResults();
                        Console.WriteLine("Hero is dead.");
                        Console.WriteLine("Dragon is the winner.");
                        return(false);
                    }
                }

                if (somebody is Dragon)
                {
                    Dragon hra = ((Dragon)somebody);
                    if (hra.isDead())
                    {
                        writeResults();
                        Console.WriteLine("Dragon is dead.");
                        Console.WriteLine("Hero is the winner.");
                        return(false);
                    }
                }
            }

            return(true);
        }