Exemplo n.º 1
0
        public void Attack(Baddie target, Player attacker)
        {
            bool battle = true;

            do
            {
                Console.WriteLine("\n{0} has performed an attack against {1}!", attacker.Name, target.Name);
                target.HealthPoints -= attacker.AttackPower;
                Console.WriteLine(target.Name + "'s health is now " + target.HealthPoints);

                if (target.HealthPoints <= 0)
                {
                    target.Die();
                    battle = false;
                }
                else if (attacker.HealthPoints <= 0)
                {
                    attacker.Die();
                    battle = false;
                }
                else
                {
                    attacker.HealthPoints -= target.AttackPower;
                    Console.WriteLine("\n{0} strikes back against {1}!", target.Name, Name);
                    Console.WriteLine("{0}'s health is now {1}", attacker.Name, attacker.HealthPoints);
                    battle = false;
                }
            } while (battle);
        }
Exemplo n.º 2
0
 public static void Combat(Player player, Baddie baddie)
 {
     player.Attack(baddie, player);
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var hero          = new Player();
            var villain       = new Baddie();
            var superVillain  = new Baddie();
            int currentHealth = hero.HealthPoints;

            Title();
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("Press ENTER to continue");
            Console.ReadKey();
            Console.Clear();
            Console.WriteLine("As you enter the dark and frigid emptiness of the dungeon you feel your soul wretch. The air is bare...and the walls so molded you sense it in your flesh. Beware what wanders here.");
            Console.ReadKey();
            Console.Clear();
            bool running = true;

            while (running)
            {
                villain.HealthPoints = 100;
                Console.Clear();
                Console.WriteLine("=== What Next Brave Wanderer? ===");
                Console.WriteLine("m to move");
                Console.WriteLine("x to escape the hell hole");
                string picker = Console.ReadLine();
                switch (picker)
                {
                case "m":
                    hero.Move();
                    Console.ReadKey();
                    break;

                case "x":
                    Environment.Exit(0);
                    break;

                default:
                    Console.WriteLine("Fool...");
                    Console.ReadKey();
                    break;
                }
                if (hero.Movement >= 30)
                {
                    hero.Movement = 5;
                    Console.WriteLine("An enemy approaches!");
                    Console.ReadKey();
                    while (villain.HealthPoints > 0)
                    {
                        Console.Clear();
                        Console.WriteLine($"Hero HP: {hero.HealthPoints}");
                        Console.WriteLine($"Villain HP: {villain.HealthPoints}");
                        Console.WriteLine("***************");
                        Console.WriteLine("a to attack");
                        Console.WriteLine("r to flee");
                        string choice = Console.ReadLine();
                        switch (choice)
                        {
                        case "a":
                            Combat(hero, villain);
                            Console.ReadKey();
                            break;

                        case "r":
                            villain.HealthPoints = 0;
                            Console.WriteLine("You got away safely.");
                            Console.ReadKey();
                            break;
                        }
                    }
                }
            }
        }