示例#1
0
        public void theBattle(Hokemon attacker, Hokemon defender)
        {
            Console.WriteLine("{0}; is waiting ..........", attacker.getname());
            System.Threading.Thread.Sleep(1000);
            Console.WriteLine("{0}; is waiting ..........", attacker.getname());
            System.Threading.Thread.Sleep(1000);
            Console.WriteLine("{0} has accepted the challenge", defender.getname());
            attacker.get_details();
            defender.get_details();

            while (Convert.ToInt32(defender.Health) > 0 && Convert.ToInt32(attacker.Health) > 0)
            {
                Console.WriteLine("round: {0}", round);
                int attackValue  = 0;
                int defenceValue = 0;
                for (int i = 1; i < 2; i++)
                {
                    attackValue = attacker.Attack_generator();

                    defenceValue = defender.Defence_generator();

                    Console.WriteLine("{0} generated an attack of {1}", attacker.Name, attackValue);
                    Console.WriteLine("{0} generated a defense of {1}", defender.Name, defenceValue);
                    if ((attackValue - defenceValue) > 0)
                    {
                        defender.Health = defender.Health - (attackValue - defenceValue);
                    }
                    Console.WriteLine("{0} has {1} health remaning \n{2} has {3} health remaining", attacker.Name, attacker.Health, defender.Name, defender.Health);
                    System.Threading.Thread.Sleep(2000);
                }
                round = round + 1;
                Console.WriteLine("turn has ended ad the roles will switch");
                temphoke = attacker;
                attacker = defender;
                defender = temphoke;
                System.Threading.Thread.Sleep(2000);
                Console.WriteLine("press enter to proceed to round {0}", round);
                Console.ReadLine();
            }

            if (attacker.Health > defender.Health)
            {
                winner       = attacker;
                loser        = defender;
                winner.Score = winner.Score + 1;
            }
            else
            {
                winner       = defender;
                loser        = attacker;
                winner.Score = winner.Score + 1;
            }

            /*if (attacker.Health > defender.Health)
             * {
             *   winner = attacker;
             *   loser = defender;
             *   public Hokemon Winner
             *      {
             *          get { return winner; }
             *          set
             *          {
             *              winner = value;
             *          }
             *      }
             *  public Hokemon Loser
             *      {
             *          get { return loser; }
             *          set
             *          {
             *              loser = value;
             *          }
             *      }
             * }
             * else
             * {
             *  Hokemon winner = defender;
             *  Hokemon loser = attacker;
             *  public Hokemon Winner
             *  {
             *      get { return winner; }
             *      set
             *      {
             *          winner = value;
             *      }
             *  }
             *  public Hokemon Loser
             *  {
             *      get { return loser; }
             *      set
             *      {
             *          loser = value;
             *      }
             *  }
             *
             * }*/
        }
示例#2
0
        static void Main(string[] args)
        {
            //declaring the veriables
            Hokemon[]   ChallengerArray = new Hokemon[3]; //creates an array of 3 hokemon
            BattleArena newBattleObject = new BattleArena();

            Hokemon temp;
            Random  rnd        = new Random();
            Boolean repeatGame = true;
            String  Result;

            Console.WriteLine("Welcome to Hokeworld, home of the Hokemon");

            Halor player = new Halor();

            for (int i = 0; i < 3; i++)
            {
                ChallengerArray[i] = new Hokemon();
            }
            while (repeatGame == true)
            {
                BattleArena.Round = 1;
                Console.WriteLine("{0} extended a challenger for a battle.", player.Name);

                temp = ChallengerArray[rnd.Next(0, ChallengerArray.Length)];
                if ((temp.Health) > 0)
                {
                    if ((player.Health) > 0)
                    {
                        //player.get_details();
                        //temp.get_details();
                        newBattleObject.theBattle(player, temp);
                    }
                    else
                    {
                        Console.WriteLine("{0} Does not have enough health to battle.", player.Name);
                    }
                }
                else
                {
                    Console.WriteLine("{0} Does not have enough health to battle.", temp.Name);
                }
                if ((player.Health) > 0)
                {
                    Console.WriteLine("Do you want annother battle?");
                    Result = Console.ReadLine();
                    if ((Result.ToLower())[0] == 'n')
                    {
                        repeatGame = false;
                    }
                }
                else
                {
                    Console.WriteLine("{0} has taken too much damage and cannot battle again", player.Name);
                    repeatGame = false;
                }
            }
            Console.ReadLine();

            /* Console.WriteLine("welcome to hokeworld home of the hokemon");
             *   //instantiating a new object
             * Hokemon hoke01 = new Hokemon();
             *
             * Console.WriteLine("the name is {0}",hoke01.getname());
             *
             * hoke01.get_details();
             *
             * Console.WriteLine("//////////////////////////////////////");
             * Hokemon hoke02 = new Hokemon();
             * Console.WriteLine("the name is {0}", hoke02.getname());
             *
             * hoke02.get_details();
             * Console.WriteLine("//////////////////////////////////////");
             * Hokemon hoke03 = new Hokemon();
             *
             * Console.WriteLine("the name is {0}", hoke03.getname());
             *
             * hoke03.get_details();
             *
             * Console.WriteLine("//////////////////////////////////////");
             * Halor hoke04 = new Halor();
             *
             * Console.WriteLine("the name is {0}", hoke04.getname());
             *
             * hoke04.get_details();
             * hoke04.definition();
             * //Console.WriteLine("Team: {0}", hoke04.team);
             * Console.WriteLine("//////////////////////////////////////");
             * Console.ReadLine();
             *
             * BattleArena newbattleobject = new BattleArena();
             * newbattleobject.requestAchallenger(hoke01);
             *
             * newbattleobject.theBattle(hoke01, hoke02);
             * //Console.WriteLine("{0} has defeated {1} and won the battle", Winner, Loser);
             * Console.ReadLine();*/
        }
示例#3
0
 public void requestAchallenger(Hokemon requestor)
 {
     Console.WriteLine("{0}: wants a challenger", requestor.getname());
 }