예제 #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 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);
            }
        }
예제 #3
0
        public static void AbilityInfo(Player player, string[] input)
        {
            string inputName = InputHelper.ParseInput(input);
            int    index     = player.Abilities.FindIndex(
                f => f.Name == inputName || f.Name.Contains(inputName));
            TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

            if (index != -1 && player.PlayerClass == PlayerClassType.Warrior)
            {
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatInfoText(),
                    Settings.FormatDefaultBackground(),
                    textInfo.ToTitleCase(player.Abilities[index].Name));
                string rankString = $"Rank: {player.Abilities[index].Rank}";
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatInfoText(),
                    Settings.FormatDefaultBackground(),
                    rankString);
                string rageCostString = $"Rage Cost: {player.Abilities[index].RageCost}";
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatInfoText(),
                    Settings.FormatDefaultBackground(),
                    rageCostString);
                switch (player.Abilities[index].WarAbilityCategory)
                {
                case WarriorAbility.Slash:
                    PlayerAbility.OffenseDamageAbilityInfo(player, index);
                    break;

                case WarriorAbility.Rend:
                    PlayerAbility.OffenseDamageAbilityInfo(player, index);
                    break;

                case WarriorAbility.Charge:
                    PlayerAbility.StunAbilityInfo(player, index);
                    break;

                case WarriorAbility.Block:
                    PlayerAbility.DefenseAbilityInfo(player, index);
                    break;

                case WarriorAbility.Berserk:
                    PlayerAbility.BerserkAbilityInfo(player, index);
                    break;

                case WarriorAbility.Disarm:
                    PlayerAbility.DisarmAbilityInfo(player, index);
                    break;

                case WarriorAbility.Bandage:
                    PlayerAbility.BandageAbilityInfo(player, index);
                    break;

                case WarriorAbility.PowerAura:
                    PlayerAbility.PowerAuraAbilityInfo(player, index);
                    break;

                case WarriorAbility.WarCry:
                    PlayerAbility.WarCryAbilityInfo(player, index);
                    break;

                case WarriorAbility.Onslaught:
                    PlayerAbility.OffenseDamageAbilityInfo(player, index);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else if (index != -1 && player.PlayerClass == PlayerClassType.Archer)
            {
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatInfoText(),
                    Settings.FormatDefaultBackground(),
                    textInfo.ToTitleCase(player.Abilities[index].Name));
                string rankString = $"Rank: {player.Abilities[index].Rank}";
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatInfoText(),
                    Settings.FormatDefaultBackground(),
                    rankString);
                string comboCostString = $"Combo Cost: {player.Abilities[index].ComboCost}";
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatInfoText(),
                    Settings.FormatDefaultBackground(),
                    comboCostString);
                switch (player.Abilities[index].ArcAbilityCategory)
                {
                case ArcherAbility.Distance:
                    PlayerAbility.DistanceAbilityInfo(player, index);
                    break;

                case ArcherAbility.Gut:
                    PlayerAbility.OffenseDamageAbilityInfo(player, index);
                    break;

                case ArcherAbility.Precise:
                    PlayerAbility.OffenseDamageAbilityInfo(player, index);
                    break;

                case ArcherAbility.Stun:
                    PlayerAbility.StunAbilityInfo(player, index);
                    break;

                case ArcherAbility.Double:
                    PlayerAbility.OffenseDamageAbilityInfo(player, index);
                    break;

                case ArcherAbility.Wound:
                    PlayerAbility.OffenseDamageAbilityInfo(player, index);
                    break;

                case ArcherAbility.Bandage:
                    PlayerAbility.BandageAbilityInfo(player, index);
                    break;

                case ArcherAbility.SwiftAura:
                    PlayerAbility.SwiftAuraAbilityInfo(player, index);
                    break;

                case ArcherAbility.ImmolatingArrow:
                    PlayerAbility.OffenseDamageAbilityInfo(player, index);
                    break;

                case ArcherAbility.Ambush:
                    PlayerAbility.OffenseDamageAbilityInfo(player, index);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else if (index != -1 && player.PlayerClass == PlayerClassType.Mage)
            {
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatFailureOutputText(),
                    Settings.FormatDefaultBackground(),
                    "You're not a warrior or archer!");
            }
            else
            {
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatFailureOutputText(),
                    Settings.FormatDefaultBackground(),
                    "You don't have that ability.");
            }
        }
예제 #4
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);
                    }
                }
            }
        }
