示例#1
0
        public static int GetAmount(this Container cont, Type[] types, bool recurse, bool includeDeeds)
        {
            int amount = cont.GetAmount(types, recurse);

            Item[] deeds = cont.FindItemsByType(typeof(CommodityDeed), recurse);

            for (var index = 0; index < deeds.Length; index++)
            {
                var item = deeds[index];
                var deed = (CommodityDeed)item;

                if (deed.Commodity == null)
                {
                    continue;
                }

                for (var i = 0; i < types.Length; i++)
                {
                    Type type = types[i];

                    if (deed.Commodity.GetType() == type)
                    {
                        amount += deed.Commodity.Amount;
                        break;
                    }
                }
            }

            return(amount);
        }
        private static void CheckArray(Mobile from, Container cont, Type[] regs, string[] regsName)
        {
            string sOverLimit = "";
            string sUnderLimit = "";

            for (int i = 0; i < regs.Length; i++)
            {
                int count = cont.GetAmount(regs[i], true);
                string text = string.Format("{0}:{1}", regsName[i], count.ToString());

                if (count > ReagentWarningLimit)
                {
                    if ((sOverLimit.Length != 0) && (i < regs.Length)) sOverLimit += ", ";
                    sOverLimit += text;
                }
                else
                {
                    if ((sUnderLimit.Length != 0) && (i < regs.Length)) sUnderLimit += ", ";
                    sUnderLimit += text;
                }
            }

            if (sOverLimit.Length == 0 && sUnderLimit.Length == 0)
            {
                from.SendAsciiMessage(40, "No regs was found !");
            }
            else
            {
                if (sOverLimit.Length != 0) from.SendAsciiMessage(76, sOverLimit);
                if (sUnderLimit.Length != 0) from.SendAsciiMessage(40, sUnderLimit);
            }
        }
示例#3
0
        public static int GetAmount(this Container cont, Type type, bool recurse, bool includeDeeds)
        {
            int amount = cont.GetAmount(type, recurse);

            Item[] deeds = cont.FindItemsByType(typeof(CommodityDeed), recurse);
            foreach (CommodityDeed deed in deeds)
            {
                if (deed.Commodity == null)
                {
                    continue;
                }
                if (deed.Commodity.GetType() == type)
                {
                    amount += deed.Commodity.Amount;
                }
            }

            return(amount);
        }
