Exemple #1
0
 public void RemoveEntry(PetBrokerEntry entry)
 {
     if (m_BrokerEntries.Contains(entry))
     {
         m_BrokerEntries.Remove(entry);
     }
 }
        public PetInventoryGump(PetBroker broker, Mobile from)
        {
            m_Broker  = broker;
            m_Entries = broker.BrokerEntries;

            AddHtmlLocalized(10, 10, 500, 18, 1114513, "#1150311", RedColor16, false, false);    // Animal Broker

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

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

            if (m_Entries.Count != 0)
            {
                AddHtmlLocalized(10, 91, 500, 18, 1114513, "#1150346", GreenColor16, false, false);    // PETS FOR SALE
                AddHtmlLocalized(10, 118, 500, 72, 1114513, "#1150352", GreenColor16, false, false);   // LORE: See the animal's

                AddHtmlLocalized(10, 199, 52, 18, 1150351, OrangeColor16, false, false);               // LORE
                AddHtmlLocalized(68, 199, 52, 18, 1150353, OrangeColor16, false, false);               // VIEW
                AddHtmlLocalized(126, 199, 104, 18, 1150347, OrangeColor16, false, false);             // NAME
                AddHtmlLocalized(236, 199, 104, 18, 1150348, OrangeColor16, false, false);             // TYPE
                AddHtmlLocalized(346, 199, 104, 18, 1114514, "#1150349", OrangeColor16, false, false); // PRICE
                AddHtmlLocalized(456, 199, 52, 18, 1150350, OrangeColor16, false, false);              // BUY

                int y = 219;
                for (int i = 0; i < m_Entries.Count; i++)
                {
                    PetBrokerEntry entry = m_Entries[i];

                    if (entry == null || entry.Pet == null)
                    {
                        continue;
                    }

                    AddButton(10, y + (i * 20), 4011, 4013, 100 + i, GumpButtonType.Reply, 0);
                    AddButton(68, y + (i * 20), 4008, 4010, 200 + i, GumpButtonType.Reply, 0);

                    AddHtml(126, y + (i * 20), 104, 14, Color(entry.Pet.Name, BlueColor), false, false);
                    AddHtml(236, y + (i * 20), 104, 20, Color(entry.TypeName, BlueColor), false, false);
                    AddHtml(346, y + (i * 20), 104, 20, Color(AlignRight(FormatAmt(entry.SalePrice)), GreenColor), false, false);

                    AddButton(456, y + (i * 20), 4014, 4016, 300 + i, GumpButtonType.Reply, 0);
                }
            }
            else
            {
                AddHtmlLocalized(10, 127, 500, 534, 1114513, "#1150336", OrangeColor16, false, false); // The animal broker has no pets in its inventory.

                AddButton(10, 490, 0xFAE, 0xFAF, 1, GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 490, 210, 20, 1149777, BlueColor16, false, false); // MAIN MENU
            }
        }
Exemple #3
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            if (info.ButtonID == 0)
            {
                return;
            }

            if (info.ButtonID == 500)            // MAIN MENU
            {
                from.SendGump(new PetBrokerGump(m_Broker, from));
                return;
            }
            else if (info.ButtonID == 501) // REMOVE PET
            {
                if (m_Index >= 0 && m_Index < m_Broker.BrokerEntries.Count)
                {
                    PetBrokerEntry entry = m_Broker.BrokerEntries[m_Index];

                    if (from.Stabled.Count >= AnimalTrainer.GetMaxStabled(from) || entry.Pet == null)
                    {
                        from.SendLocalizedMessage(1150634); // Failed to transfer the selected pet to your stables. Either the pet is no longer in the broker's inventory, or you do not have any available stable slots.
                    }
                    else
                    {
                        BaseCreature bc = entry.Pet;
                        m_Broker.RemoveEntry(entry);

                        PetBroker.EndViewTimer(bc);
                        bc.ControlTarget = null;
                        bc.ControlOrder  = OrderType.Stay;
                        bc.Internalize();
                        bc.SetControlMaster(null);
                        bc.SummonMaster = null;
                        bc.IsStabled    = true;
                        bc.Loyalty      = BaseCreature.MaxLoyalty;
                        from.Stabled.Add(bc);

                        from.SendLocalizedMessage(1150635, String.Format("{0}\t{1}", entry.TypeName, bc.Name)); // Your pet ~1_TYPE~ named ~2_NAME~ has been transferred to the stables.
                        from.SendGump(new PetBrokerGump(m_Broker, from));
                        return;
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1150341); // You did not select a pet.
                }
                from.SendGump(new RemovePetsGump(m_Broker, from, m_Index));
            }
            else
            {
                from.SendGump(new RemovePetsGump(m_Broker, from, info.ButtonID - 1));
            }
        }
