Пример #1
0
        public int GetLabelID(CommodityBrokerEntry entry)
        {
            /*Item[] items = BuyPack.FindItemsByType(typeof(CommodityDeed));
             *
             *          foreach(Item item in items)
             *          {
             *                  if(item is CommodityDeed)
             *                  {
             *                          CommodityDeed deed = (CommodityDeed)item;
             *
             *                          if(deed.Commodity != null && deed.Commodity.GetType() == entry.CommodityType)
             *                                  return deed.Commodity.ItemID;
             *                  }
             *          }
             *
             *          Item item = Loot.Construct(entry.CommodityType);
             *          int id = 0;
             *
             *          if(item != null)
             *          {
             *                  id = item.ItemID;
             *                  item.Delete();
             *          }*/

            return(entry != null ? entry.Label : 1);
        }
Пример #2
0
        public void WithdrawInventory(Mobile from, int amount, CommodityBrokerEntry entry)
        {
            if (from == null || Plot == null || entry == null || !m_CommodityEntries.Contains(entry))
            {
                return;
            }

            Container pack = from.Backpack;

            if (pack != null)
            {
                while (amount > 60000)
                {
                    CommodityDeed deed = new CommodityDeed();
                    Item          item = Loot.Construct(entry.CommodityType);
                    item.Amount = 60000;
                    deed.SetCommodity(item);
                    pack.DropItem(deed);
                    amount      -= 60000;
                    entry.Stock -= 60000;
                }

                CommodityDeed deed2   = new CommodityDeed();
                Item          newitem = Loot.Construct(entry.CommodityType);
                newitem.Amount = amount;
                deed2.SetCommodity(newitem);
                pack.DropItem(deed2);
                entry.Stock -= amount;
            }

            if (Plot != null && from == Plot.Owner)
            {
                from.SendLocalizedMessage(1150221, string.Format("{0}\t#{1}\t{2}", amount.ToString(), entry.Label, Plot.ShopName != null ? Plot.ShopName : "a shop with no name")); // You have removed ~1_QUANTITY~ units of ~2_ITEMNAME~ from the inventory of "~3_SHOPNAME~"
            }
        }
Пример #3
0
        public bool TryAddBrokerEntry(Item item, Mobile from)
        {
            Item realItem = item;

            if (item is CommodityDeed)
            {
                realItem = ((CommodityDeed)item).Commodity;
            }

            Type type   = realItem.GetType();
            int  amount = realItem.Amount;

            if (HasType(type))
            {
                return(false);
            }

            CommodityBrokerEntry entry = new CommodityBrokerEntry(realItem, this, amount);

            m_CommodityEntries.Add(entry);

            if (amount > 0)
            {
                from.SendLocalizedMessage(1150220, string.Format("{0}\t#{1}\t{2}", amount.ToString(), entry.Label, Plot.ShopName == null ? "an unnamed shop" : Plot.ShopName)); // You have added ~1_QUANTITY~ units of ~2_ITEMNAME~ to the inventory of "~3_SHOPNAME~"
            }
            item.Delete();

            return(true);
        }
Пример #4
0
        public void AddInventory(Mobile from, Item item)
        {
            Type type        = item.GetType();
            int  amountToAdd = item.Amount;

            if (item is CommodityDeed deed)
            {
                type        = deed.Commodity.GetType();
                amountToAdd = deed.Commodity.Amount;
            }

            for (var index = 0; index < m_CommodityEntries.Count; index++)
            {
                CommodityBrokerEntry entry = m_CommodityEntries[index];

                if (entry.CommodityType == type)
                {
                    entry.Stock += amountToAdd;
                    item.Delete();

                    if (from != null && Plot.Owner == from)
                    {
                        from.SendLocalizedMessage(1150220, $"{amountToAdd.ToString()}\t#{entry.Label}\t{(Plot.ShopName == null ? "an unnamed shop" : Plot.ShopName)}"); // You have added ~1_QUANTITY~ units of ~2_ITEMNAME~ to the inventory of "~3_SHOPNAME~"
                    }

                    break;
                }
            }
        }
Пример #5
0
        public ConfirmBuyCommodityGump(CommodityBroker broker, int amount, CommodityBrokerEntry entry, bool buy, Gump g)
            : base(660, 520)
        {
            m_Broker = broker;
            m_Amount = amount;
            m_Entry  = entry;
            _Gump    = g;

            AddHtmlLocalized(10, 10, 640, 18, 1114513, "#1150636", RedColor16, false, false);  // Commodity Broker

            if (m_Broker.Plot.ShopName != null && m_Broker.Plot.ShopName.Length > 0)
            {
                AddHtml(10, 37, 640, 18, Color(FormatStallName(m_Broker.Plot.ShopName), BlueColor), false, false);
            }
            else
            {
                AddHtmlLocalized(10, 37, 640, 18, 1114513, "#1150314", BlueColor16, false, false); // This Shop Has No Name
            }

            AddHtmlLocalized(10, 55, 310, 18, 1114514, "#1150313", BlueColor16, false, false); // Proprietor:
            AddHtml(330, 55, 320, 18, Color(String.Format("{0}", broker.Name), BlueColor), false, false);

            AddHtmlLocalized(10, 127, 640, 64, 1114513, "#1150666", RedColor16, false, false); // Please review the details of this transaction. If you wish to make this trade, click the TRADE button below. Otherwise, click the MAIN MENU button to return to the price list.

            if (buy)
            {
                int cost = entry.SellPricePer * amount;

                AddHtmlLocalized(10, 193, 210, 18, 1114514, "#1150144", OrangeColor16, false, false); // You are BUYING:
                AddHtmlLocalized(230, 193, 420, 18, m_Broker.GetLabelID(entry), DarkGreenColor16, false, false);

                AddHtmlLocalized(10, 213, 210, 18, 1114514, "#1150152", OrangeColor16, false, false); // Quantity to Buy:
                AddHtml(230, 213, 420, 18, Color(String.Format("{0}", amount), DarkGreenColor), false, false);

                AddHtmlLocalized(10, 233, 210, 18, 1114514, "#1150246", OrangeColor16, false, false); // Total Cost:
                AddHtml(230, 233, 420, 18, Color(FormatAmt(cost), DarkGreenColor), false, false);

                AddHtmlLocalized(230, 253, 420, 22, 1150143, OrangeColor16, false, false); // TRADE
                AddButton(190, 253, 0xFA5, 0xFA6, 1, GumpButtonType.Reply, 0);
            }
            else
            {
                int cost = entry.BuyPricePer * amount;

                AddHtmlLocalized(10, 193, 210, 18, 1114514, "#1150145", OrangeColor16, false, false); // You are SELLING:
                AddHtmlLocalized(230, 193, 420, 18, m_Broker.GetLabelID(entry), DarkGreenColor16, false, false);

                AddHtmlLocalized(10, 213, 210, 18, 1114514, "#1150153", OrangeColor16, false, false); // Quantity to Sell:
                AddHtml(230, 213, 420, 18, Color(String.Format("{0}", amount), DarkGreenColor), false, false);

                AddHtmlLocalized(10, 233, 210, 18, 1114514, "#1150251", OrangeColor16, false, false); // Gold You Will Receive:
                AddHtml(230, 233, 420, 18, Color(FormatAmt(cost), DarkGreenColor), false, false);

                AddHtmlLocalized(230, 253, 420, 22, 1150143, OrangeColor16, false, false); // TRADE
                AddButton(190, 253, 0xFA5, 0xFA6, 2, GumpButtonType.Reply, 0);
            }

            AddButton(10, 490, 0xFAE, 0xFAF, 3, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 490, 210, 20, 1149777, BlueColor16, false, false); // MAIN MENU
        }
