示例#1
0
        public RangeStatData(StringLookupTable reader, List <D2Stat> stats)
        {
            stringReader = reader;

            Func <StatIdentifier, D2Stat> findStat = id => {
                int index = stats.FindIndex(x => x.LoStatID == (ushort)id);
                return(index >= 0 ? stats[index] : null);
            };

            foreach (var stat in stats)
            {
                if (!Enum.IsDefined(typeof(StatIdentifier), stat.LoStatID))
                {
                    continue;
                }

                switch ((StatIdentifier)stat.LoStatID)
                {
                case StatIdentifier.DamageMin:
                    DamageMin = stat.Value;
                    if (DamageMin == 0)
                    {
                        var twoHandDamage = findStat(StatIdentifier.SecondaryDamageMin);
                        if (twoHandDamage != null)
                        {
                            DamageMin = twoHandDamage.Value;
                        }

                        IsDamageMinSecondary = DamageMin != 0;
                    }
                    break;

                case StatIdentifier.DamageMax:
                    DamageMax = stat.Value;
                    if (DamageMax == 0)
                    {
                        var twoHandDamage = findStat(StatIdentifier.SecondaryDamageMax);
                        if (twoHandDamage != null)
                        {
                            DamageMax = twoHandDamage.Value;
                        }

                        IsDamageMaxSecondary = DamageMax != 0;
                    }
                    break;

                case StatIdentifier.SecondaryDamageMin:
                {
                    var oneHandDamage = findStat(StatIdentifier.DamageMin);
                    if (oneHandDamage != null)
                    {
                        DamageMin = oneHandDamage.Value;
                    }

                    if (DamageMin == 0)
                    {
                        DamageMin            = stat.Value;
                        IsDamageMinSecondary = stat.Value != 0;
                    }
                    break;
                }

                case StatIdentifier.SecondaryDamageMax:
                {
                    var oneHandDamage = findStat(StatIdentifier.DamageMax);
                    if (oneHandDamage != null)
                    {
                        DamageMax = oneHandDamage.Value;
                    }

                    if (DamageMax == 0)
                    {
                        DamageMax            = stat.Value;
                        IsDamageMaxSecondary = stat.Value != 0;
                    }
                    break;
                }

                case StatIdentifier.ItemDamageMinPercent:   DamagePercentMin = stat.Value; break;

                case StatIdentifier.ItemDamageMaxPercent:   DamagePercentMax = stat.Value; break;

                case StatIdentifier.FireDamageMin:          FireMinDamage = stat.Value; break;

                case StatIdentifier.FireDamageMax:          FireMaxDamage = stat.Value; break;

                case StatIdentifier.LightningDamageMin:     LightningMinDamage = stat.Value; break;

                case StatIdentifier.LightningDamageMax:     LightningMaxDamage = stat.Value; break;

                case StatIdentifier.MagicDamageMin:         MagicMinDamage = stat.Value; break;

                case StatIdentifier.MagicDamageMax:         MagicMaxDamage = stat.Value; break;

                case StatIdentifier.ColdDamageMin:          ColdMinDamage = stat.Value; break;

                case StatIdentifier.ColdDamageMax:          ColdMaxDamage = stat.Value; break;

                case StatIdentifier.PoisonDamageMin:        PoisonMinDamage = stat.Value; break;

                case StatIdentifier.PoisonDamageMax:        PoisonMaxDamage = stat.Value; break;

                case StatIdentifier.PoisonDamageDuration:   PoisonDuration = stat.Value; break;

                case StatIdentifier.PoisonDivisor:          PoisonDivisor = stat.Value; break;

                default: break;
                }
            }

            HasDamageRange        = HasRangeFor(DamageMin, DamageMax);
            HasDamagePercentRange = HasRangeFor(DamagePercentMin, DamagePercentMax);
            HasFireRange          = HasRangeFor(FireMinDamage, FireMaxDamage);
            HasLightningRange     = HasRangeFor(LightningMinDamage, LightningMaxDamage);
            HasMagicRange         = HasRangeFor(MagicMinDamage, MagicMaxDamage);
            HasColdRange          = HasRangeFor(ColdMinDamage, ColdMaxDamage);
            HasPoisonRange        = HasRangeFor(PoisonMinDamage, PoisonMaxDamage);
        }
示例#2
0
 public UnitReader(ProcessMemoryReader reader, D2MemoryTable memory)
 {
     this.reader  = reader;
     this.memory  = memory;
     stringReader = new StringLookupTable(reader, memory.Address);
 }