Exemple #4
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write(0);

            writer.Write(m_BrokerEntries.Count);
            for (var index = 0; index < m_BrokerEntries.Count; index++)
            {
                PetBrokerEntry entry = m_BrokerEntries[index];
                entry.Serialize(writer);
            }
        }
Exemple #5
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

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

            case 1:                     // MAIN MENU
                from.SendGump(new PetBrokerGump(m_Broker, from));
                break;

            case 500:                     // SET PRICE
            {
                if (m_Index >= 0 && m_Index < m_Broker.BrokerEntries.Count)
                {
                    PetBrokerEntry entry  = m_Broker.BrokerEntries[m_Index];
                    int            amount = 0;
                    TextRelay      relay  = info.TextEntries[0];

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

                    if (amount > 0)
                    {
                        entry.SalePrice = amount;
                    }
                    else
                    {
                        from.SendLocalizedMessage(1150343);                                         // You have entered an invalid price.
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1150341);                                     // You did not select a pet.
                }
            }
                from.SendGump(new SetPetPricesGump(m_Broker, -1));
                break;

            default:
                int idx = info.ButtonID - 3;
                if (idx >= 0 && idx < m_Broker.BrokerEntries.Count)
                {
                    m_Index = idx;
                }
                from.SendGump(new SetPetPricesGump(m_Broker, m_Index));
                break;
            }
        }
Exemple #6
0
        public bool HasEntry(BaseCreature bc)
        {
            for (var index = 0; index < m_BrokerEntries.Count; index++)
            {
                PetBrokerEntry entry = m_BrokerEntries[index];

                if (entry.Pet == bc)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #7
0
        public void CheckInventory()
        {
            List <PetBrokerEntry> entries = new List <PetBrokerEntry>(m_BrokerEntries);

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

                if (entry.Pet == null || entry.Pet.Deleted)
                {
                    m_BrokerEntries.Remove(entry);
                }
            }
        }
Exemple #8
0
        public PetInventoryGump(PetBroker broker, Mobile from)
        {
            m_Broker  = broker;
            m_Entries = broker.BrokerEntries;

            AddHtmlLocalized(215, 10, 200, 18, 1150311, RedColor16, false, false); // Animal 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);
            }
            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(205, 100, 200, 18, 1150346, GreenColor16, false, false);           // PETS FOR SALE
            AddHtmlLocalized(10, 130, 500, 40, 1150352, GreenColor16, false, false);            // LORE: See the animal's

            AddHtmlLocalized(5, 180, 45, 18, 1150351, OrangeColor16, false, false);             // LORE
            AddHtmlLocalized(50, 180, 45, 18, 1150353, OrangeColor16, false, false);            // VIEW
            AddHtmlLocalized(95, 180, 150, 18, 1150347, OrangeColor16, false, false);           // NAME
            AddHtmlLocalized(245, 180, 150, 18, 1150348, OrangeColor16, false, false);          // TYPE
            AddHtmlLocalized(425, 180, 80, 18, 1150349, OrangeColor16, false, false);           // PRICE
            AddHtmlLocalized(480, 180, 55, 18, 1150350, OrangeColor16, false, false);           // BUY

            int y = 200;

            for (int i = 0; i < m_Entries.Count; i++)
            {
                PetBrokerEntry entry = m_Entries[i];

                if (entry == null || entry.Pet == null)
                {
                    continue;
                }

                AddButton(5, y + (i * 20), 4011, 4013, 100 + i, GumpButtonType.Reply, 0);
                AddButton(50, y + (i * 20), 4008, 4010, 200 + i, GumpButtonType.Reply, 0);

                AddHtml(95, y + (i * 20), 145, 18, Color(entry.Pet.Name, BlueColor), false, false);
                AddHtml(245, y + (i * 20), 145, 18, Color(entry.TypeName, BlueColor), false, false);
                AddHtml(425, y + (i * 20), 80, 18, AlignRight(Color(FormatAmt(entry.SalePrice), GreenColor)), false, false);

                AddButton(480, y + (i * 20), 4014, 4016, 300 + i, GumpButtonType.Reply, 0);
            }
        }