示例#4
0
        public PenOfWisdomGump(Mobile from, PenOfWisdom pen, Runebook sourcebook, Runebook copybook, List <RunebookEntry> list)
            : base(50, 50)
        {
            Container bp = from.Backpack;

            Pen              = pen;
            SourceBook       = sourcebook;
            CopyBook         = copybook;
            MarkScrollAmount = bp.GetAmount(typeof(MarkScroll), true);
            RuneAmount       = bp.GetAmount(typeof(RecallRune), true);
            Blank            = copybook.MaxEntries - copybook.Entries.Count;

            if (list == null)
            {
                Checked = new List <RunebookEntry>();
            }
            else
            {
                Checked = list;
            }

            Closable   = false;
            Disposable = true;
            Dragable   = true;

            int entrycount = SourceBook.Entries.Count;

            int y = entrycount <= 16 ? 0 : 25;

            AddPage(0);

            AddBackground(4, 39, 391, 313 + y, 9200);
            AddImageTiled(8, 45, 380, 53, 2624);

            AddHtmlLocalized(7, 50, 380, 53, 1115428, string.Format("@{0}@{1}@{2}@{3}", MarkScrollAmount.ToString(), RuneAmount.ToString(), Checked.Count, Blank.ToString()), EntryColor, false, false); // <CENTER>Pen of Wisdom<br>(Mark Scrolls: ~1_VAL~, Runes: ~2_VAL~ | Selected: ~3_VAL~, Blank: ~4_VAL~)</CENTER>

            AddImageTiled(8, 101, 188, 220, 2624);
            AddImageTiled(199, 101, 188, 220, 2624);

            AddButton(12, 325 + y, 4017, 4018, 20, GumpButtonType.Reply, 0);
            AddHtmlLocalized(48, 326 + y, 78, 20, 1006045, EntryColor, false, false); // Cancel

            AddButton(153, 325 + y, 4011, 4012, 21, GumpButtonType.Reply, 0);
            AddHtmlLocalized(189, 326 + y, 78, 20, 1115427, EntryColor, false, false); // Select All

            AddButton(309, 325 + y, 4023, 4024, 22, GumpButtonType.Reply, 0);
            AddHtmlLocalized(344, 326 + y, 78, 20, 1156596, EntryColor, false, false); // Okay

            string description;

            int page = 1;
            int yy   = 0;

            AddPage(page);

            for (int i = 0; i < entrycount; i++)
            {
                if (page > 1)
                {
                    AddButton(50, 325, 4014, 4015, 0, GumpButtonType.Page, page - 1);
                    AddHtmlLocalized(85, 326, 150, 20, 1011067, EntryColor, false, false); // Previous page
                }

                description = SourceBook.Entries[i].Description;

                if (description == null)
                {
                    if (i + 1 < 10)
                    {
                        description = "0" + (i + 1).ToString();
                    }
                    else
                    {
                        description = (i + 1).ToString();
                    }
                }

                if (yy < 8)
                {
                    AddButton(15, 110 + (yy * 25), Checked.Contains(SourceBook.Entries[i]) ? 211 : 210, Checked.Contains(SourceBook.Entries[i]) ? 210 : 211, i, GumpButtonType.Reply, 0);
                    AddLabelCropped(45, 110 + (yy * 25), 115, 17, RunebookGump.GetMapHue(SourceBook.Entries[i].Map), string.Format("{0}", description));
                }
                else
                {
                    AddButton(205, 110 + ((yy - 8) * 25), Checked.Contains(SourceBook.Entries[i]) ? 211 : 210, Checked.Contains(SourceBook.Entries[i]) ? 210 : 211, i, GumpButtonType.Reply, 0);
                    AddLabelCropped(235, 110 + ((yy - 8) * 25), 115, 17, RunebookGump.GetMapHue(SourceBook.Entries[i].Map), string.Format("{0}", description));
                }

                yy++;

                bool pages = (i + 1) % 16 == 0;

                if (pages && entrycount - 1 != i)
                {
                    AddButton(200, 325, 4005, 4006, 0, GumpButtonType.Page, page + 1);
                    AddHtmlLocalized(235, 326, 150, 20, 1011066, EntryColor, false, false); // Next page
                    page++;
                    AddPage(page);
                    yy = 0;
                }
            }
        }
        private bool giveMoney(Mobile to, int amount, bool mainwin)
        {
            if (to == null || to.Deleted || amount <= 0 || to.Backpack == null)
            {
                return(false);
            }

            if (itemPrize && mainwin)
            {
                Item WinningDeed = new Item(5360);
                WinningDeed.Name     = "Congratulations! You won the Lotterys Main Prize. Page a GM or Seer and show him this Deed!";
                WinningDeed.Hue      = 388;
                WinningDeed.LootType = (LootType)2; // blessed
                to.AddToBackpack(WinningDeed);
                if (debug)
                {
                    Console.WriteLine("Outgiven: WinningDeed");
                }
            }

            else
            {
                Container playerPack = to.Backpack;
                int       itemCount  = playerPack.GetAmount(typeof(Item), true);
                int       maxItems   = playerPack.MaxItems;

                if ((amount / 1000000 + itemCount) < (maxItems - 2) || amount <= 1000000)
                {
                    if (debug)
                    {
                        Console.WriteLine("Giving out: " + amount + " Gold");
                    }

                    while (amount >= 1000000)
                    {
                        to.AddToBackpack(new BankCheck(1000000));
                        amount -= 1000000;
                    }

                    if (amount >= 5000)
                    {
                        to.AddToBackpack(new BankCheck(amount));
                    }
                    else
                    {
                        if (amount > 0)
                        {
                            to.AddToBackpack(new Gold(amount));
                        }
                    }
                }
                else
                {
                    if (debug)
                    {
                        Console.WriteLine("Giving out GoldDeed. Value:" + amount);
                    }

                    Item GoldDeed = new Item(5360);
                    GoldDeed.Name     = "Congratulations! You have won " + amount + " gold in the DFI Lottery. Page a GM or Seer and show him this Deed!";
                    GoldDeed.Hue      = 1448;
                    GoldDeed.LootType = (LootType)2; // blessed
                    to.AddToBackpack(GoldDeed);
                }
            }

            return(true);
        }
