Пример #1
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  = Attacker.attackCalc();
                int defenseValue = Defender.defenseCalc();

                round += 1; // Short version of: round = round + 1

                Console.WriteLine("\n ~~~~Round {0}~~~~", round);

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

                    Console.WriteLine("{0} ****Attacks for {1}****", Attacker.Name, attackValue);

                    // Defenders defense

                    Console.WriteLine("{0}: I'm going strong, my health is at {1}!", Defender.Name, Defender.Health);
                    Console.WriteLine("{0} ****Defends for {1}****", Defender.Name, defenseValue);

                    // Calculations

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

                    Console.WriteLine("{0}: I've been hit, my health has been depleated to {1}!", Defender.Name, Defender.Health);

                    Console.WriteLine("\n\n ~~~~SWITCHING TURNS~~~~ \n\n");

                    // Switching roles:
                    tempHoke = Attacker;
                    Attacker = Defender;
                    Defender = tempHoke;
                }
            }

            if (Attacker.Health > Defender.Health)
            {
                Console.WriteLine("{0} Wins this battle!", Attacker.Name);
            }
            else
            {
                Console.WriteLine("{0} Wins this battle!", Defender.Name);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello welcome to Hokeworld home of the Hokemon!");

            // Instantiation 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);
        }
Пример #3
0
 public void requestAChallenger(Hokemon requestor)
 {
     Console.WriteLine("{0}: says 'I want a challenger!!!'", requestor.Name);
 }
Пример #4
0
        public void theBattle(Hokemon attacker, Hokemon defender)
        {
            int     round        = 0;
            int     attackValue  = 0;
            int     defenceValue = 0;
            Hokemon tempHoke;

            Console.WriteLine("{0}: waits...", attacker.Name);
            System.Threading.Thread.Sleep(2000); // Wait statement for 2 seconds
            Console.WriteLine("{0}: and waits...", attacker.Name);
            System.Threading.Thread.Sleep(1000); // Wait statement for 2 seconds
            Console.WriteLine("{0}: 'I accept the challenge!!", 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)
            {
                round       += 1;
                attackValue  = attacker.attackCalculator();
                defenceValue = defender.defenceCalculator();

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

                for (int i = 0; i < 2; i++)
                {
                    System.Threading.Thread.Sleep(2000); // Wait statement for 2 seconds

                    Console.WriteLine("{0}: Prepares for an attack ...", attacker.Name);
                    System.Threading.Thread.Sleep(1000); // Wait statement for 2 seconds
                    Console.WriteLine("{0}: Attack value: {1}...\n\n", attacker.Name, attackValue);
                    System.Threading.Thread.Sleep(2000); // Wait statement for 2 seconds
                    Console.WriteLine("{0}: 'Swiftly moves and creates a Defence value of: {1}", defender.Name, defenceValue);
                    System.Threading.Thread.Sleep(2000); // Wait statement for 2 seconds
                    Console.WriteLine("{0}: Takes damage (HEALTH {1} + Defence {2}) = {3} - Attack {4}\n", defender.Name, defender.Health, defenceValue, (defender.Health + defenceValue), attackValue);
                    defender.Health = (defender.Health + defenceValue) - attackValue;
                    Console.WriteLine("{0}: New HEALTH value: {1} ", defender.Name, ((defender.Health + defenceValue) - attackValue));

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

                    // Example of how OBJECTS can be switched identifier names
                    // This saves on having to repeat code
                    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);  // Produces a LOGICAL error - why??
            }
            else
            {
                Console.WriteLine("{0}: WINS", defender.Name);  // Produces a LOGICAL error - why??
            }
        }
Пример #5
0
 public void AcceptABattle(Hokemon contender1, Hokemon contender2)
 {
     Console.WriteLine("{0}: Who dares question my power, I'll take you on {1}!! ", contender2.Name, contender1.Name);
     System.Threading.Thread.Sleep(2000);
     Console.WriteLine("{1}: Great {0}, lets start a BATTLE!!!", contender2.Name, contender1.Name);
 }
Пример #6
0
 public void RequestAChallenger(Hokemon contender)
 {
     Console.WriteLine("{0}: I want to battle... who wants it? ", contender.Name);
 }