Exemple #9
0
        public bool TryBuyPet(Mobile from, PetBrokerEntry entry)
        {
            if (from == null || entry == null || entry.Pet == null)
            {
                return(false);
            }

            int          cost     = entry.SalePrice;
            int          toDeduct = cost + (int)((double)cost * ((double)ComissionFee / 100.0));
            BaseCreature pet      = entry.Pet;

            if (!m_BrokerEntries.Contains(entry) || entry.Pet == null || entry.Pet.Deleted)
            {
                from.SendLocalizedMessage(1150377);                 // Unable to complete the desired transaction at this time.
            }
            else if (pet.GetControlChance(from) <= 0.0)
            {
                from.SendLocalizedMessage(1150379);                 // Unable to transfer that pet to you because you have no chance at all of controlling it.
            }
            else if (from.Stabled.Count >= AnimalTrainer.GetMaxStabled(from) /*from.Followers + pet.ControlSlots >= from.FollowersMax*/)
            {
                from.SendLocalizedMessage(1150376);                 // You do not have any available stable slots. The Animal Broker can only transfer pets to your stables. Please make a stables slot available and try again.
            }
            else if (!Banker.Withdraw(from, toDeduct, true))
            {
                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.
            }
            else
            {
                BankBalance += cost;
                pet.Blessed  = false;
                EndViewTimer(pet);
                pet.ControlTarget = null;
                pet.ControlOrder  = OrderType.Stay;
                pet.Internalize();
                pet.SetControlMaster(null);
                pet.SummonMaster = null;
                pet.IsStabled    = true;
                pet.Loyalty      = BaseCreature.MaxLoyalty;
                from.Stabled.Add(pet);

                from.SendLocalizedMessage(1150380, String.Format("{0}\t{1}", entry.TypeName, pet.Name)); // You have purchased ~1_TYPE~ named "~2_NAME~". The animal is now in the stables and you may retrieve it there.
                m_BrokerEntries.Remove(entry);
                return(true);
            }

            return(false);
        }
Exemple #10
0
        public override int GetWeeklyFee()
        {
            int total = 0;

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

                if (entry.SalePrice > 0)
                {
                    total += entry.SalePrice;
                }
            }

            double perc = total * .05;

            return((int)perc);
        }
        public ConfirmBuyPetGump(PetBroker broker, PetBrokerEntry entry)
        {
            m_Broker = broker;
            m_Entry  = entry;

            AddHtmlLocalized(10, 10, 500, 18, 1114513, "#1150311", RedColor16, false, false);  // Animal Broker

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

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

            AddHtmlLocalized(10, 91, 500, 18, 1114513, "#1150375", GreenColor16, false, false);   // PURCHASE PET
            AddHtmlLocalized(10, 118, 500, 72, 1114513, "#1150370", GreenColor16, false, false);  // Please confirm your purchase order below, and click "ACCEPT" if you wish to purchase this animal.

            AddHtmlLocalized(10, 235, 245, 18, 1114514, "#1150372", OrangeColor16, false, false); // Animal Name:
            AddHtmlLocalized(10, 255, 245, 18, 1114514, "#1150371", OrangeColor16, false, false); // Animal Type:
            AddHtmlLocalized(10, 275, 245, 18, 1114514, "#1150373", OrangeColor16, false, false); // Sale Price:

            AddHtml(265, 235, 245, 18, Color(entry.Pet.Name, BlueColor), false, false);
            AddHtml(265, 255, 245, 18, Color(entry.TypeName, BlueColor), false, false);
            AddHtml(265, 275, 245, 18, Color(FormatAmt(entry.SalePrice), BlueColor), false, false);

            /*int itemID = ShrinkTable.Lookup(entry.Pet);
             * //if (entry.Pet is WildTiger)
             * //    itemID = 0x9844;
             *
             *          AddItem(240, 250, itemID);*/

            AddHtmlLocalized(265, 295, 245, 22, 1150374, OrangeColor16, false, false);             // ACCEPT
            AddButton(225, 295, 4005, 4007, 1, GumpButtonType.Reply, 0);

            AddButton(10, 490, 0xFAE, 0xFAF, 2, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 490, 210, 20, 1149777, BlueColor16, false, false); // MAIN MENU
        }