Пример #6
0
        public int GetBuyCost(Mobile from, CommodityBrokerEntry entry, int amount)
        {
            int totalCost = entry.SellPricePer * amount;
            int toDeduct  = totalCost + (int)(totalCost * (ComissionFee / 100.0));

            return(toDeduct);
        }
Пример #7
0
		public void RemoveEntry(Mobile from, CommodityBrokerEntry entry)
		{
			if(m_CommodityEntries.Contains(entry))
			{
                if(entry.Stock > 0)
				    WithdrawInventory(from, GetStock(entry), entry);
				m_CommodityEntries.Remove(entry);
			}
		}
Пример #8
0
        public ConfirmRemoveEntryGump(CommodityBroker broker, int index)
        {
            m_Broker = broker;
            m_Index  = index;

            if (index >= 0 && index < m_Broker.CommodityEntries.Count)
            {
                m_Entry = m_Broker.CommodityEntries[index];
            }
        }
Пример #9
0
 public void RemoveEntry(Mobile from, CommodityBrokerEntry entry)
 {
     if (m_CommodityEntries.Contains(entry))
     {
         if (entry.Stock > 0)
         {
             WithdrawInventory(from, GetStock(entry), entry);
         }
         m_CommodityEntries.Remove(entry);
     }
 }
Пример #10
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write(0);

            writer.Write(m_CommodityEntries.Count);
            for (var index = 0; index < m_CommodityEntries.Count; index++)
            {
                CommodityBrokerEntry entry = m_CommodityEntries[index];
                entry.Serialize(writer);
            }
        }
