Пример #1
0
        /// <summary>
        /// Simulates a fight between the player and the boss using the specified upgrades.
        /// </summary>
        /// <param name="weapon">The weapon to purchase.</param>
        /// <param name="armor">The armor to purchase, if any.</param>
        /// <param name="rings">The rings to purchase, if any.</param>
        /// <returns>
        /// A <see cref="Tuple{T1, T2}"/> that returns whether the human player won and the amount of gold spent.
        /// </returns>
        internal static Tuple<bool, int> Fight(string weapon, string armor, ICollection<string> rings)
        {
            Shop shop = new Shop();
            Human human = new Human();

            int goldSpent = human.Upgrade(shop.PurchaseWeapon(weapon));

            if (!string.IsNullOrEmpty(armor))
            {
                goldSpent += human.Upgrade(shop.PurchaseArmor(armor));
            }

            foreach (string ring in rings.Distinct().Take(2))
            {
                goldSpent += human.Upgrade(shop.PurchaseRing(ring));
            }

            Boss boss = new Boss();

            Player winner = Fight(human, boss);

            return Tuple.Create(winner == human, goldSpent);
        }