Exemple #12
0
        public int TryBuyPet(Mobile from, PetBrokerEntry entry)
        {
            if (from == null || entry == null || entry.Pet == null)
            {
                return(1150377); // Unable to complete the desired transaction at this time.
            }

            int          cost  = entry.SalePrice;
            int          toAdd = cost - (int)(cost * (ComissionFee / 100.0));
            BaseCreature pet   = entry.Pet;

            if (!m_BrokerEntries.Contains(entry) || entry.Pet == null || entry.Pet.Deleted)
            {
                return(1150377); // Unable to complete the desired transaction at this time.
            }

            if (pet.GetControlChance(from) <= 0.0)
            {
                return(1150379); // Unable to transfer that pet to you because you have no chance at all of controlling it.
            }

            if (from.Stabled.Count >= AnimalTrainer.GetMaxStabled(from))
            {
                return(1150376); // You do not have any available stable slots. The Animal Broker can only transfer pets to your stables. Please make a stables slot available and try again.
            }

            if (!Banker.Withdraw(from, cost, true))
            {
                return(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.
            }

            BankBalance += toAdd;
            pet.IsBonded = false;

            SendToStables(from, pet);

            from.SendLocalizedMessage(1150380, string.Format("{0}\t{1}", entry.TypeName, pet.Name)); // You have purchased ~1_TYPE~ named "~2_NAME~". The animal is now in the stables and you may retrieve it there.
            m_BrokerEntries.Remove(entry);
            return(0);
        }
Exemple #13
0
        public SetPetPricesGump(PetBroker broker, int index)
        {
            m_Broker = broker;
            m_Index  = index;

            AddHtmlLocalized(215, 10, 200, 18, 1150311, RedColor16, false, false);    // Animal Broker

            AddHtmlLocalized(60, 90, 100, 18, 1150347, OrangeColor16, false, false);  // NAME
            AddHtmlLocalized(220, 90, 100, 18, 1150348, OrangeColor16, false, false); // TYPE
            AddHtmlLocalized(400, 90, 100, 18, 1150349, OrangeColor16, false, false); // PRICE

            m_Broker.CheckInventory();

            int y = 130;

            for (int i = 0; i < broker.BrokerEntries.Count; i++)
            {
                int col = index == i ? YellowColor : OrangeColor;

                PetBrokerEntry entry = broker.BrokerEntries[i];

                AddHtml(60, y, 200, 18, Color(entry.Pet.Name != null ? entry.Pet.Name : "Unknown", col), false, false);
                AddHtml(220, y, 200, 18, Color(entry.TypeName, col), false, false);
                AddHtml(400, y, 200, 18, Color(FormatAmt(entry.SalePrice), col), false, false);
                AddButton(10, y, 4005, 4007, i + 3, GumpButtonType.Reply, 0);

                y += 22;
            }

            int price = index >= 0 && index < broker.BrokerEntries.Count ? broker.BrokerEntries[index].SalePrice : 0;

            AddHtmlLocalized(215, 380, 150, 18, 1150627, BlueColor16, false, false);             // SET PRICE
            AddBackground(215, 405, 295, 22, 9350);
            AddTextEntry(216, 405, 294, 20, 0, 0, FormatAmt(price));
            AddButton(175, 405, 4005, 4007, 500, GumpButtonType.Reply, 0);

            AddButton(10, 490, 4014, 4016, 1, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 490, 100, 18, 1149777, BlueColor16, false, false); // MAIN MENU
        }
Exemple #14
0
        public override bool HasValidEntry(Mobile m)
        {
            bool hasValid = false;

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

                if (entry.Pet != null)
                {
                    if (m.Stabled.Count < AnimalTrainer.GetMaxStabled(m))
                    {
                        SendToStables(m, entry.Pet);
                    }
                    else
                    {
                        hasValid = true;
                    }
                }
            }

            return(hasValid);
        }
