Exemple #1
0
 public string ToString(ItemStringOptions options)
 {
     return(ToString(Quantity, options));
 }
Exemple #2
0
        public string ToString(int quantity, ItemStringOptions options)
        {
            StringBuilder builder = new StringBuilder();

            // show the quantity
            if (options.IsSet(ItemStringOptions.ShowQuantity))
            {
                if (quantity > 1)
                {
                    builder.Append(quantity.ToString());
                    builder.Append(" ");
                }
                else
                {
                    builder.Append("a ");
                }
            }

            // show the prefix power
            if ((mPower != null) && mPower.Type.IsPrefix)
            {
                builder.Append(mPower.Name);
                builder.Append(" ");
            }

            // show the name
            if (options.IsSet(ItemStringOptions.ShowQuantity))
            {
                if (quantity > 1)
                {
                    builder.Append(Type.Noun.Plural);
                }
                else
                {
                    builder.Append(Type.Noun.Singular);
                }
            }
            else
            {
                builder.Append(Type.Noun.Singular);
            }

            // show the suffix power
            if ((mPower != null) && !mPower.Type.IsPrefix)
            {
                builder.Append(" ");
                builder.Append(mPower.Name);
            }

            if (options.IsSet(ItemStringOptions.ShowBonuses))
            {
                // show the weapon stats
                if ((Type.Attack != null) || (StrikeBonus != 0) || (DamageBonus != 1.0f))
                {
                    bool needsSpace = false;
                    builder.Append(" ^k(^m");

                    if (Type.Attack != null)
                    {
                        builder.Append(Type.Attack.Damage.ToString());
                        needsSpace = true;
                    }

                    if (StrikeBonus != 0)
                    {
                        if (needsSpace)
                        {
                            builder.Append(" ");
                        }

                        builder.Append(StrikeBonus.ToString("+##;-##;0"));
                        needsSpace = true;
                    }

                    if (DamageBonus != 1.0f)
                    {
                        if (needsSpace)
                        {
                            builder.Append(" ");
                        }

                        builder.AppendFormat("x{0}", DamageBonus);
                    }

                    builder.Append("^k)^-");
                }

                // show the armor stats
                if ((Type.Armor != 0) || (ArmorBonus != 0))
                {
                    bool needsSpace = false;
                    builder.Append(" ^k[^m");

                    if (Type.Armor != 0)
                    {
                        builder.Append(Type.Armor.ToString());
                        needsSpace = true;
                    }

                    if (ArmorBonus != 0)
                    {
                        if (needsSpace)
                        {
                            builder.Append(" ");
                        }

                        builder.Append(ArmorBonus.ToString("+##;-##;0"));
                    }

                    builder.Append("^k]^-");
                }

                // show the stat bonus
                if (StatBonus != 0)
                {
                    builder.Append(" ^k(^m");
                    builder.Append(StatBonus.ToString("+##;-##;0"));
                    builder.Append("^k)^-");
                }

                // show the speed bonus
                if (SpeedBonus != 0)
                {
                    builder.Append(" ^k(^m");
                    builder.Append(SpeedBonus.ToString("+##;-##;0"));
                    builder.Append(" speed^k)^-");
                }
            }

            if (options.IsSet(ItemStringOptions.ShowCharges))
            {
                switch (Type.ChargeType)
                {
                case ChargeType.Light:
                    if (mCharges == 0)
                    {
                        builder.Append(" ^k(^mempty^k)^-");
                    }
                    else if (mCharges > 0)
                    {
                        builder.AppendFormat(" ^k(^ylit^m {0} left^k)^-", mCharges);
                    }
                    else
                    {
                        builder.AppendFormat(" ^k(^m{0} left^k)^-", -mCharges);
                    }
                    break;

                case ChargeType.Multi:
                    if (mCharges == 0)
                    {
                        builder.Append(" ^k(^mempty^k)^-");
                    }
                    else
                    {
                        builder.AppendFormat(" ^k(^m{0} charges^k)^-", mCharges);
                    }
                    break;
                }
            }

            return(builder.ToString());
        }
Exemple #3
0
 public static bool IsSet(this ItemStringOptions options, ItemStringOptions flags)
 {
     return((options & flags) == flags);
 }