Beispiel #1
0
        static void Main(string[] args)
        {
            IOutputService message = new ConsoleOutput();
            message.WelcomeMessage();

            IPlayer playerOne = new Player();
            IPlayer playerTwo = new Player();

            IRegistrationService reg = new CharacterRegistration();
            reg.Register(playerOne);
            Console.Clear();
            reg.Register(playerTwo);
            Console.Clear();

            message.GetPlayerInfo(playerOne);
            message.GetPlayerInfo(playerTwo);

            Console.ReadLine();
            Console.Clear();

            /*ICombatService combat = new CombatLogic();
            combat.Battle(playerOne, playerTwo);*/

            Console.ReadLine();
        }
        public void Register(IPlayer character)
        {
            IOutputService message = new ConsoleOutput();

              character.CharacterName = message.NamePrompt();

              character.Health = 100;
              character.SelectAction = ActionSelection.Attack;

              IEquipmentFactory weaponFactory = new WeaponFactory();
              IEquipment weapon = null;

              weapon = weaponFactory.CreateEquipment();
              if (weapon != null)
              {
            character.WeaponName = weapon.EquipmentName;
            character.WeaponValue = message.AddEnchantment(weapon)
                                       .EquipmentValue;
              }

              IEquipmentFactory armorFactory = new ArmorFactory();
              IEquipment armor = null;

              armor = armorFactory.CreateEquipment();

              if (armor != null)
              {
            character.ArmorName = armor.EquipmentName;
            character.ArmorValue = message.AddEnchantment(armor)
                                      .EquipmentValue;
              }
        }
        public void Battle(IPlayer player1, IPlayer player2)
        {
            Random ran = new Random();
            ConsoleOutput message = new ConsoleOutput();

            bool turn = message.CoinTossInfo();
            while (player1.Health > 0 && player2.Health > 0)
            {

                if (turn)
                {
                    Console.Write(String.Format(ApplicationSettings.ActionChoose, player1.CharacterName));
                    if ((ActionSelection)Enum.Parse(typeof(ActionSelection),
                                                   Console.ReadLine(),
                                                   true)
                                                   == ActionSelection.Attack)
                    {
                        player1.SelectAction = ActionSelection.Attack;
                    }
                    else
                    {
                        player1.SelectAction = ActionSelection.Defend;
                    }
                    ActionRound(player1, player2);
                }
                else
                {
                    Console.Write(String.Format(ApplicationSettings.ActionChoose, player2.CharacterName));
                    if ((ActionSelection)Enum.Parse(typeof(ActionSelection),
                                                  Console.ReadLine(),
                                                  true)
                                                  == ActionSelection.Attack)
                    {
                        player2.SelectAction = ActionSelection.Attack;
                    }
                    else
                    {
                        player2.SelectAction = ActionSelection.Defend;
                    }
                    ActionRound(player2, player1);
                }
                turn = !turn;
                if (player1.Health < 0)
                {
                    player1.Health = 0;
                }
                if (player2.Health < 0)
                {
                    player2.Health = 0;
                }
                message.BattleInfo(player1, player2);
            }
            message.CheckWinner(player1, player2);
        }
        public IEquipment CreateEquipment()
        {
            IOutputService message = new ConsoleOutput();
              IEquipment weapon = null;

              string optionWeap = message.WeaponPrompt();
              Selection selectWeap = (Selection)Enum.Parse(typeof(Selection),
                               optionWeap, true);

              switch (selectWeap)
              {
            case Selection.A:
            {
              weapon = new Knife();
              break;
            }

            case Selection.B:
            {
              weapon = new Sword();
              break;
            }

            case Selection.C:
            {
              weapon = new Blade();
              break;
            }

            case Selection.D:
            {
              weapon = new Katana();
              break;
            }
              }
              return weapon;
        }
        public void Register(IPlayer character)
        {
            IOutputService message = new ConsoleOutput();

            character.CharacterName = message.NamePrompt();


            character.Health       = 100;
            character.SelectAction = ActionSelection.Attack;

            IEquipment weapon = null;

            string    optionWeap = message.WeaponPrompt();
            Selection selectWeap = (Selection)Enum.Parse(typeof(Selection),
                                                         optionWeap, true);

            switch (selectWeap)
            {
            case Selection.A:
            {
                weapon = new Knife();
                break;
            }

            case Selection.B:
            {
                weapon = new Sword();
                break;
            }

            case Selection.C:
            {
                weapon = new Blade();
                break;
            }

            case Selection.D:
            {
                weapon = new Katana();
                break;
            }
            }
            if (weapon != null)
            {
                character.WeaponName  = weapon.EquipmentName;
                character.WeaponValue = message.AddEnchantment(weapon).EquipmentValue;
            }

            string    optionArm = message.ArmorPrompt();
            Selection selectArm = (Selection)Enum.Parse(typeof(Selection),
                                                        optionArm, true);

            IEquipment armor = null;

            switch (selectArm)
            {
            case Selection.A:
            {
                armor = new Guard();
                break;
            }

            case Selection.B:
            {
                armor = new Buckler();
                break;
            }

            case Selection.C:
            {
                armor = new Shield();
                break;
            }

            case Selection.D:
            {
                armor = new ThornShield();
                break;
            }
            }
            if (armor != null)
            {
                character.ArmorName  = armor.EquipmentName;
                character.ArmorValue = message.AddEnchantment(armor).EquipmentValue;
            }
        }