Exemple #15
0
        public ConfirmBuyPetGump(PetBroker broker, PetBrokerEntry entry)
        {
            m_Broker = broker;
            m_Entry  = entry;

            AddHtmlLocalized(215, 10, 200, 18, 1150311, RedColor16, false, false); // Animal 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);
            }
            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, 1150370, RedColor16, false, false);             // Please confirm your purchase order below, and click "ACCEPT" if you wish to purchase this animal.

            AddHtmlLocalized(150, 160, 200, 18, 1150371, OrangeColor16, false, false);         // Animal Type:
            AddHtmlLocalized(145, 180, 200, 18, 1150372, OrangeColor16, false, false);         // Animal Name:
            AddHtmlLocalized(157, 200, 150, 18, 1150373, OrangeColor16, false, false);         // Sale Price:

            AddHtml(240, 160, 200, 18, Color(entry.TypeName, BlueColor), false, false);
            AddHtml(240, 180, 200, 18, Color(entry.Pet.Name, BlueColor), false, false);
            AddHtml(240, 200, 200, 18, Color(FormatAmt(entry.SalePrice), BlueColor), false, false);

            int itemID = ShrinkTable.Lookup(entry.Pet);

            //if (entry.Pet is WildTiger)
            //    itemID = 0x9844;

            AddItem(240, 250, itemID);

            AddHtmlLocalized(240, 360, 150, 18, 1150375, OrangeColor16, false, false);             // Purchas Pet
            AddButton(200, 360, 4005, 4007, 1, GumpButtonType.Reply, 0);
        }
Exemple #16
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            reader.ReadInt();

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                m_BrokerEntries.Add(new PetBrokerEntry(reader));
            }

            Timer.DelayCall(TimeSpan.FromSeconds(10), () =>
            {
                for (var index = 0; index < m_BrokerEntries.Count; index++)
                {
                    PetBrokerEntry entry = m_BrokerEntries[index];
                    if (entry.Pet != null && !entry.Pet.IsStabled)
                    {
                        AddToViewTimer(entry.Pet);
                    }
                }
            });
        }
Exemple #17
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            if (info.ButtonID < 200)            // LORE
            {
                int id = info.ButtonID - 100;

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

                    if (entry != null && entry.Pet != null && m_Broker.BrokerEntries.Contains(entry))
                    {
                        from.SendGump(new PetInventoryGump(m_Broker, from));
                        from.SendGump(new Server.SkillHandlers.AnimalLoreGump(entry.Pet));
                    }
                    else
                    {
                        from.SendLocalizedMessage(1150368); // The selected animal is not available.
                    }
                }
            }
            else if (info.ButtonID < 300)             // VIEW
            {
                int id = info.ButtonID - 200;

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

                    if (entry != null && entry.Pet != null && m_Broker.BrokerEntries.Contains(entry) && entry.Pet.IsStabled)
                    {
                        BaseCreature pet = entry.Pet;

                        pet.Blessed = true;
                        pet.SetControlMaster(m_Broker);
                        pet.ControlTarget = m_Broker;
                        pet.ControlOrder  = OrderType.None;
                        pet.MoveToWorld(m_Broker.Location, m_Broker.Map);
                        pet.IsStabled = false;
                        pet.Home      = pet.Location;
                        pet.RangeHome = 2;
                        pet.Loyalty   = BaseCreature.MaxLoyalty;

                        PetBroker.AddToViewTimer(pet);
                        from.SendLocalizedMessage(1150369, String.Format("{0}\t{1}", entry.TypeName, pet.Name));                         // The ~1_TYPE~ named "~2_NAME~" is now in the animal broker's pen for inspection.
                    }
                    else
                    {
                        from.SendLocalizedMessage(1150368);                         // The selected animal is not available.
                    }
                }

                from.SendGump(new PetInventoryGump(m_Broker, from));
            }
            else             // BUY
            {
                int id = info.ButtonID - 300;

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

                    if (entry != null && entry.Pet != null && m_Broker.BrokerEntries.Contains(entry))
                    {
                        from.SendGump(new ConfirmBuyPetGump(m_Broker, entry));
                    }
                }
            }
        }
