Esempio n. 1
0
        public void theBattle(Hokemon attacker, Hokemon defender)
        {
            int     roundNum   = 0;
            int     attackNum  = 0;
            int     defenceNum = 0;
            Hokemon tempHoke;

            Console.WriteLine("{0}: waits...", attacker.name);
            System.Threading.Thread.Sleep(2000);
            Console.WriteLine("{0}: and waits...", attacker.name);
            System.Threading.Thread.Sleep(1000);
            Console.WriteLine("{0}: 'I Accept The Challenger!!!'", defender.name);

            Console.WriteLine("--- Contender Stats ---");
            attacker.get_details();
            defender.get_details();

            Console.WriteLine("--- BATTLE BEGINS ---\n");

            while (Convert.ToInt32(defender.health) >= 0 || Convert.ToInt32(attacker.health) >= 0)
            {
                roundNum   = roundNum + 1;
                attackNum  = attacker.attackCalculator();
                defenceNum = defender.defenceCalculator();

                Console.WriteLine("---Round{0}---\n\n", roundNum);

                for (int i = 0; i < 2; i++)
                {
                    System.Threading.Thread.Sleep(2000);
                    Console.WriteLine("{0}: prepares to attack...", attacker.Name);
                    System.Threading.Thread.Sleep(1000);
                    Console.WriteLine("{0}: attacks for:{1}...\n\n", attacker.Name, attackNum);
                    System.Threading.Thread.Sleep(1000);
                    Console.WriteLine("{0}: prepares for the attack and build up its defence value to: {1}", defender.Name, defenceNum);
                    System.Threading.Thread.Sleep(1000);
                    Console.WriteLine("{0}: was hurt for (HEALTH {1} + DEFENCE {2}) = {3} - ATTACK {4}\n", defender.Name, defender.health, defenceNum, (defender.health + defenceNum), attackNum);
                    defender.health = (defender.health + defenceNum) - attackNum;
                    Console.WriteLine("{0}: now has {1} health ", defender.Name, ((defender.health + defenceNum) - attackNum));

                    Console.WriteLine("\n-----------------------------\n");

                    Console.WriteLine("\n----\nSwitch turns Defender becomes the Attacker...\n----\n");
                    tempHoke = attacker;
                    attacker = defender;
                    defender = tempHoke;
                }
            }
            if (attacker.health > defender.health)
            {
                Console.WriteLine("{0}: WINS", attacker.Name);
            }
            else
            {
                Console.WriteLine("{0}: WINS", defender.Name);
            }
        }
Esempio n. 2
0
        public void Battle(Hokemon Attacker, Hokemon Defender)
        {
            int attackValue;
            int defenceValue;
            int round = 0;

            Hokemon tempHoke;


            while (Attacker.Health >= 0 || Defender.Health >= 0)
            {
                round += 1;

                Console.WriteLine("\n****** ROUND {0} ******\n\n", round);

                for (int i = 0; i < 2; i++)
                {
                    attackValue  = Attacker.attackCalculator();
                    defenceValue = Defender.defenceCalculator();

                    Console.WriteLine("{0}: Attacks with value: {1}", Attacker.Name, attackValue);

                    Console.WriteLine("{0}: Generates a defence...", Defender.Name);
                    Console.WriteLine("{0}: Defence value {1}\n", Defender.Name, defenceValue);

                    Console.WriteLine("{0}: Defender Health {1}");

                    Defender.Health = (Defender.Health + defenceValue) - attackValue;


                    Console.WriteLine("{0} Defender New Health {1}", Defender.Name, Defender.Health);

                    // Example of how OBJECTS can be switched identifier names
                    // This saves having ot repeat code

                    Console.WriteLine("\n***Switch turns: Defender becomes the attacker***\n\n");

                    tempHoke = Attacker;
                    Attacker = Defender;
                    Defender = tempHoke;
                }
            }

            if (Attacker.Health > Defender.Health)
            {
                Console.WriteLine("{0}: WINS", attacker.Name);
            }
            else
            {
                Console.WriteLine("{0}: WINS", defender.Name);
            }
        }
