Пример #1
0
        public override Attack GetAttack(Entity defender)
        {
            // default to barehanded
            Roller          damage     = Roller.Dice(1, 3);
            Element         element    = Element.Anima;
            string          verb       = Verbs.Hit;
            EffectType      effectType = EffectType.Hit;
            IFlagCollection flags      = new FlagCollection();

            // find the equipped melee weapon
            Item weapon = Equipment.MeleeWeapon;

            if (weapon != null)
            {
                damage  = weapon.Attack.Damage;
                element = weapon.Attack.Element;
                verb    = weapon.Attack.Verb;
                flags   = weapon.Flags;

                //### bob: temp. need to get from weapon data
                effectType = EffectType.Stab;
            }

            var attack = new Attack(damage, MeleeStrikeBonus, MeleeDamageBonus, element, verb, effectType, flags);

            // give the class a chance to modify it
            mClass.BeforeAttack(defender, attack);

            return(attack);
        }
Пример #2
0
        /// <summary>
        /// Tries to create a new Roller by parsing the given string representation of it.
        /// Valid strings include "3", "2-5", "2d6", "6t3", and "2-5(1:4)".
        /// </summary>
        /// <param name="text">The string to parse.</param>
        /// <returns>The parsed Roller or <c>null</c> if unsuccessful.</returns>
        public static Roller Parse(string text)
        {
            // ignore whitespace
            text = text.Trim();

            // compile the regex if needed
            if (sParser == null)
            {
                string pattern = @"^((?<die>(?<dice>\d+)d(?<sides>\d+))|(?<tri>(?<center>\d+)t(?<range>\d+))|(?<range>(?<min>\d+)-(?<max>\d+))|(?<fixed>(?<value>-?\d+)))(?<taper>\((?<chance>\d+)\:(?<outof>\d+)\))?$";

                sParser = new Regex(pattern, RegexOptions.Compiled | RegexOptions.ExplicitCapture);
            }

            // parse it
            Match match = sParser.Match(text);

            if (!match.Success)
            {
                return(null);
            }

            Roller roller;

            if (match.Groups["die"].Success)
            {
                int dice  = Int32.Parse(match.Groups["dice"].Value);
                int sides = Int32.Parse(match.Groups["sides"].Value);
                roller = Roller.Dice(dice, sides);
            }
            else if (match.Groups["tri"].Success)
            {
                int center = Int32.Parse(match.Groups["center"].Value);
                int range  = Int32.Parse(match.Groups["range"].Value);
                roller = Roller.Triangle(center, range);
            }
            else if (match.Groups["range"].Success)
            {
                int min = Int32.Parse(match.Groups["min"].Value);
                int max = Int32.Parse(match.Groups["max"].Value);
                roller = Roller.Range(min, max);
            }
            else // fixed
            {
                int value = Int32.Parse(match.Groups["value"].Value);
                roller = Roller.Fixed(value);
            }

            // add the taper
            if (match.Groups["taper"].Success)
            {
                int chance = Int32.Parse(match.Groups["chance"].Value);
                int outOf  = Int32.Parse(match.Groups["outof"].Value);

                roller.mNextRoller = Taper(chance, outOf);
            }

            return(roller);
        }
Пример #3
0
        public Attack(Roller damage, int strikeBonus, float damageBonus,
                      Element element, string verb, EffectType effectType,
                      IFlagCollection flags)
        {
            mDamage      = damage;
            mStrikeBonus = strikeBonus;
            mDamageBonus = damageBonus;
            mElement     = element;

            Verb       = verb;
            EffectType = effectType;
            mFlags     = flags;
        }
Пример #4
0
 public ItemType(Content content, string name, string category, string subcategory,
                 object appearance, Roller quantity, Roller charges, Attack attack, int armor,
                 ChargeType chargeType, ItemScript use, int price)
     : base(content)
 {
     mName        = new Noun(name);
     mCategory    = category;
     mSubcategory = subcategory;
     mAppearance  = appearance;
     mQuantity    = quantity;
     mCharges     = charges;
     mAttack      = attack;
     mArmor       = armor;
     mChargeType  = chargeType;
     mUse         = use;
     mPrice       = price;
 }
Пример #5
0
        public PowerType(Content content, string name, bool isPrefix, IEnumerable <string> categories, object appearance)
            : base(content)
        {
            mName    = name;
            IsPrefix = isPrefix;

            mCategories.AddRange(categories);
            Appearance = appearance;

            // default to no bonus
            StrikeBonus = Roller.Fixed(0);
            DamageBonus = Roller.Fixed(10);
            ArmorBonus  = Roller.Fixed(0);
            StatBonus   = Roller.Fixed(0);
            SpeedBonus  = Roller.Fixed(0);

            Element = null;

            Flags = new FlagCollection();
        }
Пример #6
0
        public Race(Content content, string name, int depth, object appearance, int speed, Roller health)
            : base(content)
        {
            mName       = name;
            mDepth      = depth;
            mAppearance = appearance;
            mSpeed      = speed;

            // if the health is fixed, then automatically create a range for it
            if (health.IsFixed)
            {
                int amount = health.Roll();
                int range  = (int)(amount * 0.2f);

                if (range > 0)
                {
                    mHealth = Roller.Triangle(amount, range);
                }
                else
                {
                    mHealth = Roller.Fixed(amount);
                }
            }
            else
            {
                mHealth = health;
            }

            mDescription = "A nondescript beast of the dungeon.";
        }
Пример #7
0
 public ItemDrop(NotNull <ItemType> itemType, Roller quantity)
 {
     mItemType = itemType;
     mQuantity = quantity;
 }
Пример #8
0
 public Attack(Roller damage, Element element, string verb)
     : this(damage, 0, 1.0f, Element.Anima, verb, EffectType.Hit, new FlagCollection())
 {
 }
Пример #9
0
 public Attack(Roller damage, string verb, EffectType effectType)
     : this(damage, 0, 1.0f, Element.Anima, verb, effectType, new FlagCollection())
 {
 }
Пример #10
0
        public override Action GetAction(Monster monster, Entity target)
        {
            Attack attack = new Attack(Roller.Fixed(monster.Health.Current), Info.Element, Info.Verb, Info.Effect);

            return(new ElementConeAction(monster, target.Position, Info.Radius, Info.Noun, attack));
        }