Exemple #18
0
        public RemovePetsGump(PetBroker broker, Mobile from, int index)
        {
            m_Broker = broker;
            m_Index  = index;

            AddHtmlLocalized(215, 10, 200, 18, 1150311, RedColor16, false, false);  // Animal Broker
            AddHtmlLocalized(145, 50, 250, 18, 1150337, RedColor16, false, false);  // ADD PET TO BROKER INVENTORY
            AddHtmlLocalized(10, 80, 500, 40, 1150633, GreenColor16, false, false); // Click the button next to a pet to select it, then click the REMOVE PET button below to transfer that pet to your stables.

            m_Broker.CheckInventory();

            int y = 130;

            for (int i = 0; i < broker.BrokerEntries.Count; i++)
            {
                BaseCreature bc  = broker.BrokerEntries[i].Pet;
                int          col = index == i ? YellowColor16 : OrangeColor16;
                AddButton(10, y, 4005, 4007, i + 1, GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, y, 200, 18, 1150340, String.Format("{0}\t{1}", bc.Name, PetBrokerEntry.GetOriginalName(bc)), col, false, false);                 // ~1_NAME~ (~2_type~)

                y += 20;
            }

            AddHtmlLocalized(215, 405, 150, 18, 1150632, OrangeColor16, false, false);             // REMOVE PET
            AddButton(175, 405, 4014, 4016, 501, GumpButtonType.Reply, 0);

            AddButton(10, 490, 4014, 4016, 500, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 490, 100, 18, 1149777, BlueColor16, false, false); // MAIN MENU
        }
Exemple #19
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            if (info.ButtonID == 0)
            {
                return;
            }

            if (info.ButtonID == 500)            // MAIN MENU
            {
                from.SendGump(new PetBrokerGump(m_Broker, from));
                return;
            }
            else if (info.ButtonID == 501)            // ADD PET
            {
                if (m_Index >= 0 && m_Index < m_List.Count)
                {
                    if (m_Broker.BankBalance < 0)
                    {
                        from.SendGump(new BazaarInformationGump(1150623, 1150615));
                        return;
                    }

                    TextRelay relay = info.TextEntries[0];
                    int       cost  = PetBrokerEntry.DefaultPrice;

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

                    if (cost > 0)
                    {
                        BaseCreature bc = m_List[m_Index];

                        if (m_Broker.TryAddEntry(bc, from, cost))
                        {
                            from.Stabled.Remove(bc);
                            from.SendGump(new SetPetPricesGump(m_Broker));
                            from.SendLocalizedMessage(1150345, String.Format("{0}\t{1}\t{2}\t{3}", PetBrokerEntry.GetOriginalName(bc), bc.Name, m_Broker.Name, cost));                             // Your pet ~1_TYPE~ named ~2_NAME~ has been transferred to the inventory of your animal broker named ~3_SHOP~ with an asking price of ~4_PRICE~.
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1150343);                         // You have entered an invalid price.
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1150341);                     // You did not select a pet.
                }
            }
            else
            {
                from.SendGump(new SelectPetsGump(m_Broker, from, info.ButtonID - 1));
            }
        }
Exemple #20
0
        public SelectPetsGump(PetBroker broker, Mobile from, int index)
        {
            m_Broker = broker;
            m_Index  = index;

            AddHtmlLocalized(215, 10, 200, 18, 1150311, RedColor16, false, false);             // Animal Broker
            AddHtmlLocalized(145, 50, 250, 18, 1150337, RedColor16, false, false);             // ADD PET TO BROKER INVENTORY
            AddHtmlLocalized(10, 100, 500, 40, 1150338, GreenColor16, false, false);           // Click the button next to a pet to select it. Enter the price you wish to charge into the box below the pet list, then click the "ADD PET" button.

            m_List = GetList(from);

            int y = 150;

            for (int i = 0; i < m_List.Count; i++)
            {
                int          col = index == i ? YellowColor16 : OrangeColor16;
                BaseCreature bc  = m_List[i];

                if (bc == null)
                {
                    continue;
                }

                AddButton(10, y, 4005, 4007, i + 1, GumpButtonType.Reply, 0);
                AddHtmlLocalized(60, y, 200, 18, 1150340, String.Format("{0}\t{1}", bc.Name, PetBrokerEntry.GetOriginalName(bc)), col, false, false);                 // ~1_NAME~ (~2_type~)
                y += 22;
            }

            AddHtmlLocalized(215, 380, 100, 18, 1150339, OrangeColor16, false, false);             // ADD PET
            AddButton(175, 405, 4005, 4007, 501, GumpButtonType.Reply, 0);
            AddBackground(215, 405, 295, 22, 9350);
            AddTextEntry(216, 405, 294, 20, 0, 0, "");

            AddButton(10, 490, 4014, 4016, 500, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 490, 100, 18, 1149777, BlueColor16, false, false);             // MAIN MENU
        }