Esempio n. 3
0
        public void Battle(Hokemon Attacker, Hokemon Defender) // Passing in two PARAMETERS
                                                               // two Hokemon for the Battle
        {
            Hokemon tempHoke;
            int     round = 0;

            while (Convert.ToInt32(Attacker.Health) >= 0 || Convert.ToInt32(Defender.Health) >= 0)
            {
                int attackValue  = Attacker.attackCalculator();
                int defenceValue = Defender.defenceCalculator();

                round += 1; // Alternate to statement round = round + 1

                Console.WriteLine("\n******** ROUND {0} ********\n", round);

                for (int i = 0; i < 2; i++)
                {
                    // Attacker attacks

                    Console.WriteLine("{0}: Attacks with value {1} ", Attacker.Name, attackValue);

                    // Defenders defence

                    Console.WriteLine("{0}: Defends with Value {1}", Defender.Name, defenceValue);

                    Console.WriteLine("{0}: health = {1}", Defender.Name, Defender.Health);

                    // Calculate the impact of the Attach on defenders health

                    Defender.Health = (Defender.Health + defenceValue) - attackValue;

                    Console.WriteLine("{0}: New health value = {1} // Calc: {1} + {2} - {3}", Defender.Name, Defender.Health, defenceValue, attackValue);

                    // IMPORTANT part of the Battle
                    Console.WriteLine("\n\n*** SWITCHING TURNS - Attacker now the Defender ***\n");

                    tempHoke = Attacker; // tempHoke is assigned the attacker object
                    Attacker = Defender;
                    Defender = tempHoke;
                }
            }

            if (Attacker.Health > Defender.Health)
            {
                Console.WriteLine("{0} WINS", Attacker.Name);
            }
            else
            {
                Console.WriteLine("{0} WINS", Defender.Name);
            }
        }
Esempio n. 4
0
        public void Battle(Hokemon Attacker, Hokemon Defender)
        {
            int     attackValue;
            int     defenceValue;
            int     round = 0;
            Hokemon tempHoke;

            while (Attacker.Health >= 0 && Defender.Health >= 0)
            {
                for (int i = 0; i < 2; i++)
                {
                    round += 1; // This is the same as round = round + 1
                    Console.WriteLine("\n\nROUND {0}\n\n", round);

                    attackValue  = Attacker.attackCalculator();
                    defenceValue = Defender.defenceCalculator();

                    Console.WriteLine("{0}: Attacks with value {1}", Attacker.Name, attackValue);

                    Console.WriteLine("\n{0}: Generates a defence...", Defender.Name);
                    Console.WriteLine("\n{0}: Defends with value {1}", Defender.Name, defenceValue);
                    Console.WriteLine("\n{0}: Health is {1}", Defender.Name, Defender.Health);

                    Console.WriteLine("\nCalculation: (Health {0} + Defence {1}) - Attack {2}", Defender.Health, defenceValue, attackValue);
                    Defender.Health = (Defender.Health + defenceValue) - attackValue;

                    Console.WriteLine("\n{0}: Health changed to {1}", Defender.Name, Defender.Health);

                    Console.WriteLine("\nSwitch turns: Defender becomes the attacker...");
                    tempHoke = Attacker;
                    Attacker = Defender;
                    Defender = tempHoke;
                }
            }

            if (Attacker.Health > Defender.Health)
            {
                Console.WriteLine("\n{0} wins the battle!", Attacker.Name);
            }
            else
            {
                Console.WriteLine("\n{0} wins the battle!", Defender.Name);
            }
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Welcome to Hokeworld, home of the hokemon!");

            //instanation of new Hokemon


            Hokemon hoke01 = new Hokemon();   // INSTANTIATE new Hokemon object referred to as Hoke01

            hoke01.get_details();
            Console.WriteLine("Attack value is: {0}", hoke01.attackCalculator());
            Console.WriteLine("Defence value is: {0}", hoke01.defenceCalculator());
            Hokemon hoke02 = new Hokemon();   // INSTANTIATE Hoke02

            hoke02.get_details();
            Console.WriteLine("Attack value is: {0}", hoke02.attackCalculator());
            Console.WriteLine("Defence value is: {0}", hoke02.defenceCalculator());

            Hokemon hokemonObject = new Hokemon();   // INSTANTIATE hokemonObject

            hokemonObject.get_details();
            Console.WriteLine("Attack value is: {0}", hokemonObject.attackCalculator());
            Console.WriteLine("Defence value is: {0}", hokemonObject.defenceCalculator());

            Hokemon hoke03 = new Hokemon(); // INSTANTIATE from Hokemon Parent class

            HALOR hoke04 = new HALOR();     // INSTANTIATE from Halor child class

            Console.WriteLine("I am part of {0} team.", hoke04.team);



            Battle_Arena newBattleObject = new Battle_Arena();

            newBattleObject.requestAChallenger(hoke03);  // In newBattleObject passing
                                                         // Hoke02 object as an
                                                         // Argument

            newBattleObject.theBattle(hoke03, hoke04);
        }
