Пример #1
0
        public static void UseArmorKit(Player player, string[] userInput)
        {
            int kitIndex = player.Inventory.FindIndex(f => f.Name.Contains(userInput[2]));

            if (kitIndex == -1)
            {
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatFailureOutputText(),
                    Settings.FormatDefaultBackground(),
                    "What armor kit did you want to use?");
                return;
            }
            int armorIndex = player.Inventory.FindIndex(f =>
                                                        f.Name.Contains(userInput[1].ToLower()));

            if (armorIndex == -1)
            {
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatFailureOutputText(),
                    Settings.FormatDefaultBackground(),
                    "What armor did you want to upgrade?");
                return;
            }
            Armor    armor     = player.Inventory[armorIndex] as Armor;
            TextInfo textInfo  = new CultureInfo("en-US", false).TextInfo;
            string   armorName = textInfo.ToTitleCase(armor.Name);

            if (!armor.Equipped)
            {
                bool inputValid = false;
                while (!inputValid)
                {
                    string armorString = $"{armorName} is not equipped. Are you sure you want to upgrade that?";
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatFailureOutputText(),
                        Settings.FormatDefaultBackground(),
                        armorString);
                    OutputHelper.Display.BuildUserOutput();
                    OutputHelper.Display.ClearUserOutput();
                    string[] input = InputHelper.GetFormattedInput(Console.ReadLine());
                    if (input[0] == "no" || input[0] == "n")
                    {
                        return;
                    }

                    if (input[0] == "yes" || input[0] == "y")
                    {
                        inputValid = true;
                    }
                }
            }

            ArmorKit armorKit = player.Inventory[kitIndex] as ArmorKit;

            armorKit.AttemptAugmentArmorPlayer(armor);

            if (armorKit.KitHasBeenUsed)
            {
                player.Inventory.RemoveAt(kitIndex);
            }
        }
Пример #2
0
        public static void LevelUpCheck(Player player)
        {
            if (player.Experience < player.ExperienceToLevel || player.Level == 10)
            {
                return;
            }

            foreach (IEffect effect in player.Effects.ToList())
            {
                effect.IsEffectExpired = true;
            }

            player.Level++;
            player.Experience       -= player.ExperienceToLevel;
            player.ExperienceToLevel = Settings.GetBaseExperienceToLevel() * player.Level;
            string levelUpString = $"You have leveled! You are now level {player.Level}.";

            OutputHelper.Display.StoreUserOutput(
                Settings.FormatLevelUpText(),
                Settings.FormatDefaultBackground(),
                levelUpString);
            int statsToAssign = 5;

            while (statsToAssign > 0)
            {
                string       levelUpStatString = $"Please choose {statsToAssign} stats to raise. Your choices are: str, dex, int, const.";
                const string levelUpStatInfo   =
                    "You may raise a stat more than once by putting a number after the stat, IE str 2.";
                const string levelUpStatStr = "Str will increase your max carrying weight and warrior abilities.";
                const string levelUpStatDex = "Dex will increase your dodge chance and archer abilities";
                const string levelUpStatInt =
                    "Int will increase your mana and decrease your training cost for spells and abilities.";
                const string levelUpStatConst = "Const will increase your max hit points.";
                DisplayPlayerStats(player);
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatAnnounceText(),
                    Settings.FormatDefaultBackground(),
                    levelUpStatString);
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatAnnounceText(),
                    Settings.FormatDefaultBackground(),
                    levelUpStatInfo);
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatAnnounceText(),
                    Settings.FormatDefaultBackground(),
                    levelUpStatStr);
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatAnnounceText(),
                    Settings.FormatDefaultBackground(),
                    levelUpStatDex);
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatAnnounceText(),
                    Settings.FormatDefaultBackground(),
                    levelUpStatInt);
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatAnnounceText(),
                    Settings.FormatDefaultBackground(),
                    levelUpStatConst);
                OutputHelper.Display.RetrieveUserOutput();
                OutputHelper.Display.ClearUserOutput();
                int statNumber = 0;
                try {
                    string[] input = InputHelper.GetFormattedInput(Console.ReadLine());
                    if (input.Length > 1)
                    {
                        if (GameHelper.IsWholeNumber(input[1]) == false)
                        {
                            continue;
                        }

                        statNumber = Convert.ToInt32(input[1]);
                    }
                    switch (input[0])
                    {
                    case "str":
                        if (statNumber > 0 && statNumber <= statsToAssign)
                        {
                            player.Strength += statNumber;
                            statsToAssign   -= statNumber;
                        }
                        else
                        {
                            player.Strength++;
                            statsToAssign--;
                        }
                        break;

                    case "dex":
                        if (statNumber > 0 && statNumber <= statsToAssign)
                        {
                            player.Dexterity += statNumber;
                            statsToAssign    -= statNumber;
                        }
                        else
                        {
                            player.Dexterity++;
                            statsToAssign--;
                        }
                        break;

                    case "int":
                        if (statNumber > 0 && statNumber <= statsToAssign)
                        {
                            player.Intelligence += statNumber;
                            statsToAssign       -= statNumber;
                        }
                        else
                        {
                            player.Intelligence++;
                            statsToAssign--;
                        }
                        break;

                    case "const":
                        if (statNumber > 0 && statNumber <= statsToAssign)
                        {
                            player.Constitution += statNumber;
                            statsToAssign       -= statNumber;
                        }
                        else
                        {
                            player.Constitution++;
                            statsToAssign--;
                        }
                        break;
                    }
                } catch (IndexOutOfRangeException) {
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatAnnounceText(),
                        Settings.FormatDefaultBackground(),
                        "You did not select an appropriate stat!");
                }
            }
            OutputHelper.Display.StoreUserOutput(
                Settings.FormatAnnounceText(),
                Settings.FormatDefaultBackground(),
                "All stats have been assigned!");
            player.FireResistance   += 5;
            player.FrostResistance  += 5;
            player.ArcaneResistance += 5;
            CalculatePlayerStats(player);
            // Leveling sets player back to max stats
            player.HitPoints   = player.MaxHitPoints;
            player.RagePoints  = player.MaxRagePoints;
            player.ComboPoints = player.MaxComboPoints;
            player.ManaPoints  = player.MaxManaPoints;
            // Update level for rainbow gear if any in player inventory
            foreach (IItem item in player.Inventory)
            {
                if (item is Armor || item is Weapon)
                {
                    IRainbowGear rainbowItem = (IRainbowGear)item;
                    if (rainbowItem != null && rainbowItem.IsRainbowGear)
                    {
                        rainbowItem.UpdateRainbowStats(player);
                    }
                }
            }
        }
