Exemplo n.º 1
0
        private void InvalidateItems()
        {
            m_Locked = true;

            for (int i = 0; i < ItemFilter.Items.Count; i++)
            {
                ItemFilter.SetItemChecked(i, m_Filter.Filters(i));
            }

            m_Locked = false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructs header for all items.
        /// </summary>
        /// <param name="filter">Loot filter.</param>
        /// <returns>Item header.</returns>
        public static string GetHeader(LootFilter filter)
        {
            StringBuilder builder = new StringBuilder();
            int           l       = PropCount;

            builder.Append(Filter(filter, l, "Serial\t", null));
            builder.Append(Filter(filter, l + 1, "Localized Number\t", null));
            builder.Append(Filter(filter, l + 2, "Name\t", null));
            builder.Append(Filter(filter, l + 3, "ItemID\t", null));
            builder.Append(Filter(filter, l + 4, "Hue\t", null));
            builder.Append(Filter(filter, l + 5, "Amount\t", null));
            builder.Append(Filter(filter, l + 6, "Weight\t", null));

            string[] list = Enum.GetNames(typeof(ItemProperty));

            for (int i = 0; i < list.Length; i++)
            {
                if (filter == null || filter.Filters(i))
                {
                    builder.AppendFormat("{0}\t", list[i]);
                }
            }

            return(builder.ToString());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Converts this item to one line string
        /// </summary>
        /// <param name="filter">Loot filter.</param>
        /// <returns>Item converted into string.</returns>
        public string ToString(LootFilter filter)
        {
            StringBuilder builder = new StringBuilder();
            int           l       = PropCount;

            builder.Append(Filter(filter, l, "0x{0}\t", m_Serial.ToString("X8")));
            builder.Append(Filter(filter, l + 1, "{0}\t", m_NameCliloc));
            builder.Append(Filter(filter, l + 2, "{0}\t", m_Name));
            builder.Append(Filter(filter, l + 3, "0x{0}\t", m_ItemID.ToString("X4")));
            builder.Append(Filter(filter, l + 4, "0x{0}\t", m_Hue.ToString("X")));
            builder.Append(Filter(filter, l + 5, "{0}\t", m_Amount));
            builder.Append(Filter(filter, l + 6, "{0}\t", m_Weight));

            Array list = Enum.GetValues(typeof(ItemProperty));

            for (int i = 0; i < list.Length; i++)
            {
                ItemProperty p = (ItemProperty)i;

                if (filter == null || filter.Filters((int)p))
                {
                    if (m_Properties.ContainsKey(p))
                    {
                        builder.AppendFormat("{0}\t", m_Properties[p]);
                    }
                    else
                    {
                        builder.Append('\t');
                    }
                }
            }

            return(builder.ToString());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Filters item property
        /// </summary>
        /// <param name="filter">Loot filter.</param>
        /// <param name="index">Item property (<see cref="ItemProperty"/>).</param>
        /// <param name="format">A composite format string.</param>
        /// <param name="args">An object to format.</param>
        /// <returns>Empty string when filtered and constructed item property otherwise.</returns>
        public static string Filter(LootFilter filter, int index, string format, object args)
        {
            if (filter == null || filter.Filters(index))
            {
                return(String.Format(format, args));
            }

            return(String.Empty);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Saves filtered loot to a file.
        /// </summary>
        /// <param name="fileName">File name.</param>
        public void PrintReport(string fileName)
        {
            TextWriter writer = new StreamWriter(fileName);

            writer.WriteLine(Item.GetHeader(m_Filter));

            int totalGold = 0, minGold = Int32.MaxValue, maxGold = 0;
            int totalItems = 0, sumItems = 0, minItems = Int32.MaxValue, maxItems = 0;
            int counter = 0;

            int[] items = new int[100];
            int[] props = new int[100];

            foreach (uint ms in m_Mobiles.Keys)
            {
                Mobile m = m_Mobiles[ms];

                if (m_Filter.Filters(m.Name) && m.Loot.Count > 0)
                {
                    foreach (KeyValuePair <uint, Item> kvp in m.Loot)
                    {
                        Item item = kvp.Value;

                        if (!m_Filter.Filters(item))
                        {
                            if ((item.IsWearable && m_Filter.Wearable) || (item.IsOther && m_Filter.Other))
                            {
                                writer.WriteLine(kvp.Value.ToString(m_Filter));
                                sumItems++;
                            }

                            if (item.IsGold)
                            {
                                totalGold += item.Amount;

                                if (item.Amount > maxGold)
                                {
                                    maxGold = item.Amount;
                                }
                                if (item.Amount < minGold)
                                {
                                    minGold = item.Amount;
                                }
                            }

                            props[item.SpecialProps]++;
                        }
                    }

                    if (sumItems > 0)
                    {
                        writer.WriteLine();
                    }

                    if (sumItems > maxItems)
                    {
                        maxItems = sumItems;
                    }
                    if (sumItems > 0 && sumItems < minItems)
                    {
                        minItems = sumItems;
                    }

                    totalItems += sumItems;
                    counter++;
                    items[sumItems]++;
                    sumItems = 0;
                }
            }

            writer.WriteLine();
            writer.WriteLine("Item count\tNumber of corpses\t\tProp count\tNumber of items");

            int sumFullCorpses = 0;

            for (int i = 1; i < items.Length; i++)
            {
                sumFullCorpses += items[i];

                if (items[i] > 0 || props[i] > 0)
                {
                    writer.WriteLine("{0}\t{1}\t\t{2}\t{3}", i, items[i], i, props[i]);
                }
            }

            writer.WriteLine("0\t{0}", counter - sumFullCorpses);

            writer.WriteLine();
            writer.WriteLine("{0} items in {1} corpses, {2}/{3}/{4} items per corpse", totalItems, counter, minItems, totalItems / (double)counter, maxItems);
            writer.WriteLine("{0} gold in {1} corpses, {2}/{3}/{4} gold per corpse", totalGold, counter, minGold, totalGold / (double)counter, maxGold);
            writer.WriteLine();
            writer.WriteLine(Mobile.GetHeader());

            foreach (uint ms in m_Mobiles.Keys)
            {
                Mobile m = m_Mobiles[ms];

                if (m_Filter.Filters(m.Name))
                {
                    writer.WriteLine(m);
                }
            }

            writer.Close();
        }