Esempio n. 6
0
        public void Battle(Hokemon Attacker, Hokemon Defender)
        {
            Hokemon tempHoke;
            int     round = 0;


            while (Convert.ToInt32(Attacker.Health) >= 0 || Convert.ToInt32(Defender.Health) >= 0)
            {
                int attackValue;
                int defenseValue;

                round = (round + 1);

                Console.WriteLine("************* ROUND {0} *************", round);

                for (int i = 0; i < 2; i++)
                {
                    attackValue  = Attacker.attackCalculator();
                    defenseValue = Defender.defenseCalculator();

                    // Attacker attacks

                    Console.WriteLine("{0}: Attacks with value {1}", Attacker.Name, attackValue);

                    // Defender's defense

                    Console.WriteLine("{0}: Defends with value {1}", Defender.Name, defenseValue);
                    Console.WriteLine("{0}'s health = {1}", Defender.Name, Defender.Health);

                    // calculates impact of attack on defender's health

                    Defender.Health = (Defender.Health + defenseValue) - attackValue;

                    Console.WriteLine("{0}'s new health = {1}", Defender.Name, Defender.Health, attackValue);
                    Console.WriteLine();

                    // switch turns
                    if ((((Attacker.Health > 0) & (Defender.Health > 0))) & (round != 10))
                    {
                        Console.WriteLine("----- SWITCHING TURNS -----");

                        tempHoke = Attacker; // tempHoke assigned to Attacker object
                        Attacker = Defender;
                        Defender = tempHoke;

                        Console.WriteLine();
                    }
                }

                if (Attacker.Health <= 0)
                {
                    if (Defender.Health > Attacker.Health)
                    {
                        Console.WriteLine("{0} WINS!", Defender.Name);
                        Environment.Exit(0);
                    }
                }
                else if (Defender.Health <= 0)
                {
                    if (Attacker.Health > Defender.Health)
                    {
                        Console.WriteLine("{0} WINS!", Attacker.Name);
                        Environment.Exit(0);
                    }
                }

                if (round == 10)
                {
                    if ((Attacker.Health <= 0) || (Defender.Health > Attacker.Health))
                    {
                        Console.WriteLine("END OF BATTLE! {0} WINS!", Defender.Name);
                        Environment.Exit(0);
                    }
                    else if ((Defender.Health <= 0) || (Attacker.Health > Defender.Health))
                    {
                        Console.WriteLine("END OF BATTLE! {0} WINS!", Attacker.Name);
                        Environment.Exit(0);
                    }
                    else
                    {
                        Console.WriteLine("END OF BATTLE! IT'S A TIE!");
                    }
                }

                //if ((Attacker.Health > Defender.Health) || (Defender.Health <= 0))
                //{
                //    Console.WriteLine("{0} WINS!", Attacker.Name);
                //    Environment.Exit(0);
                //}
                //else if ((Defender.Health > Attacker.Health) || (Attacker.Health <= 0))
                //{
                //    Console.WriteLine("{0} WINS!", Defender.Name);
                //    Environment.Exit(0);
                //}
            }
        }