示例#6
0
        public void TryRepairCannon(Mobile from)
        {
            Container pack = from.Backpack;
            Container hold = Galleon.GalleonHold;

            if (pack == null)
            {
                return;
            }

            //double ingotsNeeded = 36 * (100 - Durability);
            double ingotsNeeded = 36 * (int)DamageState;

            ingotsNeeded -= ((double)from.Skills[SkillName.Blacksmith].Value / 200.0) * ingotsNeeded;

            double min     = ingotsNeeded / 10;
            double ingots1 = pack.GetAmount(typeof(IronIngot));
            double ingots2 = hold != null?hold.GetAmount(typeof(IronIngot)) : 0;

            double ingots = ingots1 + ingots2;
            double ingotsUsed, percRepaired;

            if (ingots < min)
            {
                from.SendLocalizedMessage(1116603, ((int)min).ToString());                 //You need a minimum of ~1_METAL~ iron ingots to repair this cannon.
                return;
            }

            if (ingots >= ingotsNeeded)
            {
                ingotsUsed   = ingotsNeeded;
                percRepaired = 100;
            }
            else
            {
                ingotsUsed   = ingots;
                percRepaired = (ingots / ingotsNeeded) * 100;
            }

            double toConsume = 0;
            double temp      = ingotsUsed;

            if (ingotsUsed > 0 && ingots1 > 0)
            {
                toConsume = Math.Min(ingotsUsed, ingots1);
                pack.ConsumeTotal(typeof(IronIngot), (int)toConsume);
                ingotsUsed -= toConsume;
            }

            if (hold != null && ingotsUsed > 0 && ingots2 > 0)
            {
                toConsume = Math.Min(ingotsUsed, ingots2);
                hold.ConsumeTotal(typeof(IronIngot), (int)toConsume);
            }

            m_Hits += (int)((MaxHits - m_Hits) * (percRepaired / 100));
            if (m_Hits > MaxHits)
            {
                m_Hits = MaxHits;
            }
            InvalidateDamageState();

            percRepaired += Durability;
            if (percRepaired > 100)
            {
                percRepaired = 100;
            }

            from.SendLocalizedMessage(1116605, String.Format("{0}\t{1}", ((int)temp).ToString(), ((int)percRepaired).ToString()));             //You make repairs to the cannon using ~1_METAL~ ingots. The cannon is now ~2_DMGPCT~% repaired.
        }
示例#7
0
        public PenOfWisdomGump(Mobile from, PenOfWisdom pen, Runebook sourcebook, Runebook copybook, List <RunebookEntry> list) : base(50, 50)
        {
            Container bp = from.Backpack;

            m_Pen              = pen;
            m_SourceBook       = sourcebook;
            m_CopyBook         = copybook;
            m_MarkScrollAmount = bp.GetAmount(typeof(MarkScroll), true);
            m_RuneAmount       = bp.GetAmount(typeof(RecallRune), true);
            m_Blank            = copybook.MaxEntries - copybook.Entries.Count;

            if (list == null)
            {
                m_Checked = new List <RunebookEntry>();
            }
            else
            {
                m_Checked = list;
            }

            Closable   = false;
            Disposable = true;
            Dragable   = true;

            AddPage(0);
            AddBackground(4, 39, 391, 313, 9200);
            AddImageTiled(8, 45, 380, 53, 2624);
            AddHtmlLocalized(7, 50, 380, 53, 1115428, String.Format("{0}\t{1}\t{2}\t{3}", m_MarkScrollAmount.ToString(), m_RuneAmount.ToString(), m_Checked.Count, m_Blank.ToString()), 0xFFFFFF, false, false); // <CENTER>Pen of Wisdom<br>(Mark Scrolls: ~1_VAL~, Runes: ~2_VAL~ | Selected: ~3_VAL~, Blank: ~4_VAL~)</CENTER>

            AddImageTiled(8, 101, 188, 220, 2624);
            AddImageTiled(199, 101, 188, 220, 2624);
            AddButton(12, 325, 4017, 4018, 20, GumpButtonType.Reply, 0);
            AddLabel(48, 325, 2100, @"Cancel");
            AddButton(153, 325, 4011, 4012, 21, GumpButtonType.Reply, 0);
            AddHtmlLocalized(189, 325, 78, 22, 1115427, 0xFFFFFF, false, false); // Select All
            AddButton(309, 325, 4023, 4024, 22, GumpButtonType.Reply, 0);
            AddLabel(344, 325, 2100, @"Okay");

            string description;

            for (int i = 0; i < sourcebook.Entries.Count; i++)
            {
                description = sourcebook.Entries[i].Description;

                if (description == null)
                {
                    if (i + 1 < 10)
                    {
                        description = "0" + (i + 1).ToString();
                    }
                    else
                    {
                        description = (i + 1).ToString();
                    }
                }

                if (i < 8)
                {
                    AddButton(15, 110 + i * 25, m_Checked.Contains(sourcebook.Entries[i]) ? 211 : 210, m_Checked.Contains(sourcebook.Entries[i]) ? 210 : 211, i, GumpButtonType.Reply, 0);
                    AddLabel(45, 110 + i * 25, RunebookGump.GetMapHue(sourcebook.Entries[i].Map), String.Format("{0}", description));
                }
                else
                {
                    AddButton(205, 110 + ((i - 8) * 25), m_Checked.Contains(sourcebook.Entries[i]) ? 211 : 210, m_Checked.Contains(sourcebook.Entries[i]) ? 210 : 211, i, GumpButtonType.Reply, 0);
                    AddLabel(235, 110 + ((i - 8) * 25), RunebookGump.GetMapHue(sourcebook.Entries[i].Map), String.Format("{0}", description));
                }
            }
        }