예제 #1
0
        public void CastSpell(string inputName)
        {
            int index = Spellbook.FindIndex(f => f.Name == inputName);

            if (index != -1 &&
                ManaPoints >= Spellbook[index].ManaCost &&
                PlayerClass == PlayerClassType.Mage)
            {
                switch (Spellbook[index].SpellCategory)
                {
                case SpellType.Heal:
                    PlayerSpell.CastHealing(this, index);
                    return;

                case SpellType.Rejuvenate:
                    PlayerSpell.CastHealing(this, index);
                    return;

                case SpellType.Diamondskin:
                    PlayerSpell.CastAugmentArmor(this, index);
                    return;

                case SpellType.TownPortal:
                    PlayerSpell.CastTownPortal(this, index);
                    return;

                case SpellType.Reflect:
                    PlayerSpell.CastReflectDamage(this, index);
                    return;

                case SpellType.Fireball:
                case SpellType.Frostbolt:
                case SpellType.Lightning:
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatAttackFailText(),
                        Settings.FormatDefaultBackground(),
                        "You cannot use that spell outside combat!");
                    return;

                case SpellType.ArcaneIntellect:
                    PlayerSpell.CastArcaneIntellect(this, index);
                    return;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            if (index != -1)
            {
                throw new InvalidOperationException();
            }
            throw new IndexOutOfRangeException();
        }