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;
            }

            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.SendToStables(from, 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 #2
0
        public void OnTick()
        {
            foreach (MaginciaBazaarPlot plot in m_Plots)
            {
                if (plot.Active)
                {
                    plot.OnTick();
                }
            }

            List <Mobile> toRemove = new List <Mobile>();

            foreach (KeyValuePair <Mobile, StorageEntry> kvp in m_WarehouseStorage)
            {
                Mobile       m     = kvp.Key;
                StorageEntry entry = kvp.Value;

                if (entry.Expires < DateTime.UtcNow)
                {
                    bool deleted = false;
                    bool stabled = false;

                    if (entry.CommodityTypes.Count > 0)
                    {
                        deleted = true;
                    }

                    foreach (BaseCreature bc in entry.Creatures)
                    {
                        if (m.Stabled.Count < AnimalTrainer.GetMaxStabled(m))
                        {
                            PetBroker.SendToStables(m, bc);

                            if (!stabled)
                            {
                                stabled = true;
                            }
                        }
                        else
                        {
                            if (!deleted)
                            {
                                deleted = true;
                            }

                            bc.Delete();
                        }
                    }

                    if (stabled)
                    {
                        string message;

                        if (deleted)
                        {
                            message = "Your broker inventory and/or funds in storage at the New Magincia Warehouse " +
                                      "have been donated to charity, because these items remained unclaimed for a " +
                                      "full week. These items may no longer be recovered, but the orphans will " +
                                      "appreciate a nice hot meal. One or all of your pets have been placed in your stables.";
                        }
                        else
                        {
                            message = "Because your pets remained in storage for more than a full week, one or all of them have been placed in your stables. " +
                                      "If you had insufficient room in your stables, any further pets will be lost and returned to the wild.";
                        }

                        MaginciaLottoSystem.SendMessageTo(m, new NewMaginciaMessage(new TextDefinition(1150676), message, null));
                    }
                    else if (deleted)
                    {
                        toRemove.Add(m);

                        /*Your broker inventory and/or funds in storage at the New Magincia Warehouse
                         * have been donated to charity, because these items remained unclaimed for a
                         * full week. These items may no longer be recovered, but the orphans will
                         * appreciate a nice hot meal.*/

                        MaginciaLottoSystem.SendMessageTo(m, new NewMaginciaMessage(new TextDefinition(1150676), new TextDefinition(1150673), null));
                    }
                }
            }

            foreach (Mobile m in toRemove)
            {
                if (m_WarehouseStorage.ContainsKey(m))
                {
                    m_WarehouseStorage.Remove(m);
                }
            }

            ColUtility.Free(toRemove);
        }