public void AddAffect(int type, int duration, int modifier, int location, int bits)
        {
            if (type < 0)
            {
                throw new InvalidEnumArgumentException(nameof(type), (int)type, typeof(AffectedByTypes));
            }

            AffectData newAffect = new AffectData
            {
                Type     = Common.EnumerationExtensions.GetEnum <AffectedByTypes>(type),
                Duration = duration,
                Modifier = modifier,
                Location = Realm.Library.Common.Extensions.EnumerationExtensions.GetEnum <ApplyTypes>(location)
            };

            newAffect.BitVector.SetBit(bits);

            Affects.Add(newAffect);
        }
示例#2
0
 public void AddAffect(SmaugAffect affect)
 {
     Affects.Add(affect);
 }
        internal void ApplyAffect(AffectData affect, bool adding = true)
        {
            // Add the affect to the list
            Affects.Add(affect);

            // Add/remove the affect flag to the appropriate property
            switch (affect.Where)
            {
            case ToWhere.Affects:
                if (adding)
                {
                    this.AffectedBy |= (AffectedByFlag)affect.BitVector;
                }
                else
                {
                    this.AffectedBy &= ~(AffectedByFlag)affect.BitVector;
                }

                break;

            case ToWhere.Vuln:
                if (adding)
                {
                    this.Vulnerability |= (VulnerabilityFlag)affect.BitVector;
                }
                else
                {
                    this.Vulnerability &= ~(VulnerabilityFlag)affect.BitVector;
                }

                break;

            case ToWhere.Resist:
                if (adding)
                {
                    this.Resist |= (ResistanceFlag)affect.BitVector;
                }
                else
                {
                    this.Resist &= ~(ResistanceFlag)affect.BitVector;
                }
                break;

            case ToWhere.Immune:
                if (adding)
                {
                    this.Immunity |= (ImmunityFlag)affect.BitVector;
                }
                else
                {
                    this.Immunity &= ~(ImmunityFlag)affect.BitVector;
                }

                break;
            }

            // Set the modifier
            int modifier = affect.Modifier;

            // If we're removing, reverse the modifier
            if (!adding)
            {
                modifier *= -1;
            }

            // Apply the modifier to the appropriate location
            switch (affect.Location)
            {
            case ApplyType.None:
                break;

            case ApplyType.Strength:
                this.ModifiedStats.Strength += modifier;
                break;

            case ApplyType.Dexterity:
                this.ModifiedStats.Dexterity += modifier;
                break;

            case ApplyType.Intelligence:
                this.ModifiedStats.Intelligence += modifier;
                break;

            case ApplyType.Wisdom:
                this.ModifiedStats.Wisdom += modifier;
                break;

            case ApplyType.Constitution:
                this.ModifiedStats.Constitution += modifier;
                break;

            case ApplyType.Gender:
                // Calculate the new gender value
                int newGenderVal = (int)this.Gender.GenderCode + modifier;

                // Attempt to locate a matching new gender value
                Gender newGender = Consts.Gender.GenderTable.SingleOrDefault(g => (int)g.GenderCode == newGenderVal);

                if (newGender != null)
                {
                    this.Gender = newGender;
                }
                else
                {
                    throw new ArgumentException("Unable to find new gender matching modified value " + newGenderVal);
                }

                break;

            case ApplyType.Class:
                break;

            case ApplyType.Level:
                break;

            case ApplyType.Age:
                break;

            case ApplyType.Height:
                break;

            case ApplyType.Weight:
                break;

            case ApplyType.Health:
                this.MaxHealth += modifier;
                break;

            case ApplyType.Mana:
                this.MaxMana += modifier;
                break;

            case ApplyType.Movement:
                this.MaxMove += modifier;
                break;

            case ApplyType.Gold:
                break;

            case ApplyType.Experience:
                break;

            case ApplyType.AC:
                this.Armor.Modify(modifier);
                break;

            case ApplyType.HitRoll:
                this.HitRoll += modifier;
                break;

            case ApplyType.DamageRoll:
                this.DamRoll += modifier;
                break;

            // There is actually only one saving throw stat, all feed into it
            case ApplyType.Saves:
            case ApplyType.Saving_Rod:
            case ApplyType.Saving_Spell:
            case ApplyType.Saving_Breath:
            case ApplyType.Saving_Paralyze:
            case ApplyType.Saving_Petrification:
                this.SavingThrow += modifier;
                break;

            case ApplyType.SpellAffect:
                break;
            }

            // Check if the PC is wielding a weapon heavier than their maximum wield weight; if so, drop the item (can happens as strength-boosting effects drop, for example)
            if (!IsNPC && Equipment.Wield != null &&
                Equipment.Wield.Weight > Consts.AttributeBonuses.StrengthBonusTable[GetEffectiveStat(Enums.Attribute.Strength)].Wield * 10)
            {
                // Drop the item
                // TODO: Implement
            }
        }
示例#4
0
 public void AddAffect(AffectData affect) => Affects.Add(affect);