Exemple #21
0
		public ConfirmBuyPetGump(PetBroker broker, PetBrokerEntry entry)
		{
			m_Broker = broker;
			m_Entry = entry;

            AddHtmlLocalized(215, 10, 200, 18, 1150311, RedColor16, false, false); // Animal 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);
            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, 1150370, RedColor16, false, false); // Please confirm your purchase order below, and click "ACCEPT" if you wish to purchase this animal.
			
			AddHtmlLocalized(150, 160, 200, 18, 1150371, OrangeColor16, false, false); // Animal Type:
			AddHtmlLocalized(145, 180, 200, 18, 1150372, OrangeColor16, false, false); // Animal Name:
			AddHtmlLocalized(157, 200, 150, 18, 1150373, OrangeColor16, false, false); // Sale Price:

            AddHtml(240, 160, 200, 18, Color(entry.TypeName, BlueColor), false, false);
            AddHtml(240, 180, 200, 18, Color(entry.Pet.Name, BlueColor), false, false);
			AddHtml(240, 200, 200, 18, Color(FormatAmt(entry.SalePrice), BlueColor), false, false);

            int itemID = ShrinkTable.Lookup(entry.Pet);
            //if (entry.Pet is WildTiger)
            //    itemID = 0x9844;

			AddItem(240, 250, itemID);
			
			AddHtmlLocalized(240, 360, 150, 18, 1150375, OrangeColor16, false, false); // Purchas Pet
			AddButton(200, 360, 4005, 4007, 1, GumpButtonType.Reply, 0);
		}
Exemple #22
0
		public void RemoveEntry(PetBrokerEntry entry)
		{
			if(m_BrokerEntries.Contains(entry))
				m_BrokerEntries.Remove(entry);
		}
Exemple #23
0
		public bool TryBuyPet(Mobile from, PetBrokerEntry entry)
		{
			if(from == null || entry == null || entry.Pet == null)
				return false;
				
			int cost = entry.SalePrice;
			int toDeduct = cost + (int)((double)cost * ((double)ComissionFee / 100.0));
			BaseCreature pet = entry.Pet;
			
			if(!m_BrokerEntries.Contains(entry) || entry.Pet == null || entry.Pet.Deleted)
				from.SendLocalizedMessage(1150377); // Unable to complete the desired transaction at this time.
			else if(pet.GetControlChance(from) <= 0.0)
				from.SendLocalizedMessage(1150379); // Unable to transfer that pet to you because you have no chance at all of controlling it.
            else if (from.Stabled.Count >= AnimalTrainer.GetMaxStabled(from)/*from.Followers + pet.ControlSlots >= from.FollowersMax*/)
				from.SendLocalizedMessage(1150376); // You do not have any available stable slots. The Animal Broker can only transfer pets to your stables. Please make a stables slot available and try again.
			else if (!Banker.Withdraw(from, toDeduct))
				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.
			else
			{
                BankBalance += cost;
				pet.Blessed = false;
                EndViewTimer(pet);
                pet.ControlTarget = null;
                pet.ControlOrder = OrderType.Stay;
                pet.Internalize();
                pet.SetControlMaster(null);
                pet.SummonMaster = null;
                pet.IsStabled = true;
                pet.Loyalty = BaseCreature.MaxLoyalty;
                from.Stabled.Add(pet);

                from.SendLocalizedMessage(1150380, String.Format("{0}\t{1}", entry.TypeName, pet.Name)); // You have purchased ~1_TYPE~ named "~2_NAME~". The animal is now in the stables and you may retrieve it there.
                m_BrokerEntries.Remove(entry);
                return true;
            }

            return false;
		}