Beispiel #6
0
        public void Battle(IPlayer player1, IPlayer player2)
        {
            Random        ran     = new Random();
            ConsoleOutput message = new ConsoleOutput();

            bool turn = message.CoinTossInfo();

            while (player1.Health > 0 && player2.Health > 0)
            {
                if (turn)
                {
                    Console.Write(String.Format(ApplicationSettings.ActionChoose,
                                                player1.CharacterName));

                    if ((ActionSelection)Enum.Parse(typeof(ActionSelection),
                                                    Console.ReadLine(),
                                                    true)
                        == ActionSelection.Attack)
                    {
                        player1.SelectAction = ActionSelection.Attack;
                    }

                    else
                    {
                        player1.SelectAction = ActionSelection.Defend;
                    }
                    ActionRound(player1, player2);
                }
                else
                {
                    Console.Write(String.Format(ApplicationSettings.ActionChoose,
                                                player2.CharacterName));
                    if ((ActionSelection)Enum.Parse(typeof(ActionSelection),
                                                    Console.ReadLine(),
                                                    true)
                        == ActionSelection.Attack)
                    {
                        player2.SelectAction = ActionSelection.Attack;
                    }

                    else
                    {
                        player2.SelectAction = ActionSelection.Defend;
                    }

                    ActionRound(player2, player1);
                }
                turn = !turn;
                if (player1.Health < 0)
                {
                    player1.Health = 0;
                }

                if (player2.Health < 0)
                {
                    player2.Health = 0;
                }

                message.BattleInfo(player1, player2);
            }

            message.CheckWinner(player1, player2);
        }
        public void Register(IPlayer character)
        {
            IOutputService message = new ConsoleOutput();

            character.CharacterName = message.NamePrompt();

            character.Health = 100;
            character.SelectAction = ActionSelection.Attack;

            IEquipment weapon = null;

            string optionWeap = message.WeaponPrompt();
            Selection selectWeap = (Selection)Enum.Parse(typeof(Selection),
                                   optionWeap, true);

            switch (selectWeap)
            {
                case Selection.A:
                    {
                        weapon = new Knife();
                        break;
                    }
                case Selection.B:
                    {
                        weapon = new Sword();
                        break;
                    }
                case Selection.C:
                    {
                        weapon = new Blade();
                        break;
                    }
                case Selection.D:
                    {
                        weapon = new Katana();
                        break;
                    }
            }
            if (weapon != null)
            {
                character.WeaponName = weapon.EquipmentName;
                character.WeaponValue = message.AddEnchantment(weapon).EquipmentValue;
            }

            string optionArm = message.ArmorPrompt();
            Selection selectArm = (Selection)Enum.Parse(typeof(Selection),
                                  optionArm, true);

            IEquipment armor = null;

            switch (selectArm)
            {
                case Selection.A:
                    {
                        armor = new Guard();
                        break;
                    }
                case Selection.B:
                    {
                        armor = new Buckler();
                        break;
                    }
                case Selection.C:
                    {
                        armor = new Shield();
                        break;
                    }
                case Selection.D:
                    {
                        armor = new ThornShield();
                        break;
                    }
            }
            if (armor != null)
            {
                character.ArmorName = armor.EquipmentName;
                character.ArmorValue = message.AddEnchantment(armor).EquipmentValue;
            }
        }