示例#1
0
        protected string _toString(StringLookupTable stringLookupTable, object[] args, ushort stringId)
        {
            string format = stringLookupTable.ConvertCFormatString(
                stringLookupTable.GetString(stringId),
                out int arguments
                );

            if (arguments != args.Length)
            {
                return(null);
            }
            return(string.Format(format, args).TrimEnd());
        }
示例#2
0
        public string GetSkillName(ushort skillIdentifier)
        {
            D2SkillData skillData = GetSkillData(skillIdentifier);

            if (skillData == null)
            {
                return(null);
            }

            // Skill description table (unknown).
            if (skillData.SkillDescriptionId == 0 || skillData.SkillDescriptionId >= globals.SkillDescriptionCount)
            {
                return(null);
            }
            IntPtr skillDescriptionAddress = globals.SkillDescriptions.Address + (int)skillData.SkillDescriptionId * 0x120;
            UInt16 skillNameID             = reader.ReadUInt16(skillDescriptionAddress + 8);

            if (skillNameID == 0)
            {
                return(null);
            }
            return(stringReader.GetString(skillNameID));
        }
示例#3
0
        public bool TryHandleStat(D2Stat stat, out string description)
        {
            description = null;

            if (!stat.HasValidLoStatIdentifier())
            {
                return(false);
            }

            switch ((StatIdentifier)stat.LoStatID)
            {
            // Handle one and two handed damage.
            case StatIdentifier.DamageMin:
            case StatIdentifier.DamageMax:
            case StatIdentifier.SecondaryDamageMin:
            case StatIdentifier.SecondaryDamageMax:
                // Only print once if it's a range.
                if (HasHandledDamageRange)
                {
                    return(true);
                }

                // Skip two-handed damage if there is a one-handed damage source or if no damage is defined.
                if (stat.IsOfType(StatIdentifier.SecondaryDamageMin) && !IsDamageMinSecondary)
                {
                    return(true);
                }
                if (stat.IsOfType(StatIdentifier.SecondaryDamageMax) && !IsDamageMaxSecondary)
                {
                    return(true);
                }

                // If not a range, print normally.
                if (!damage.HasRange())
                {
                    return(false);
                }

                // We also print twice if they are the same.
                if (damage.min == damage.max)
                {
                    return(false);
                }

                HasHandledDamageRange = true;
                description           = damage.ToString(stringReader);
                return(true);

            // Handle enhanced damage.
            case StatIdentifier.ItemDamageMinPercent:
                if (!damagePercent.HasRange())
                {
                    return(false);
                }
                description = string.Format("+{0}% {1}", stat.Value, stringReader.GetString(StringConstants.EnhancedDamage).TrimEnd());
                return(true);

            case StatIdentifier.ItemDamageMaxPercent:
                return(damagePercent.HasRange());

            // Handle fire damage ranges.
            case StatIdentifier.FireDamageMin:
                if (!fireDamage.HasRange())
                {
                    return(false);
                }
                description = fireDamage.ToString(stringReader);
                return(true);

            case StatIdentifier.FireDamageMax:
                return(fireDamage.HasRange());

            // Handle lightning damage ranges.
            case StatIdentifier.LightningDamageMin:
                if (!lightningDamage.HasRange())
                {
                    return(false);
                }
                description = lightningDamage.ToString(stringReader);
                return(true);

            case StatIdentifier.LightningDamageMax:
                return(lightningDamage.HasRange());

            // Handle magic damage ranges.
            case StatIdentifier.MagicDamageMin:
                if (!magicDamage.HasRange())
                {
                    return(false);
                }
                description = magicDamage.ToString(stringReader);
                return(true);

            case StatIdentifier.MagicDamageMax:
                return(magicDamage.HasRange());

            // Handle cold damage ranges.
            case StatIdentifier.ColdDamageMin:
                if (!coldDamage.HasRange())
                {
                    return(false);
                }
                description = coldDamage.ToString(stringReader);
                return(true);

            case StatIdentifier.ColdDamageMax:
                return(coldDamage.HasRange());

            // Handle poison damage ranges.
            case StatIdentifier.PoisonDamageMax:
            case StatIdentifier.PoisonDamageDuration:
                return(poisonDamage.HasRange());

            case StatIdentifier.PoisonDamageMin:
                if (!poisonDamage.HasRange())
                {
                    return(false);
                }
                description = poisonDamage.ToString(stringReader);
                return(true);

            // By default, the stat is not handled.
            default:
                return(false);
            }
        }