예제 #5
0
        private static bool ProcessPlayerInput(Player player, Monster monster)
        {
            switch (_input[0])
            {
            case "f":
            case "fight":
                int attackDamage = player.PhysicalAttack(monster);
                if (attackDamage - monster.ArmorRating(player) <= 0)
                {
                    string armorAbsorbString = $"The {monster.Name}'s armor absorbed all of your attack!";
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatAttackFailText(),
                        Settings.FormatDefaultBackground(),
                        armorAbsorbString);
                }
                else if (attackDamage == 0)
                {
                    string attackFailString = $"You missed {monster.Name}!";
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatAttackFailText(),
                        Settings.FormatDefaultBackground(),
                        attackFailString);
                }
                else
                {
                    int    attackAmount        = attackDamage - monster.ArmorRating(player);
                    string attackSucceedString = $"You hit the {monster.Name} for {attackAmount} physical damage.";
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatAttackSuccessText(),
                        Settings.FormatDefaultBackground(),
                        attackSucceedString);
                    monster.HitPoints -= attackAmount;
                }
                break;

            case "cast":
                try {
                    if (_input[1] != null)
                    {
                        string spellName = InputHelper.ParseInput(_input);
                        player.CastSpell(monster, spellName);
                    }
                } catch (IndexOutOfRangeException) {
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatFailureOutputText(),
                        Settings.FormatDefaultBackground(),
                        "You don't have that spell.");
                    return(false);
                } catch (NullReferenceException) {
                    if (player.PlayerClass != PlayerClassType.Mage)
                    {
                        OutputHelper.Display.StoreUserOutput(
                            Settings.FormatFailureOutputText(),
                            Settings.FormatDefaultBackground(),
                            "You can't cast spells. You're not a mage!");
                        return(false);
                    }
                } catch (InvalidOperationException) {
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatFailureOutputText(),
                        Settings.FormatDefaultBackground(),
                        player.PlayerClass != PlayerClassType.Mage
                                                                ? "You can't cast spells. You're not a mage!"
                                                                : "You do not have enough mana to cast that spell!");
                    return(false);
                }
                break;

            case "use":
                try {
                    if (_input[1] != null && _input[1] != "bandage")
                    {
                        player.UseAbility(monster, _input);
                    }
                    if (_input[1] != null && _input[1] == "bandage")
                    {
                        player.UseAbility(_input);
                    }
                } catch (IndexOutOfRangeException) {
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatFailureOutputText(),
                        Settings.FormatDefaultBackground(),
                        "You don't have that ability.");
                    return(false);
                } catch (ArgumentOutOfRangeException) {
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatFailureOutputText(),
                        Settings.FormatDefaultBackground(),
                        "You don't have that ability.");
                    return(false);
                } catch (NullReferenceException) {
                    if (player.PlayerClass == PlayerClassType.Mage)
                    {
                        OutputHelper.Display.StoreUserOutput(
                            Settings.FormatFailureOutputText(),
                            Settings.FormatDefaultBackground(),
                            "You can't use abilities. You're not a warrior or archer!");
                        return(false);
                    }
                } catch (InvalidOperationException) {
                    switch (player.PlayerClass)
                    {
                    case PlayerClassType.Mage:
                        OutputHelper.Display.StoreUserOutput(
                            Settings.FormatFailureOutputText(),
                            Settings.FormatDefaultBackground(),
                            "You can't use abilities. You're not a warrior or archer!");
                        break;

                    case PlayerClassType.Warrior:
                        OutputHelper.Display.StoreUserOutput(
                            Settings.FormatFailureOutputText(),
                            Settings.FormatDefaultBackground(),
                            "You do not have enough rage to use that ability!");
                        break;

                    case PlayerClassType.Archer:
                        OutputHelper.Display.StoreUserOutput(
                            Settings.FormatFailureOutputText(),
                            Settings.FormatDefaultBackground(),
                            player.PlayerWeapon.WeaponGroup != WeaponType.Bow
                                                                                ? "You do not have a bow equipped!"
                                                                                : "You do not have enough combo points to use that ability!");
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    return(false);
                }
                break;

            case "equip":
            case "unequip":
                GearHelper.EquipItem(player, _input);
                break;

            case "flee":
                FleeCombat(player, monster);
                break;

            case "drink":
                if (_input.Last() == "potion")
                {
                    player.AttemptDrinkPotion(InputHelper.ParseInput(_input));
                }
                else
                {
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatFailureOutputText(),
                        Settings.FormatDefaultBackground(),
                        "You can't drink that!");
                    return(false);
                }
                break;

            case "reload":
                player.ReloadQuiver();
                break;

            case "i":
            case "inventory":
                PlayerHelper.ShowInventory(player);
                return(false);

            case "list":
                switch (_input[1])
                {
                case "abilities":
                    try {
                        PlayerHelper.ListAbilities(player);
                    } catch (IndexOutOfRangeException) {
                        OutputHelper.Display.StoreUserOutput(
                            Settings.FormatFailureOutputText(),
                            Settings.FormatDefaultBackground(),
                            "List what?");
                        return(false);
                    }
                    break;

                case "spells":
                    try {
                        PlayerHelper.ListSpells(player);
                    } catch (IndexOutOfRangeException) {
                        OutputHelper.Display.StoreUserOutput(
                            Settings.FormatFailureOutputText(),
                            Settings.FormatDefaultBackground(),
                            "List what?");
                        return(false);
                    }
                    break;
                }
                return(false);

            case "ability":
                try {
                    PlayerHelper.AbilityInfo(player, _input);
                } catch (IndexOutOfRangeException) {
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatFailureOutputText(),
                        Settings.FormatDefaultBackground(),
                        "What ability did you want to know about?");
                } catch (NullReferenceException) {
                    if (player.PlayerClass == PlayerClassType.Mage)
                    {
                        OutputHelper.Display.StoreUserOutput(
                            Settings.FormatFailureOutputText(),
                            Settings.FormatDefaultBackground(),
                            "You can't use abilities. You're not a warrior or archer!");
                    }
                }
                return(false);

            case "spell":
                try {
                    PlayerHelper.SpellInfo(player, _input);
                } catch (IndexOutOfRangeException) {
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatFailureOutputText(),
                        Settings.FormatDefaultBackground(),
                        "What spell did you want to know about?");
                } catch (NullReferenceException) {
                    if (player.PlayerClass != PlayerClassType.Mage)
                    {
                        OutputHelper.Display.StoreUserOutput(
                            Settings.FormatFailureOutputText(),
                            Settings.FormatDefaultBackground(),
                            "You can't use spells. You're not a mage!");
                    }
                }
                return(false);

            default:
                Messages.InvalidCommand();
                return(false);
            }
            return(true);
        }
예제 #6
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;
            }
        }