Ejemplo n.º 1
0
        static void Main()
        {
            //instance of class BoostingMethod
            BoostingMethod boostMethod = new BoostingMethod();

            //condition to keep menu open or return to game
            while (true)
            {
                Console.WriteLine("You enter a game-battle with an option to receive a temporary boost now or save it, how do you proceed? type: " +
                                  "\n 'boost' to access boost menu ('saveit' to return right back to battle) ");
                string input = Console.ReadLine();
                if (input == "saveit")
                {
                    break;
                }

                boostMethod.SetBoost(input);

                Console.WriteLine("Do you want to temporarily boost your player's 'Health', 'Damage', or 'Shield'?");
                string player = Console.ReadLine();

                //namespace used to collect data from user input based on template for data in the abstract/sub classes
                Type p = Type.GetType("BoostStrategy." + player);
                try
                {
                    PlayerBoost pBoost = (PlayerBoost)Activator.CreateInstance(p);
                    boostMethod.SetPlayerBoost(pBoost);
                    boostMethod.Boost();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                Console.WriteLine(" = = = = = = = = ");
            }
        }
Ejemplo n.º 2
0
 public void SetPlayerBoost(PlayerBoost elixerBoost)
 {
     this._playerBoost = elixerBoost;
 }