Пример #1
0
        public void InitializeGame()
        {
            AddToMonsters();
            Console.WriteLine("Please name your hero. (in 1 word)");
            var playerName = Console.ReadLine();

            while (playerName == "" || playerName.Contains(" "))
            {
                if (playerName.Contains(" "))
                {
                    Console.WriteLine("NO SPACES please.");
                }
                else
                {
                    Console.WriteLine("No name?! That's sad...");
                }
                playerName = Console.ReadLine();
            }

            int fixedHp = int.Parse(ConfigurationManager.AppSettings.Get("FixedOriginalHealth"));

            CreateHero(playerName, 0, 0, fixedHp, this);
            Console.WriteLine("---------------------");
            Console.WriteLine("Monsters are randomly chosen for you per match.");
            Console.WriteLine("Docile monsters don't attack you first; Aggressive monsters do!!");
            Console.WriteLine("You may choose to fight a boss monster when you have more than 500 coins in your possession. All bosses are aggressive.");
            Console.WriteLine("You may quit the game by closing this console window, however, all your accomplishments will be lost once you quit.");
            Console.WriteLine("In order to equip, you require coins of the item's price.");
            Console.WriteLine("You must choose a weapon and an armor right before each battle.");
            Console.WriteLine("As far as your coin amount allows, it's better if you equip the strongest weapon and armor.");
            Console.WriteLine("Follow the instructions or press any key to continue.");
            Console.WriteLine("GOOD LUCK!!");
            Console.WriteLine("---------------------");
            Console.WriteLine("");
            Console.ReadKey();
            Console.WriteLine($"Welcome { Hero.Name }!!");
            Console.WriteLine("---------------------");
            Hero.ShowStats();
            Hero.ShowInventory();
            Console.WriteLine("");
            Console.ReadKey();
        }
Пример #2
0
        public void MainMenu()
        {
            HashSet <string> flowNum = new HashSet <string> {
                "1", "2", "3", "4", "5"
            };

            Console.WriteLine(" ========== ");
            Console.WriteLine("What would you like to do?");
            Console.WriteLine("1 = show current status  /  2 = show inventory again  /  3 = equip weapon  /  4 = equip armor  /  5 = everything's done");
            string choice = ChooseNext(flowNum);

            while (!flowNum.Contains(choice))
            {
                Console.WriteLine("Choose the right number and press ENTER.");
                Console.WriteLine("");
                choice = ChooseNext(flowNum);
            }

            while (choice != "5" && flowNum.Contains(choice))
            {
                switch (choice)
                {
                case "1":
                    Hero.ShowStats();
                    break;

                case "2":
                    Hero.ShowInventory();
                    break;

                case "3":
                    Hero.EquipWeapon();
                    break;

                case "4":
                    Hero.EquipArmor();
                    break;
                }

                Console.WriteLine("");
                Console.WriteLine(" ========== ");
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("1 = show current status  /  2 = show inventory again  /  3 = equip weapon  /  4 = equip armor  /  5 = everything's done");
                choice = ChooseNext(flowNum);
            }

            if (choice == "5")
            {
                if (Hero.EquippedWeapon == null || Hero.EquippedArmor == null)
                {
                    if (Hero.EquippedWeapon == null && Hero.EquippedArmor == null)
                    {
                        Console.WriteLine("You're bare naked with no weapons!!");
                        Hero.EquipWeapon();
                        Hero.EquipArmor();
                    }

                    if (Hero.EquippedWeapon == null)
                    {
                        Hero.EquipWeapon();
                    }

                    if (Hero.EquippedArmor == null)
                    {
                        Hero.EquipArmor();
                    }
                }
            }

            Console.WriteLine("");
            Console.WriteLine($"{ Hero.Name } - let's fight!!");
            Console.WriteLine("---------------------");
            Console.WriteLine("");
        }
Пример #3
0
        public void InFight()
        {
            int turn = 1;

            Console.WriteLine($"You've been matched with { Monster.Name }! HP: { Monster.OriginalHealth }");
            Console.WriteLine($"{ Monster.Name } has { Monster.Defense } defense capability, and");
            Console.WriteLine($"{ Hero.Name } has { Hero.Strength } attack power.");
            Console.WriteLine("If your attack power is equal or less than your target's defense,");
            Console.WriteLine("Then your damage will be 0.");
            Console.WriteLine($"Defeat { Monster.Name } and get { Monster.Prize } coins!!");
            Console.WriteLine("");
            Console.WriteLine("****** Begin Fight ******");

            while (Hero.CurrentHealth > 0 && Monster.CurrentHealth > 0)
            {
                if (Monster.Type == MonsterType.docile)
                {
                    if (turn % 2 != 0)
                    {
                        EachHit(Hero, Monster);
                    }
                    else
                    {
                        EachHit(Monster, Monster);
                    }
                }
                else
                {
                    if (turn % 2 != 0)
                    {
                        EachHit(Monster, Monster);
                    }
                    else
                    {
                        EachHit(Hero, Monster);
                    }
                }

                Console.WriteLine($"{ Hero.Name } HP: { (Hero.CurrentHealth > 0 ? Hero.CurrentHealth : 0) }   |   { Monster.Name } HP: { (Monster.CurrentHealth > 0 ? Monster.CurrentHealth : 0) }");
                Console.WriteLine("---------------------");
                Console.WriteLine("<press any key to continue>");
                Console.WriteLine("");

                if (Monster.Type == MonsterType.boss &&
                    Hero.CurrentHealth < 30 &&
                    Hero.Coins >= 100 &&
                    Monster.CurrentHealth > 0)
                {
                    HealAgainstBoss();
                }

                turn++;
                Console.ReadKey();
            }

            if (Hero.CurrentHealth <= 0)
            {
                Hero.Losts++;
                Console.WriteLine($"{ Hero.Name } lost battle to { Monster.Name }. You've earned 0 coins.");
            }
            else if (Monster.CurrentHealth <= 0)
            {
                Hero.Wins++;
                Hero.Coins += Monster.Prize;
                Console.WriteLine($"{ Hero.Name } won against { Monster.Name }! You've earned { Monster.Prize } coins.");
            }

            Console.WriteLine("");
            Console.WriteLine($"Current Status of { Hero.Name } is as follows: ");
            Console.WriteLine(" ------------ ");
            Hero.ShowStats();
            Console.WriteLine(" ------------ ");
            Console.WriteLine("");
            HealthRefill();
        }