Ejemplo n.º 1
0
        /// <summary>
        /// fill the player data by dictionary
        /// </summary>
        private void ParseStats(
            Dictionary <StatIdentifier, D2Stat> data,
            D2GameInfo gameInfo
            )
        {
            CharClass = (CharacterClass)gameInfo.Player.eClass;

            int penalty = ResistancePenalty.GetPenaltyByGame(gameInfo.Game);

            int ValueByStatID(Dictionary <StatIdentifier, D2Stat> d, StatIdentifier statID)
            {
                // Get the value if if the key exists, else assume zero.
                return(d.TryGetValue(statID, out D2Stat stat) ? stat.Value : 0);
            }

            int getStat(StatIdentifier statID) => ValueByStatID(data, statID);

            Level      = getStat(StatIdentifier.Level);
            Experience = getStat(StatIdentifier.Experience);

            Strength  = getStat(StatIdentifier.Strength);
            Dexterity = getStat(StatIdentifier.Dexterity);
            Vitality  = getStat(StatIdentifier.Vitality);
            Energy    = getStat(StatIdentifier.Energy);

            Gold      = getStat(StatIdentifier.Gold);
            GoldStash = getStat(StatIdentifier.GoldStash);

            VelocityPercent = getStat(StatIdentifier.VelocityPercent);
            AttackRate      = getStat(StatIdentifier.AttackRate);
            Defense         = getStat(StatIdentifier.Defense);

            int maxFire      = BASE_MAX_RESIST + getStat(StatIdentifier.ResistFireMax);
            int maxCold      = BASE_MAX_RESIST + getStat(StatIdentifier.ResistColdMax);
            int maxLightning = BASE_MAX_RESIST + getStat(StatIdentifier.ResistLightningMax);
            int maxPoison    = BASE_MAX_RESIST + getStat(StatIdentifier.ResistPoisonMax);

            FireResist      = Utility.Clamp(getStat(StatIdentifier.ResistFire) + penalty, MIN_RESIST, maxFire);
            ColdResist      = Utility.Clamp(getStat(StatIdentifier.ResistCold) + penalty, MIN_RESIST, maxCold);
            LightningResist = Utility.Clamp(getStat(StatIdentifier.ResistLightning) + penalty, MIN_RESIST, maxLightning);
            PoisonResist    = Utility.Clamp(getStat(StatIdentifier.ResistPoison) + penalty, MIN_RESIST, maxPoison);

            FasterHitRecovery    = getStat(StatIdentifier.FasterHitRecovery);
            FasterRunWalk        = getStat(StatIdentifier.FasterRunWalk);
            FasterCastRate       = getStat(StatIdentifier.FasterCastRate);
            IncreasedAttackSpeed = getStat(StatIdentifier.IncreasedAttackSpeed);

            AttackerSelfDamage = getStat(StatIdentifier.AttackerSelfDamage);

            MagicFind   = getStat(StatIdentifier.MagicFind);
            MonsterGold = getStat(StatIdentifier.MonsterGold);
        }
Ejemplo n.º 2
0
 internal void ParseStats(UnitReader unitReader, D2GameInfo gameInfo)
 {
     ParseStats(unitReader.GetStatsMap(gameInfo.Player), gameInfo);
 }