public static void FormatBonusText(AutoStringBuilder text, double value, double percent)
        {
            var hasValueBonus = false;

            if (value != 0)
            {
                hasValueBonus = true;
                text.Append(SignChar(value))
                .Append(value.ToString("0.##"));
            }

            if (percent != 0)
            {
                if (hasValueBonus)
                {
                    text.Append(" (");
                }

                text.Append(SignChar(percent))
                .Append(percent.ToString("0.##"))
                .Append("%");

                if (hasValueBonus)
                {
                    text.Append(")");
                }
            }
        }
Exemple #2
0
        public static void FormatBonusText(AutoStringBuilder text, double totalValueBonus, double totalPercentBonus)
        {
            if (totalValueBonus != 0)
            {
                text.Append(SignChar(totalValueBonus))
                .Append(totalValueBonus.ToString("0.##"));
            }

            if (totalPercentBonus != 0)
            {
                text.Append(SignChar(totalPercentBonus))
                .Append(totalPercentBonus.ToString("0.##"))
                .Append("%");
            }
        }
Exemple #3
0
        public static void FormatBonusText(
            AutoStringBuilder text,
            double valueBonus,
            double percentBonus,
            bool canDisplayPositiveSign)
        {
            var hasValueBonus = false;

            if (valueBonus != 0)
            {
                hasValueBonus = true;

                if (canDisplayPositiveSign ||
                    valueBonus < 0)
                {
                    text.Append(SignChar(valueBonus));
                }

                text.Append(valueBonus.ToString("0.##"));
            }

            if (percentBonus == 0)
            {
                return;
            }

            if (hasValueBonus)
            {
                text.Append(" (");
            }

            if (canDisplayPositiveSign ||
                percentBonus < 0)
            {
                text.Append(SignChar(percentBonus));
            }

            text.Append(percentBonus.ToString("0.##"))
            .Append("%");

            if (hasValueBonus)
            {
                text.Append(")");
            }
        }
Exemple #4
0
        public override void Refresh(byte currentLevel)
        {
            this.Visibility = Visibility.Visible;

            double totalValueBonusNow         = 0,
                   totalPercentBonusNow       = 0,
                   totalValueBonusNextLevel   = 0,
                   totalPercentBonusNextLevel = 0;

            var nextLevel = (byte)(currentLevel + 1);

            if (nextLevel > this.MaxLevel)
            {
                nextLevel = this.MaxLevel;
            }

            var hasNextLevel = nextLevel != currentLevel;

            foreach (var statEffect in this.effects)
            {
                if (statEffect.Level > currentLevel)
                {
                    continue;
                }

                totalValueBonusNow   += statEffect.CalcTotalValueBonus(currentLevel);
                totalPercentBonusNow += statEffect.CalcTotalPercentBonus(currentLevel);

                if (hasNextLevel)
                {
                    totalValueBonusNextLevel   += statEffect.CalcTotalValueBonus(nextLevel);
                    totalPercentBonusNextLevel += statEffect.CalcTotalPercentBonus(nextLevel);
                }
            }

            if (totalValueBonusNow == 0d &&
                totalPercentBonusNow == 0d)
            {
                this.IsActive   = false;
                this.Visibility = Visibility.Collapsed;
                return;
            }

            this.IsActive   = true;
            this.Visibility = Visibility.Visible;

            var text = new AutoStringBuilder(this.effects[0].Description);

            text.Append(" ");
            ViewModelSkillEffectStat.FormatBonusText(text, totalValueBonusNow, totalPercentBonusNow);

            if (totalValueBonusNextLevel != 0 ||
                totalPercentBonusNextLevel != 0)
            {
                text.Append(" (")
                .Append(NextLevelPrefix)
                .Append(" ");

                ViewModelSkillEffectStat.FormatBonusText(text,
                                                         totalValueBonusNextLevel,
                                                         totalPercentBonusNextLevel);
                text.Append(")");
            }

            this.Description = text;
        }
        public override void Refresh(byte currentLevel)
        {
            this.Visibility = Visibility.Visible;

            double totalValueBonusNow         = 0,
                   totalPercentBonusNow       = 0,
                   totalValueBonusNextLevel   = 0,
                   totalPercentBonusNextLevel = 0;

            var nextLevel = (byte)(currentLevel + 1);

            if (nextLevel > this.MaxLevel)
            {
                nextLevel = this.MaxLevel;
            }

            var hasNextLevel = nextLevel != currentLevel;

            foreach (var statEffect in this.effects)
            {
                if (statEffect.Level > currentLevel)
                {
                    continue;
                }

                totalValueBonusNow   += statEffect.CalcTotalValueBonus(currentLevel);
                totalPercentBonusNow += statEffect.CalcTotalPercentBonus(currentLevel);

                if (hasNextLevel)
                {
                    totalValueBonusNextLevel   += statEffect.CalcTotalValueBonus(nextLevel);
                    totalPercentBonusNextLevel += statEffect.CalcTotalPercentBonus(nextLevel);
                }
            }

            if (totalValueBonusNow == 0d &&
                totalPercentBonusNow == 0d)
            {
                this.IsActive   = false;
                this.Visibility = Visibility.Collapsed;
                return;
            }

            this.IsActive   = true;
            this.Visibility = Visibility.Visible;

            var firstEffect       = this.effects[0];
            var displayTotalValue = firstEffect.DisplayTotalValue;

            var sb = new AutoStringBuilder(firstEffect.Description);

            sb.Append(" ");

            double globalValue        = 0,
                   globalPercentValue = 0;

            if (displayTotalValue)
            {
                var statName = firstEffect.StatName;
                var cache    = ClientCurrentCharacterHelper.Character.SharedGetFinalStatsCache();
                foreach (var statEntry in cache.Sources.List)
                {
                    if (statEntry.StatName == statName &&
                        !ReferenceEquals(statEntry.Source, this.skill))
                    {
                        globalValue        += statEntry.Value;
                        globalPercentValue += statEntry.Percent;
                    }
                }
            }

            ViewModelSkillEffectStat.FormatBonusText(sb,
                                                     globalValue + totalValueBonusNow,
                                                     globalPercentValue + totalPercentBonusNow,
                                                     canDisplayPositiveSign: !displayTotalValue);

            if (hasNextLevel &&
                (totalValueBonusNextLevel != totalValueBonusNow ||
                 totalPercentBonusNextLevel != totalPercentBonusNow))
            {
                sb.Append(" (")
                .Append(NextLevelPrefix)
                .Append(" ");

                ViewModelSkillEffectStat.FormatBonusText(sb,
                                                         globalValue + totalValueBonusNextLevel,
                                                         globalPercentValue + totalPercentBonusNextLevel,
                                                         canDisplayPositiveSign: !displayTotalValue);
                sb.Append(")");
            }

            this.Description = sb;
        }