Пример #11
0
        private bool HasType(Type type)
        {
            for (var index = 0; index < m_CommodityEntries.Count; index++)
            {
                CommodityBrokerEntry entry = m_CommodityEntries[index];

                if (entry.CommodityType == type)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #12
0
        public override bool HasValidEntry(Mobile m)
        {
            for (var index = 0; index < m_CommodityEntries.Count; index++)
            {
                CommodityBrokerEntry entry = m_CommodityEntries[index];

                if (entry.Stock > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #13
0
        public ConfirmBuyCommodityGump(CommodityBroker broker, int amount, CommodityBrokerEntry entry, bool buy)
        {
            m_Broker = broker;
            m_Amount = amount;
            m_Entry  = entry;

            AddHtmlLocalized(205, 10, 200, 18, 1150636, RedColor16, false, false); // Commodity Broker

            if (m_Broker.Plot.ShopName != null && m_Broker.Plot.ShopName.Length > 0)
            {
                AddHtml(173, 40, 173, 18, Color(FormatStallName(m_Broker.Plot.ShopName), BlueColor), false, false); // "~1_NAME~"
            }
            else
            {
                AddHtmlLocalized(180, 40, 200, 18, 1150314, BlueColor16, false, false); // This Shop Has No Name
            }
            AddHtml(173, 65, 173, 18, Color(FormatBrokerName(String.Format("Proprietor: {0}", broker.Name)), BlueColor), false, false);

            AddHtmlLocalized(10, 100, 500, 40, 1150666, RedColor16, false, false);             // Please review the details of this transaction. If you wish to make this trade, click the TRADE button below. Otherwise, click the MAIN MENU button to return to the price list.

            if (buy)
            {
                int cost = entry.SellPricePer * amount;

                AddHtmlLocalized(10, 150, 260, 18, 1150245, OrangeColor16, false, false);                 // <DIV ALIGN=RIGHT>You are purchasing:</DIV>
                AddItem(230, 210, m_Broker.GetItemID(entry));

                AddHtmlLocalized(110, 350, 150, 18, 1150246, OrangeColor16, false, false); // Total Cost:
                AddHtml(180, 350, 150, 18, Color(FormatAmt(cost), OrangeColor), false, false);

                AddHtmlLocalized(170, 380, 120, 18, 1150247, OrangeColor16, false, false);                 // <DIV ALIGN=RIGHT>PURCHASE</DIV>
                AddButton(180, 380, 4005, 4007, 1, GumpButtonType.Reply, 0);
            }
            else
            {
                int cost = entry.BuyPricePer * amount;

                AddHtmlLocalized(10, 150, 260, 18, 1150250, OrangeColor16, false, false); // <DIV ALIGN=RIGHT>You are selling:</DIV>
                AddItem(230, 210, m_Broker.GetItemID(entry));

                AddHtmlLocalized(50, 350, 160, 18, 1150251, OrangeColor16, false, false); // Gold you will recieve:
                AddHtml(190, 350, 150, 18, Color(FormatAmt(cost), OrangeColor), false, false);

                AddHtmlLocalized(200, 380, 60, 18, 1150249, OrangeColor16, false, false);                 // <DIV ALIGN=RIGHT>SELL</DIV>
                AddButton(190, 380, 4005, 4007, 2, GumpButtonType.Reply, 0);
            }

            //AddHtmlLocalized(x, y, 120, 18, 1150248, OrangeColor, false, false); // <DIV ALIGN=RIGHT>CONFIRM</DIV>
        }
Пример #14
0
        // Called when a player BUYS the commodity from teh broker...this is f*****g confusing
        public void TryBuyCommodity(Mobile from, CommodityBrokerEntry entry, int amount)
        {
            int totalCost = entry.SellPricePer * amount;
            int toAdd     = totalCost + (int)(totalCost * (ComissionFee / 100.0));

            if (Banker.Withdraw(from, totalCost, true))
            {
                from.SendLocalizedMessage(1150643, string.Format("{0}\t#{1}", amount.ToString("###,###,###"), entry.Label)); // A commodity deed worth ~1_AMOUNT~ ~2_ITEM~ has been placed in your backpack.
                WithdrawInventory(from, amount, entry);
                BankBalance += toAdd;
            }
            else
            {
                from.SendLocalizedMessage(1150252); // You do not have the funds needed to make this trade available in your bank box. Brokers are only able to transfer funds from your bank box. Please deposit the necessary funds into your bank box and try again.
            }
        }
Пример #15
0
        public override int GetWeeklyFee()
        {
            int total = 0;

            for (var index = 0; index < m_CommodityEntries.Count; index++)
            {
                CommodityBrokerEntry entry = m_CommodityEntries[index];

                if (entry.SellPricePer > 0)
                {
                    total += entry.Stock * entry.SellPricePer;
                }
            }

            double perc = total * .05;

            return((int)perc);
        }
Пример #16
0
        public bool SellCommodityControl(Mobile from, CommodityBrokerEntry entry, int amount)
        {
            int  totalCost = entry.BuyPricePer * amount;
            Type type      = entry.CommodityType;

            if (from.Backpack != null)
            {
                int total           = amount;
                int typeAmount      = from.Backpack.GetAmount(type);
                int commodityAmount = GetCommodityType(from.Backpack, type);

                if (typeAmount + commodityAmount >= total)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #17
0
		public bool TryAddBrokerEntry(Item item, Mobile from)
		{
            Item realItem = item;

            if (item is CommodityDeed)
                realItem = ((CommodityDeed)item).Commodity;

            Type type = realItem.GetType();
            int amount = realItem.Amount;

			if(HasType(type))
				return false;

            CommodityBrokerEntry entry = new CommodityBrokerEntry(realItem, this, amount);
            m_CommodityEntries.Add(entry);

            if(amount > 0)
                from.SendLocalizedMessage(1150220, String.Format("{0}\t#{1}\t{2}", amount.ToString(), entry.Label, Plot.ShopName == null ? "an unnamed shop" : Plot.ShopName)); // You have added ~1_QUANTITY~ units of ~2_ITEMNAME~ to the inventory of "~3_SHOPNAME~"

            item.Delete();

			return true;
		}
Пример #18
0
        // Called when a player SELLs the commodity from teh broker...this is f*****g confusing
        public void TrySellCommodity(Mobile from, CommodityBrokerEntry entry, int amount)
        {
            int  totalCost = entry.BuyPricePer * amount;
            Type type      = entry.CommodityType;

            if (BankBalance < totalCost)
            {
                //No message, this should have already been handled elsewhere
            }
            else if (from.Backpack != null)
            {
                int total           = amount;
                int typeAmount      = from.Backpack.GetAmount(type);
                int commodityAmount = GetCommodityType(from.Backpack, type);

                if (typeAmount + commodityAmount < total)
                {
                    from.SendLocalizedMessage(1150667); // You do not have the requested amount of that commodity (either in item or deed form) in your backpack to trade. Note that commodities cannot be traded from your bank box.
                }
                else if (Banker.Deposit(from, totalCost))
                {
                    TakeItems(from.Backpack, type, ref total);

                    if (total > 0)
                    {
                        TakeCommodities(from.Backpack, type, ref total);
                    }

                    BankBalance -= totalCost + (int)(totalCost * (ComissionFee / 100.0));
                    from.SendLocalizedMessage(1150668, string.Format("{0}\t#{1}", amount.ToString(), entry.Label)); // You have sold ~1_QUANTITY~ units of ~2_COMMODITY~ to the broker. These have been transferred from deeds and/or items in your backpack.
                }
                else
                {
                    from.SendLocalizedMessage(1150265); // Your bank box cannot hold the proceeds from this transaction.
                }
            }
        }
Пример #19
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            switch (info.ButtonID)
            {
            case 0: return;

            case 1:     // Withdraw
                if (m_Index >= 0 && m_Index < m_Broker.CommodityEntries.Count)
                {
                    CommodityBrokerEntry entry = m_Broker.CommodityEntries[m_Index];
                    int amount = 0;

                    TextRelay relay = info.TextEntries[0];

                    try
                    {
                        amount = Convert.ToInt32(relay.Text);
                    }
                    catch (Exception e) { Server.Diagnostics.ExceptionLogging.LogException(e); }

                    if (amount <= 0 || amount > entry.Stock)
                    {
                        from.SendLocalizedMessage(1150215);     // You have entered an invalid value, or a non-numeric value. Please try again.
                    }
                    else
                    {
                        m_Broker.WithdrawInventory(from, amount, entry);
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1150642);     // You did not select a commodity.
                }
                break;

            case 2:     // Main Menu
                from.SendGump(new CommodityBrokerGump(m_Broker, from));
                return;

            case 3:     // Remove Entry
                if (m_Index >= 0 && m_Index < m_Broker.CommodityEntries.Count)
                {
                    from.SendGump(new ConfirmRemoveEntryGump(m_Broker, m_Index));
                    return;
                }
                else
                {
                    from.SendLocalizedMessage(1150642);     // You did not select a commodity.
                }
                break;

            case 400:
                from.SendGump(new ViewInventoryGump(m_Broker, -1, m_Page - 1));
                return;

            case 401:
                from.SendGump(new ViewInventoryGump(m_Broker, -1, m_Page + 1));
                return;

            case 501:
                from.SendGump(new CommodityBrokerGump(m_Broker, from));
                return;

            default:
            {
                if (info.ButtonID < 1500)         // SELECT ENTRY
                {
                    int id = info.ButtonID - 1000;

                    if (id >= 0 && id < m_Broker.CommodityEntries.Count)
                    {
                        from.SendGump(new ViewInventoryGump(m_Broker, id, m_Page));
                        return;
                    }
                }
                else if (info.ButtonID < 2000)         // UP
                {
                    int id = info.ButtonID - 1500;

                    if (id > 0 && id < m_Broker.CommodityEntries.Count)
                    {
                        CommodityBrokerEntry entry = m_Broker.CommodityEntries[id];
                        int idx = m_Broker.CommodityEntries.IndexOf(entry);

                        m_Broker.CommodityEntries.Remove(entry);
                        m_Broker.CommodityEntries.Insert(idx - 1, entry);
                        //m_Broker.CommodityEntries[id] = m_Broker.CommodityEntries[id-1];
                        //m_Broker.CommodityEntries[id-1] = entry;
                    }
                }
                else         // DOWN
                {
                    int id = info.ButtonID - 2000;

                    if (id >= 0 && id < m_Broker.CommodityEntries.Count - 1)
                    {
                        CommodityBrokerEntry entry = m_Broker.CommodityEntries[id];
                        int idx = m_Broker.CommodityEntries.IndexOf(entry);

                        m_Broker.CommodityEntries.Remove(entry);
                        m_Broker.CommodityEntries.Insert(idx + 1, entry);
                        //m_Broker.CommodityEntries[id] = m_Broker.CommodityEntries[id+1];
                        //m_Broker.CommodityEntries[id+1] = entry;
                    }
                }

                break;
            }
            }

            from.SendGump(new ViewInventoryGump(m_Broker, m_Index));
        }
Пример #20
0
        public CommodityInventoryGump(CommodityBroker broker, int index, bool buy, int page, int cliloc)
            : base(655, 520)
        {
            m_Broker  = broker;
            m_Entries = broker.CommodityEntries;
            m_Buy     = buy;
            m_Page    = page;
            m_Index   = index;

            AddHtmlLocalized(10, 10, 640, 18, 1114513, "#1150636", RedColor16, false, false);  // Commodity Broker

            if (m_Broker.Plot.ShopName != null && m_Broker.Plot.ShopName.Length > 0)
            {
                AddHtml(10, 37, 640, 18, Color(FormatStallName(m_Broker.Plot.ShopName), BlueColor), false, false);
            }
            else
            {
                AddHtmlLocalized(10, 37, 640, 18, 1114513, "#1150314", BlueColor16, false, false); // This Shop Has No Name
            }

            AddHtmlLocalized(10, 55, 310, 18, 1114514, "#1150313", BlueColor16, false, false); // Proprietor:
            AddHtml(330, 55, 320, 18, Color(String.Format("{0}", broker.Name), BlueColor), false, false);

            if (cliloc != 0)
            {
                if (cliloc == 1150654)
                {
                    /* This broker trades in commodities. Commodity brokers can buy and sell most commodities, either in item or deed form.
                     * The menu shows all commodities this broker will deal in.<BR><BR>The center column lists the commodities by name.
                     * The columns on the left indicate how much of the commodity the broker has available for purchase, and the price per unit.
                     * The right-hand columns indicate how much of the commodity the broker is willing to buy from you and the price it will pay per unit.
                     * <BR><BR>If you wish to buy that commodity, click the button to the left of it to select it, then enter the quantity you wish to buy in the QUANTITY field below.
                     * If you wish to sell a commodity to the broker, click the button to the right of it and enter the quantity you wish to sell below. Finally, click the "TRADE" button.
                     * You will be presented with a confirmation window that will show the item being traded, the quantity, and how much gold will change hands.<BR><BR>If a broker lists a price but shows 0 quantity available,
                     * the broker may be out of stock (unable to sell to you) or may have reached its purchasing limit (unable to buy from you). All gold transactions are between your bank box and the commodity broker.
                     * Gold or bank checks in your backpack cannot be used for these trades. Commodities are traded between your backpack and the broker, and commodity items/deeds in your bank box cannot be used for these trades.
                     */
                    AddHtmlLocalized(10, 127, 640, 354, 1150654, OrangeColor16, true, true);
                }
                else
                {
                    AddHtmlLocalized(10, 127, 640, 354, 1114513, String.Format("#{0}", cliloc), OrangeColor16, false, false);
                }

                AddButton(10, 490, 0xFAE, 0xFAF, 999, GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 490, 210, 20, 1149777, BlueColor16, false, false); // MAIN MENU
            }
            else
            {
                AddButton(190, 91, 4005, 4007, 1, GumpButtonType.Reply, 0);
                AddHtmlLocalized(230, 91, 420, 22, 1150392, OrangeColor16, false, false);              // INFORMATION

                AddHtmlLocalized(10, 124, 54, 20, 1150656, OrangeColor16, false, false);               // BUY
                AddHtmlLocalized(70, 124, 54, 20, 1150659, OrangeColor16, false, false);               // PRICE
                AddHtmlLocalized(130, 124, 109, 20, 1150658, OrangeColor16, false, false);             // LIMIT
                AddHtmlLocalized(245, 124, 164, 20, 1114513, "#1150655", OrangeColor16, false, false); // COMMODITY
                AddHtmlLocalized(415, 124, 54, 20, 1114514, "#1150659", OrangeColor16, false, false);  // PRICE
                AddHtmlLocalized(475, 124, 109, 20, 1114514, "#1150658", OrangeColor16, false, false); // LIMIT
                AddHtmlLocalized(590, 124, 54, 20, 1114514, "#1150657", OrangeColor16, false, false);  // SELL

                if (m_Entries.Count != 0)
                {
                    int y       = 153;
                    int perPage = 10;

                    if (index > -1)
                    {
                        m_Page = index <= 0 ? 0 : index / perPage;
                    }

                    int start = page * perPage;
                    int count = 0;

                    for (int i = start; i < m_Entries.Count && /*index < perPage*/ count <= perPage; i++)
                    {
                        CommodityBrokerEntry entry = m_Entries[i];

                        int stock     = entry.Stock;
                        int buyLimit  = entry.ActualSellLimit;
                        int sellLimit = entry.ActualBuyLimit;

                        // Sell to player
                        if (entry.SellPricePer > 0)
                        {
                            AddHtml(70, y, 54, 20, Color(FormatAmt(entry.SellPricePer), OrangeColor), false, false);
                        }
                        else
                        {
                            AddHtmlLocalized(70, y, 54, 20, 1150397, OrangeColor16, false, false); // N/A
                        }

                        if (entry.SellPricePer > 0 && entry.SellLimit > 0)
                        {
                            AddHtml(130, y, 109, 20, Color(FormatAmt(buyLimit), OrangeColor), false, false);
                        }

                        // what we're selling/buying
                        AddHtmlLocalized(200, y, 164, 20, 1114514, String.Format("#{0}", entry.Label), OrangeColor16, false, false); // <DIV ALIGN=RIGHT>~1_TOKEN~</DIV>
                        AddTooltip(entry.Label);

                        // buy from player

                        if (entry.BuyPricePer > 0)
                        {
                            AddHtml(415, y, 54, 20, Color(AlignRight(FormatAmt(entry.BuyPricePer)), OrangeColor), false, false);
                        }
                        else
                        {
                            AddHtmlLocalized(415, y, 54, 20, 1150397, OrangeColor16, false, false); // N/A
                        }

                        if (entry.BuyPricePer > 0 && entry.BuyLimit > 0)
                        {
                            AddHtml(475, y, 109, 20, (Color(AlignRight(FormatAmt(sellLimit)), OrangeColor)), false, false);
                        }

                        //Buttons
                        if (entry.PlayerCanBuy(0))
                        {
                            AddRadio(10, y, 0xFA5, 0xFA6, false, 2 + i);
                        }

                        if (entry.PlayerCanSell(0))
                        {
                            AddRadio(590, y, 0xFAE, 0xFAF, false, 102 + i);
                        }

                        y += 20;
                        count++;
                    }

                    if (m_Page > 0) // back
                    {
                        AddButton(60, 362, 0xFAE, 0xFAF, 400, GumpButtonType.Reply, 0);
                        AddHtmlLocalized(100, 362, 230, 40, 1044044, OrangeColor16, false, false); // PREV PAGE
                    }

                    if (m_Entries.Count - start > perPage) // forward
                    {
                        AddButton(570, 362, 0xFA5, 0xFA6, 401, GumpButtonType.Reply, 0);
                        AddHtmlLocalized(330, 362, 230, 40, 1114514, "#1044045", OrangeColor16, false, false); // NEXT PAGE
                    }

                    AddHtmlLocalized(10, 421, 210, 22, 1114514, "#1150662", BlueColor16, false, false); // QUANTITY
                    AddBackground(230, 421, 420, 22, 0x2486);
                    AddTextEntry(232, 423, 416, 18, LabelHueBlue, 0, "");

                    AddButton(190, 445, 4005, 4007, 500, GumpButtonType.Reply, 0);
                    AddHtmlLocalized(230, 445, 420, 22, 1077761, OrangeColor16, false, false); // TRADE
                }
                else
                {
                    AddHtmlLocalized(10, 153, 640, 20, 1114513, "#1150638", OrangeColor16, false, false); // There are no commodities in this broker's inventory.
                }
            }
        }
Пример #21
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            if (info.ButtonID == 0)
            {
                return;
            }
            if (info.ButtonID == 1)
            {
                from.SendGump(new BazaarInformationGump(0, 1150644, new SetPricesAndLimitsGump(m_Broker, m_Index, m_Page)));
                return;
            }
            else if (info.ButtonID == 400) // back page
            {
                from.SendGump(new SetPricesAndLimitsGump(m_Broker, -1, m_Page - 1));
                return;
            }
            else if (info.ButtonID == 401) // forward page
            {
                from.SendGump(new SetPricesAndLimitsGump(m_Broker, -1, m_Page + 1));
                return;
            }
            else if (info.ButtonID == 500) // SET PRICES
            {
                if (m_Index >= 0 && m_Index < m_Broker.CommodityEntries.Count)
                {
                    CommodityBrokerEntry entry = m_Broker.CommodityEntries[m_Index];

                    int buyAt   = entry.BuyPricePer;
                    int buyLmt  = entry.BuyLimit;
                    int sellAt  = entry.SellPricePer;
                    int sellLmt = entry.SellLimit;

                    TextRelay relay1 = info.TextEntries[0];
                    TextRelay relay2 = info.TextEntries[1];
                    TextRelay relay3 = info.TextEntries[2];
                    TextRelay relay4 = info.TextEntries[3];
                    try
                    {
                        buyAt = Convert.ToInt32(relay1.Text);
                    }
                    catch (Exception e) { Server.Diagnostics.ExceptionLogging.LogException(e); }
                    try
                    {
                        buyLmt = Convert.ToInt32(relay2.Text);
                    }
                    catch (Exception e) { Server.Diagnostics.ExceptionLogging.LogException(e); }
                    try
                    {
                        sellAt = Convert.ToInt32(relay3.Text);
                    }
                    catch (Exception e) { Server.Diagnostics.ExceptionLogging.LogException(e); }
                    try
                    {
                        sellLmt = Convert.ToInt32(relay4.Text);
                    }
                    catch (Exception e) { Server.Diagnostics.ExceptionLogging.LogException(e); }

                    if (buyLmt < 0 || buyLmt > 60000 || sellLmt < 0 || sellLmt > 60000)
                    {
                        from.SendLocalizedMessage(1150776); // You have entered an invalid numeric value. Negative values are not allowed. Trade quantities are limited to 60,000 per transaction.
                    }
                    else
                    {
                        entry.BuyPricePer  = buyAt;
                        entry.BuyLimit     = buyLmt;
                        entry.SellPricePer = sellAt;
                        entry.SellLimit    = sellLmt;
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1150642); // You did not select a commodity.
                }
            }
            else if (info.ButtonID == 501) // Main Menu
            {
                from.SendGump(new CommodityBrokerGump(m_Broker, from));
                return;
            }
            else
            {
                int id = info.ButtonID - 2;

                if (id >= 0 && id < m_Broker.CommodityEntries.Count)
                {
                    m_Index = id;
                }
            }

            from.SendGump(new SetPricesAndLimitsGump(m_Broker, m_Index, m_Page));
        }
Пример #22
0
        public ViewInventoryGump(CommodityBroker broker, int index, int page)
            : base(660, 520)
        {
            m_Broker = broker;
            m_Index  = index;
            m_Page   = page;

            AddHtmlLocalized(10, 10, 640, 18, 1114513, "#1150636", RedColor16, false, false); // Commodity Broker
            AddHtmlLocalized(10, 40, 640, 60, 1150641, OrangeColor16, false, false);          // Click the button next to the commodity...

            AddHtmlLocalized(235, 125, 150, 18, 1150140, OrangeColor16, false, false);        // ITEM
            AddHtmlLocalized(360, 125, 150, 18, 1150201, OrangeColor16, false, false);        // IN STOCK
            AddHtmlLocalized(440, 125, 150, 18, 1150639, OrangeColor16, false, false);        // SELECT
            AddHtmlLocalized(540, 125, 150, 18, 1150855, OrangeColor16, false, false);        // DOWN
            AddHtmlLocalized(600, 125, 150, 18, 1150856, OrangeColor16, false, false);        // UP

            int y       = 150;
            int perPage = 10;

            if (index > -1)
            {
                m_Page = index <= 0 ? 0 : index / perPage;
            }

            int start = page * perPage;
            int count = 1;

            for (int i = start; i < broker.CommodityEntries.Count && /*index <= perPage &&*/ count <= perPage; i++)
            {
                int col   = i == m_Index ? YellowColor : OrangeColor;
                int col16 = col == YellowColor ? YellowColor16 : OrangeColor16;
                CommodityBrokerEntry entry = broker.CommodityEntries[i];

                AddHtmlLocalized(1, y, 260, 18, 1114514, String.Format("#{0}", entry.Label), col16, false, false); // <DIV ALIGN=RIGHT>~1_TOKEN~</DIV>
                AddHtml(360, y, 55, 18, Color(AlignRight(FormatAmt(entry.Stock)), col), false, false);

                AddButton(440, y, 4014, 4016, 1000 + i, GumpButtonType.Reply, 0); // SELECT

                if (i > 0)
                {
                    AddButton(600, y, 250, 251, 1500 + i, GumpButtonType.Reply, 0); // UP
                }
                if (i < broker.CommodityEntries.Count - 1)
                {
                    AddButton(540, y, 252, 253, 2000 + i, GumpButtonType.Reply, 0); // DOWN
                }
                y += 20;
                count++;
            }

            if (m_Page > 0) // back
            {
                AddButton(162, 350, 4014, 4016, 400, GumpButtonType.Reply, 0);
            }

            if (broker.CommodityEntries.Count - start > perPage) // forward
            {
                AddButton(390, 350, 4005, 4007, 401, GumpButtonType.Reply, 0);
            }

            AddHtmlLocalized(160, 415, 150, 18, 1150202, OrangeColor16, false, false); // WITHDRAW
            AddBackground(250, 415, 360, 22, 9350);
            AddTextEntry(251, 415, 358, 20, LabelHueBlue, 0, "");
            AddButton(620, 415, 4014, 4016, 1, GumpButtonType.Reply, 0);

            if (index > -1)
            {
                AddHtml(50, 460, 200, 18, Color("Remove from Inventory", RedColor), false, false);
                AddButton(10, 460, 4020, 4022, 3, GumpButtonType.Reply, 0);
            }

            AddButton(10, 490, 4014, 4016, 501, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 490, 100, 18, 1149777, BlueColor16, false, false); // MAIN MENU
        }
Пример #23
0
		// Called when a player BUYS the commodity from teh broker...this is f*****g confusing
		public void TryBuyCommodity(Mobile from, CommodityBrokerEntry entry, int amount)
		{
			int totalCost = entry.SellPricePer * amount;
			int toDeduct = totalCost + (int)((double)totalCost * ((double)ComissionFee / 100.0));
			
			if(Banker.Withdraw(from, toDeduct))
			{
				from.SendLocalizedMessage(1150643, String.Format("{0}\t#{1}", amount.ToString("###,###,###"), entry.Label)); // A commodity deed worth ~1_AMOUNT~ ~2_ITEM~ has been placed in your backpack.
				WithdrawInventory(from, amount, entry);
                BankBalance += totalCost;
			}
			else
			{
				from.SendLocalizedMessage(1150252); // You do not have the funds needed to make this trade available in your bank box. Brokers are only able to transfer funds from your bank box. Please deposit the necessary funds into your bank box and try again.
			}
		}
Пример #24
0
        public SetPricesAndLimitsGump(CommodityBroker broker, int index, int page)
            : base(520, 520)
        {
            m_Broker = broker;
            m_Index  = index;
            m_Page   = page;

            AddHtmlLocalized(10, 10, 500, 18, 1114513, "#1150636", RedColor16, false, false);  // Commodity Broker

            AddButton(150, 40, 4005, 4007, 1, GumpButtonType.Reply, 0);
            AddHtmlLocalized(190, 40, 200, 18, 1150392, OrangeColor16, false, false); // INFORMATION

            AddHtmlLocalized(100, 65, 100, 18, 1150140, OrangeColor16, false, false); // ITEM
            AddHtmlLocalized(170, 65, 100, 18, 1150204, OrangeColor16, false, false); // BUY AT
            AddHtmlLocalized(230, 65, 100, 18, 1150645, OrangeColor16, false, false); // BUY LMT
            AddHtmlLocalized(315, 65, 100, 18, 1150205, OrangeColor16, false, false); // SELL AT
            AddHtmlLocalized(380, 65, 100, 18, 1150646, OrangeColor16, false, false); // SELL LMT
            AddHtmlLocalized(475, 65, 100, 18, 1150647, OrangeColor16, false, false); // EDIT

            int y       = 85;
            int perPage = 10;

            if (index > -1)
            {
                m_Page = index <= 0 ? 0 : index / perPage;
            }

            int start = page * perPage;
            int count = 1;

            for (int i = start; i < broker.CommodityEntries.Count && /*index <= perPage * (m_Page + 1) &&*/ count <= perPage; i++)
            {
                int col   = i == m_Index ? YellowColor : OrangeColor;
                int col16 = col == YellowColor ? YellowColor16 : OrangeColor16;
                CommodityBrokerEntry entry = broker.CommodityEntries[i];

                AddHtmlLocalized(1, y, 130, 18, 1114514, String.Format("#{0}", entry.Label), col16, false, false); // <DIV ALIGN=RIGHT>~1_TOKEN~</DIV>
                AddHtml(170, y, 45, 18, Color(AlignRight(FormatAmt(entry.BuyPricePer)), col), false, false);
                AddHtml(230, y, 80, 18, Color(AlignRight(FormatAmt(entry.BuyLimit)), col), false, false);
                AddHtml(315, y, 45, 18, Color(AlignRight(FormatAmt(entry.SellPricePer)), col), false, false);
                AddHtml(380, y, 80, 18, Color(AlignRight(FormatAmt(entry.SellLimit)), col), false, false);

                AddButton(475, y, 4014, 4016, 2 + i, GumpButtonType.Reply, 0);

                y += 22;
                count++;
            }

            if (m_Page > 0) // back
            {
                AddButton(162, 321, 4014, 4016, 400, GumpButtonType.Reply, 0);
            }

            if (broker.CommodityEntries.Count - start > perPage) // forward
            {
                AddButton(390, 321, 4005, 4007, 401, GumpButtonType.Reply, 0);
            }

            AddHtmlLocalized(124, 345, 100, 18, 1150204, BlueColor16, false, false); // BUY AT
            AddBackground(190, 345, 300, 18, 9350);
            AddTextEntry(191, 344, 320, 22, LabelHueBlue, 0, "");

            AddHtmlLocalized(114, 370, 100, 18, 1150645, BlueColor16, false, false); // BUY LMT
            AddBackground(190, 370, 300, 18, 9350);
            AddTextEntry(191, 369, 320, 22, LabelHueBlue, 1, "");

            AddHtmlLocalized(118, 395, 100, 18, 1150205, BlueColor16, false, false); // SELL AT
            AddBackground(190, 395, 300, 18, 9350);
            AddTextEntry(191, 394, 320, 22, LabelHueBlue, 2, "");

            AddHtmlLocalized(108, 420, 100, 18, 1150646, BlueColor16, false, false); // SELL LMT
            AddBackground(190, 420, 300, 18, 9350);
            AddTextEntry(191, 419, 320, 22, LabelHueBlue, 3, "");

            AddButton(140, 450, 4005, 4007, 500, GumpButtonType.Reply, 0);
            AddHtmlLocalized(190, 450, 200, 18, 1150232, RedColor16, false, false); // SET PRICES

            AddButton(10, 490, 4014, 4016, 501, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 490, 100, 18, 1149777, BlueColor16, false, false); // MAIN MENU
        }
Пример #25
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            switch (info.ButtonID)
            {
            case 0: return;

            case 1:
                from.SendGump(new CommodityInventoryGump(m_Broker, m_Index, m_Buy, m_Page));
                from.SendGump(new BazaarInformationGump(1150655, 1150654));
                return;

            case 400:
                from.SendGump(new CommodityInventoryGump(m_Broker, -1, m_Buy, m_Page - 1));
                return;

            case 401:
                from.SendGump(new CommodityInventoryGump(m_Broker, -1, m_Buy, m_Page + 1));
                return;

            case 500:                     // TRADE
            {
                if (m_Index >= 0 && m_Index < m_Entries.Count)
                {
                    CommodityBrokerEntry entry = m_Entries[m_Index];

                    if (!m_Broker.CommodityEntries.Contains(entry))
                    {
                        from.SendLocalizedMessage(1150244);                                         // Transaction no longer available
                        break;
                    }

                    int       amount = 0;
                    TextRelay relay  = info.TextEntries[0];

                    try
                    {
                        amount = Convert.ToInt32(relay.Text);
                    }
                    catch {}

                    if (amount > 0)
                    {
                        if (m_Buy && entry.PlayerCanBuy(amount))
                        {
                            from.SendGump(new ConfirmBuyCommodityGump(m_Broker, amount, entry, true));
                        }
                        else if (!m_Buy && entry.PlayerCanSell(amount))
                        {
                            from.SendGump(new ConfirmBuyCommodityGump(m_Broker, amount, entry, false));
                        }
                        else
                        {
                            from.SendLocalizedMessage(1150215);         // You have entered an invalid value, or a non-numeric value. Please try again.
                        }
                        return;
                    }
                    else
                    {
                        from.SendLocalizedMessage(1150215);                                         // You have entered an invalid value, or a non-numeric value. Please try again.
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1150642);                                     // You did not select a commodity.
                }
            }
            break;

            default:
            {
                if (info.ButtonID < 102)
                {
                    int id = info.ButtonID - 2;

                    if (id >= 0 && id < m_Entries.Count && m_Broker.CommodityEntries.Contains(m_Entries[id]))
                    {
                        m_Buy   = true;
                        m_Index = id;
                    }
                    else
                    {
                        from.SendLocalizedMessage(1150244);         // Transaction no longer available
                    }
                }
                else
                {
                    int id = info.ButtonID - 102;

                    if (id >= 0 && id < m_Entries.Count && m_Broker.CommodityEntries.Contains(m_Entries[id]))
                    {
                        m_Buy   = false;
                        m_Index = id;
                    }
                    else
                    {
                        from.SendLocalizedMessage(1150244);         // Transaction no longer available
                    }
                }
            }
            break;
            }

            from.SendGump(new CommodityInventoryGump(m_Broker, m_Index, m_Buy, 0));
        }
Пример #26
0
		// Called when a player SELLs the commodity from teh broker...this is f*****g confusing
		public void TrySellCommodity(Mobile from, CommodityBrokerEntry entry, int amount)
		{
			int totalCost = entry.BuyPricePer * amount;
			Type type = entry.CommodityType;
			
			if(BankBalance < totalCost)
			{
				//No message, this should have already been handled elsewhere
			}
			else if(from.Backpack != null)
			{
				int total = amount;
				int typeAmount = from.Backpack.GetAmount(type);
				int commodityAmount = GetCommodityType(from.Backpack, type);
				
				if(typeAmount + commodityAmount < total)
					from.SendLocalizedMessage(1150667); // You do not have the requested amount of that commodity (either in item or deed form) in your backpack to trade. Note that commodities cannot be traded from your bank box.
				else if(Banker.Deposit(from, totalCost))
				{
					TakeItems(from.Backpack, type, ref total);
					
					if(total > 0)
						TakeCommodities(from.Backpack, type, ref total);

                    BankBalance -= totalCost + (int)((double)totalCost * ((double)ComissionFee / 100.0));
					from.SendLocalizedMessage(1150668, String.Format("{0}\t#{1}", amount.ToString(), entry.Label)); // You have sold ~1_QUANTITY~ units of ~2_COMMODITY~ to the broker. These have been transferred from deeds and/or items in your backpack.
				}
				else
					from.SendLocalizedMessage(1150265); // Your bank box cannot hold the proceeds from this transaction.
			}
		}
Пример #27
0
		public int GetItemID(CommodityBrokerEntry entry)
		{
			/*Item[] items = BuyPack.FindItemsByType(typeof(CommodityDeed));
			
			foreach(Item item in items)
			{
				if(item is CommodityDeed)
				{
					CommodityDeed deed = (CommodityDeed)item;
					
					if(deed.Commodity != null && deed.Commodity.GetType() == entry.CommodityType)
						return deed.Commodity.ItemID;
				}
			}
			
			Item item = Loot.Construct(entry.CommodityType);
			int id = 0;
			
			if(item != null)
			{
				id = item.ItemID;
				item.Delete();
			}*/
			
			return entry != null ? entry.ItemID : 1;
		}
Пример #28
0
        public CommodityInventoryGump(CommodityBroker broker, int index, bool buy, int page) : base(655, 520)
        {
            m_Broker  = broker;
            m_Entries = broker.CommodityEntries;
            m_Buy     = buy;
            m_Page    = page;
            m_Index   = index;

            AddHtmlLocalized(205, 10, 200, 18, 1150636, RedColor16, false, false); // Commodity Broker

            if (m_Broker.Plot.ShopName != null && m_Broker.Plot.ShopName.Length > 0)
            {
                AddHtml(173, 40, 173, 18, Color(FormatStallName(m_Broker.Plot.ShopName), BlueColor), false, false); // "~1_NAME~"
            }
            else
            {
                AddHtmlLocalized(180, 40, 200, 18, 1150314, BlueColor16, false, false); // This Shop Has No Name
            }
            AddHtml(173, 65, 173, 18, Color(FormatBrokerName(String.Format("Proprietor: {0}", broker.Name)), BlueColor), false, false);

            AddButton(150, 100, 4005, 4007, 1, GumpButtonType.Reply, 0);
            AddHtmlLocalized(190, 100, 150, 18, 1150392, OrangeColor16, false, false); // INFORMATION

            AddHtmlLocalized(10, 125, 75, 18, 1150656, OrangeColor16, false, false);   // BUY
            AddHtmlLocalized(60, 125, 75, 18, 1150659, OrangeColor16, false, false);   // PRICE
            AddHtmlLocalized(120, 125, 75, 18, 1150658, OrangeColor16, false, false);  // LIMIT
            AddHtmlLocalized(330, 125, 75, 18, 1150655, OrangeColor16, false, false);  // COMMODITY
            AddHtmlLocalized(490, 125, 75, 18, 1150659, OrangeColor16, false, false);  // PRICE
            AddHtmlLocalized(550, 125, 75, 18, 1150658, OrangeColor16, false, false);  // LIMIT
            AddHtmlLocalized(610, 125, 75, 18, 1150657, OrangeColor16, false, false);  // SELL

            int y       = 150;
            int perPage = 10;

            if (index > -1)
            {
                m_Page = index <= 0 ? 0 : index / perPage;
            }

            int start = page * perPage;
            int count = 0;

            for (int i = start; i < m_Entries.Count && /*index < perPage*/ count <= perPage; i++)
            {
                CommodityBrokerEntry entry = m_Entries[i];

                int buyCol  = index == i && buy ? YellowColor : OrangeColor;
                int sellCol = index == i && !buy ? YellowColor : OrangeColor;
                int stock   = entry.Stock;

                int    buyLimit   = entry.ActualSellLimit;
                int    sellLimit  = entry.ActualBuyLimit;
                string buyAmount  = entry.SellPricePer > 0 ? FormatAmt(entry.SellPricePer) : "N/A";
                string sellAmount = entry.BuyPricePer > 0 ? FormatAmt(entry.BuyPricePer) : "N/A";

                // Sell to player
                AddHtml(60, y, 60, 18, Color(buyAmount, buyCol), false, false);
                if (entry.SellPricePer > 0 && entry.SellLimit > 0)
                {
                    AddHtml(120, y, 150, 18, Color(FormatAmt(buyLimit), buyCol), false, false);
                }

                // what we're selling/buying
                AddHtmlLocalized(200, y, 215, 18, 1114514, String.Format("#{0}", entry.Label), OrangeColor16, false, false); // <DIV ALIGN=RIGHT>~1_TOKEN~</DIV>

                // buy from player
                AddHtml(490, y, 75, 18, AlignRight(Color(sellAmount, sellCol)), false, false);
                if (entry.BuyPricePer > 0 && entry.BuyLimit > 0)
                {
                    AddHtml(550, y, 150, 18, AlignRight(Color(FormatAmt(sellLimit), sellCol)), false, false);
                }

                //Buttons
                if (entry.PlayerCanBuy(0))
                {
                    AddButton(10, y, 4005, 4007, 2 + i, GumpButtonType.Reply, 0);
                }

                if (entry.PlayerCanSell(0))
                {
                    AddButton(610, y, 4014, 4016, 102 + i, GumpButtonType.Reply, 0);
                }

                y += 22;
                count++;
            }

            if (m_Page > 0) // back
            {
                AddHtmlLocalized(100, 410, 150, 18, 1044044, OrangeColor16, false, false);
                AddButton(60, 410, 4014, 4016, 400, GumpButtonType.Reply, 0);
            }

            if (m_Entries.Count - start > perPage) // forward
            {
                AddHtmlLocalized(340, 410, 150, 18, 1044045, OrangeColor16, false, false);
                AddButton(425, 410, 4005, 4007, 401, GumpButtonType.Reply, 0);
            }

            AddHtmlLocalized(240, 445, 150, 18, 1150662, BlueColor16, false, false); // QUANTITY
            AddBackground(315, 445, 325, 22, 9350);
            AddTextEntry(316, 445, 300, 20, 0, 0, "");

            AddButton(275, 470, 4005, 4007, 500, GumpButtonType.Reply, 0);
            AddHtmlLocalized(315, 470, 100, 18, 1077761, OrangeColor16, false, false); // TRADE
        }
Пример #29
0
 public int GetStock(CommodityBrokerEntry entry)
 {
     return(entry.Stock);
 }
Пример #30
0
		public void WithdrawInventory(Mobile from, int amount, CommodityBrokerEntry entry)
		{
			if(from == null || Plot == null || entry == null || !m_CommodityEntries.Contains(entry))
				return;
				
			Container pack = from.Backpack;
			
			if(pack != null)
			{
				while(amount > 60000)
				{
					CommodityDeed deed = new CommodityDeed();
					Item item = Loot.Construct(entry.CommodityType);
					item.Amount = 60000;
					deed.SetCommodity(item);
					pack.DropItem(deed);
					amount -= 60000;
					entry.Stock -= 60000;
				}
				
				CommodityDeed deed2 = new CommodityDeed();
				Item newitem = Loot.Construct(entry.CommodityType);
                newitem.Amount = amount;
                deed2.SetCommodity(newitem);
				pack.DropItem(deed2);
				entry.Stock -= amount;
			}
			
			if(Plot != null && from == Plot.Owner)
				from.SendLocalizedMessage(1150221, String.Format("{0}\t#{1}\t{2}", amount.ToString(), entry.Label, Plot.ShopName != null ? Plot.ShopName : "a shop with no name")); // You have removed ~1_QUANTITY~ units of ~2_ITEMNAME~ from the inventory of "~3_SHOPNAME~"
		}
Пример #31
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            switch (info.ButtonID)
            {
            case 0: return;

            case 999:
                from.SendGump(new CommodityInventoryGump(m_Broker, m_Index, m_Buy, m_Page, 0));
                return;

            case 1:
                from.SendGump(new CommodityInventoryGump(m_Broker, m_Index, m_Buy, m_Page, 1150654));
                return;

            case 400:
                from.SendGump(new CommodityInventoryGump(m_Broker, -1, m_Buy, m_Page - 1, 0));
                return;

            case 401:
                from.SendGump(new CommodityInventoryGump(m_Broker, -1, m_Buy, m_Page + 1, 0));
                return;

            case 500:     // TRADE
            {
                for (int i = 0; i < m_Entries.Count; i++)
                {
                    int buyid  = 2 + i;
                    int sellid = 102 + i;

                    if (info.IsSwitched(buyid))
                    {
                        if (m_Broker.CommodityEntries.Contains(m_Entries[i]))
                        {
                            m_Buy   = true;
                            m_Index = i;
                        }
                    }
                    else if (info.IsSwitched(sellid))
                    {
                        if (m_Broker.CommodityEntries.Contains(m_Entries[i]))
                        {
                            m_Buy   = false;
                            m_Index = i;
                        }
                    }
                }

                if (m_Index >= 0 && m_Index < m_Entries.Count)
                {
                    CommodityBrokerEntry entry = m_Entries[m_Index];

                    if (!m_Broker.CommodityEntries.Contains(entry))
                    {
                        from.SendGump(new CommodityInventoryGump(m_Broker, m_Index, m_Buy, m_Page, 1150244));         // Transaction no longer available
                        return;
                    }

                    int       amount = 0;
                    TextRelay relay  = info.TextEntries[0];

                    try
                    {
                        amount = Convert.ToInt32(relay.Text);
                    }
                    catch (Exception e) { Server.Diagnostics.ExceptionLogging.LogException(e); }

                    if (amount > 0)
                    {
                        if (m_Buy && Banker.GetBalance(from) < entry.SellPricePer * amount)
                        {
                            /* You do not have the funds needed to make this trade available in your bank box. Brokers are only able to transfer funds from your bank box.
                             * Please deposit the necessary funds into your bank box and try again.
                             */
                            from.SendGump(new CommodityInventoryGump(m_Broker, m_Index, m_Buy, m_Page, 1150252));
                            return;
                        }
                        else if (!m_Buy && !m_Broker.SellCommodityControl(from, entry, amount))
                        {
                            /* You do not have the requested amount of that commodity (either in item or deed form) in your backpack to trade.
                             * Note that commodities cannot be traded from your bank box.
                             */
                            from.SendGump(new CommodityInventoryGump(m_Broker, m_Index, m_Buy, m_Page, 1150667));
                            return;
                        }
                        else if (m_Buy && entry.PlayerCanBuy(amount))
                        {
                            from.SendGump(new ConfirmBuyCommodityGump(m_Broker, amount, entry, true, new CommodityInventoryGump(m_Broker, m_Index, m_Buy, m_Page, 0)));
                            return;
                        }
                        else if (!m_Buy && entry.PlayerCanSell(amount))
                        {
                            from.SendGump(new ConfirmBuyCommodityGump(m_Broker, amount, entry, false, new CommodityInventoryGump(m_Broker, m_Index, m_Buy, m_Page, 0)));
                            return;
                        }
                        else
                        {
                            from.SendGump(new CommodityInventoryGump(m_Broker, m_Index, m_Buy, m_Page, 1150215));         // You have entered an invalid value, or a non-numeric value. Please try again.
                            return;
                        }
                    }
                    else
                    {
                        from.SendGump(new CommodityInventoryGump(m_Broker, m_Index, m_Buy, m_Page, 1150215));         // You have entered an invalid value, or a non-numeric value. Please try again.
                        return;
                    }
                }
                else
                {
                    from.SendGump(new CommodityInventoryGump(m_Broker, m_Index, m_Buy, m_Page, 1150642));         // You did not select a commodity.
                    return;
                }
            }
            }
        }
Пример #32
0
 public int GetLabelID(CommodityBrokerEntry entry)
 {
     return(entry != null ? entry.Label : 1);
 }
Пример #33
0
		public ConfirmBuyCommodityGump(CommodityBroker broker, int amount, CommodityBrokerEntry entry, bool buy)
		{
			m_Broker = broker;
			m_Amount = amount;
			m_Entry = entry;

            AddHtmlLocalized(205, 10, 200, 18, 1150636, RedColor16, false, false); // Commodity Broker

            if (m_Broker.Plot.ShopName != null && m_Broker.Plot.ShopName.Length > 0)
                AddHtml(173, 40, 173, 18, Color(FormatStallName(m_Broker.Plot.ShopName), BlueColor), false, false); // "~1_NAME~"
            else
                AddHtmlLocalized(180, 40, 200, 18, 1150314, BlueColor16, false, false); // This Shop Has No Name

            AddHtml(173, 65, 173, 18, Color(FormatBrokerName(String.Format("Proprietor: {0}", broker.Name)), BlueColor), false, false);
			
			AddHtmlLocalized(10, 100, 500, 40, 1150666, RedColor16, false, false); // Please review the details of this transaction. If you wish to make this trade, click the TRADE button below. Otherwise, click the MAIN MENU button to return to the price list.
			
			if(buy)
			{
				int cost = entry.SellPricePer * amount;

				AddHtmlLocalized(10, 150, 260, 18, 1150245, OrangeColor16, false, false); // <DIV ALIGN=RIGHT>You are purchasing:</DIV>
                AddItem(230, 210, m_Broker.GetItemID(entry));
                
                AddHtmlLocalized(110, 350, 150, 18, 1150246, OrangeColor16, false, false); // Total Cost:
				AddHtml(180, 350, 150, 18, Color(FormatAmt(cost), OrangeColor), false, false);
				
				AddHtmlLocalized(170, 380, 120, 18, 1150247, OrangeColor16, false, false); // <DIV ALIGN=RIGHT>PURCHASE</DIV>
				AddButton(180, 380, 4005, 4007, 1, GumpButtonType.Reply, 0);
			}
			else
			{
				int cost = entry.BuyPricePer * amount;

                AddHtmlLocalized(10, 150, 260, 18, 1150250, OrangeColor16, false, false); // <DIV ALIGN=RIGHT>You are selling:</DIV>
                AddItem(230, 210, m_Broker.GetItemID(entry));

                AddHtmlLocalized(50, 350, 160, 18, 1150251, OrangeColor16, false, false); // Gold you will recieve:
				AddHtml(190, 350, 150, 18, Color(FormatAmt(cost), OrangeColor), false, false);
				
				AddHtmlLocalized(200, 380, 60, 18, 1150249, OrangeColor16, false, false); // <DIV ALIGN=RIGHT>SELL</DIV>
				AddButton(190, 380, 4005, 4007, 2, GumpButtonType.Reply, 0);
			}
			
			//AddHtmlLocalized(x, y, 120, 18, 1150248, OrangeColor, false, false); // <DIV ALIGN=RIGHT>CONFIRM</DIV>
		}
Пример #34
0
		public ConfirmRemoveEntryGump(CommodityBroker broker, int index)
		{
			m_Broker = broker;
			m_Index = index;

            if (index >= 0 && index < m_Broker.CommodityEntries.Count)
                m_Entry = m_Broker.CommodityEntries[index];
		}
Пример #35
0
		public int GetStock(CommodityBrokerEntry entry)
		{
			return entry.Stock;
		}