Пример #3
0
        public static void UseWeaponKit(Player player, string[] userInput)
        {
            int kitIndex = player.Inventory.FindIndex(f => f.Name.Contains(userInput[2]));

            if (kitIndex == -1)
            {
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatFailureOutputText(),
                    Settings.FormatDefaultBackground(),
                    "What weapon kit did you want to use?");
                return;
            }
            int weaponIndex = player.Inventory.FindIndex(f =>
                                                         f.Name.Contains(userInput[1].ToLower()));

            if (weaponIndex == -1)
            {
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatFailureOutputText(),
                    Settings.FormatDefaultBackground(),
                    "What weapon did you want to upgrade?");
                return;
            }
            Weapon   weapon     = player.Inventory[weaponIndex] as Weapon;
            TextInfo textInfo   = new CultureInfo("en-US", false).TextInfo;
            string   weaponName = textInfo.ToTitleCase(weapon.Name);

            if (!weapon.Equipped)
            {
                bool inputValid = false;
                while (!inputValid)
                {
                    string weaponString = $"{weaponName} is not equipped. Are you sure you want to upgrade that?";
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatFailureOutputText(),
                        Settings.FormatDefaultBackground(),
                        weaponString);
                    OutputHelper.Display.RetrieveUserOutput();
                    OutputHelper.Display.ClearUserOutput();
                    string[] input = InputHelper.GetFormattedInput(Console.ReadLine());
                    if (input[0] == "no" || input[0] == "n")
                    {
                        return;
                    }

                    if (input[0] == "yes" || input[0] == "y")
                    {
                        inputValid = true;
                    }
                }
            }

            WeaponKit weaponKit = player.Inventory[kitIndex] as WeaponKit;

            weaponKit.AttemptAugmentPlayerWeapon(weapon);

            if (weaponKit.KitHasBeenUsed)
            {
                player.Inventory.RemoveAt(kitIndex);
            }
        }
Пример #4
0
        public static void StartCombat(Player player, Monster monster)
        {
            Console.Clear();

            string fightStartString = $"{player.Name}, you have encountered a {monster.Name}. Time to fight!";

            OutputHelper.Display.StoreUserOutput(
                Settings.FormatSuccessOutputText(),
                Settings.FormatDefaultBackground(),
                fightStartString);

            while (monster.HitPoints > 0 && player.HitPoints > 0 &&
                   player.InCombat && monster.InCombat)
            {
                GameHelper.RemovedExpiredEffectsAsync(player);
                GameHelper.RemovedExpiredEffectsAsync(monster);

                bool isInputValid = false;
                // Get input and check to see if input is valid, and if not, keep trying to get input from user
                while (!isInputValid)
                {
                    // Show initial output that announces start of fight
                    OutputHelper.ShowUserOutput(player, monster);
                    OutputHelper.Display.ClearUserOutput();
                    // Player will attack, use ability, cast spells, etc. to cause damage
                    _input = InputHelper.GetFormattedInput(Console.ReadLine());
                    Console.Clear();
                    isInputValid = ProcessPlayerInput(player, monster);
                }

                if (player.Effects.Any())
                {
                    ProcessPlayerEffects(player);
                }

                if (_fleeSuccess)
                {
                    return;
                }

                // Check to see if player attack killed monster
                if (monster.HitPoints <= 0)
                {
                    monster.MonsterDeath(player);
                    return;
                }

                if (monster.Effects.Any())
                {
                    ProcessOpponentEffects(monster);
                }

                // Check to see if damage over time effects killed monster
                if (monster.HitPoints <= 0)
                {
                    monster.MonsterDeath(player);
                    return;
                }

                if (monster.IsStunned)
                {
                    continue;
                }

                monster.Attack(player);

                // Check at end of round to see if monster was killed by combat round
                if (monster.HitPoints > 0)
                {
                    continue;
                }

                monster.MonsterDeath(player);

                return;
            }
        }