Пример #1
0
        public void Update()
        {
            if (!Valid)
            {
                return;
            }

            if (!From.IsDisposed && From.Accepted && !To.IsDisposed && To.Accepted)
            {
                List <Item> list = From.Container.Items;

                bool allowed = true;

                for (int i = list.Count - 1; allowed && i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        if (item == From.VirtualCheck)
                        {
                            continue;
                        }

                        if (!item.AllowSecureTrade(From.Mobile, To.Mobile, To.Mobile, true))
                        {
                            allowed = false;
                        }
                    }
                }

                list = To.Container.Items;

                for (int i = list.Count - 1; allowed && i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        if (item == To.VirtualCheck)
                        {
                            continue;
                        }

                        if (!item.AllowSecureTrade(To.Mobile, From.Mobile, From.Mobile, true))
                        {
                            allowed = false;
                        }
                    }
                }

                if (AccountGold.Enabled)
                {
                    if (From.Mobile.Account != null)
                    {
                        int totalPlat = From.Mobile.Account.TotalPlat;
                        int totalGold = From.Mobile.Account.TotalGold;

                        if (totalPlat < From.Plat || totalGold < From.Gold)
                        {
                            allowed = false;
                            From.Mobile.SendMessage("You do not have enough currency to complete this trade.");
                        }
                    }

                    if (To.Mobile.Account != null)
                    {
                        int totalPlat = To.Mobile.Account.TotalPlat;
                        int totalGold = To.Mobile.Account.TotalGold;

                        if (totalPlat < To.Plat || totalGold < To.Gold)
                        {
                            allowed = false;
                            To.Mobile.SendMessage("You do not have enough currency to complete this trade.");
                        }
                    }
                }

                if (!allowed)
                {
                    From.Accepted = false;
                    To.Accepted   = false;

                    From.Mobile.Send(new UpdateSecureTrade(From.Container, From.Accepted, To.Accepted));
                    To.Mobile.Send(new UpdateSecureTrade(To.Container, To.Accepted, From.Accepted));

                    return;
                }

                if (AccountGold.Enabled && From.Mobile.Account != null && To.Mobile.Account != null)
                {
                    HandleAccountGoldTrade();
                }

                list = From.Container.Items;

                for (int i = list.Count - 1; i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        if (item == From.VirtualCheck)
                        {
                            continue;
                        }

                        item.OnSecureTrade(From.Mobile, To.Mobile, To.Mobile, true);

                        if (!item.Deleted)
                        {
                            To.Mobile.AddToBackpack(item);
                        }
                    }
                }

                list = To.Container.Items;

                for (int i = list.Count - 1; i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        if (item == To.VirtualCheck)
                        {
                            continue;
                        }

                        item.OnSecureTrade(To.Mobile, From.Mobile, From.Mobile, true);

                        if (!item.Deleted)
                        {
                            From.Mobile.AddToBackpack(item);
                        }
                    }
                }

                Close();
            }
            else if (!From.IsDisposed && !To.IsDisposed)
            {
                From.Mobile.Send(new UpdateSecureTrade(From.Container, From.Accepted, To.Accepted));
                To.Mobile.Send(new UpdateSecureTrade(To.Container, To.Accepted, From.Accepted));
            }
        }
Пример #2
0
        public void Update()
        {
            if (!m_Valid)
            {
                return;
            }

            if (m_From.Accepted && m_To.Accepted)
            {
                List <Item> list = m_From.Container.Items;

                bool allowed = true;

                for (int i = list.Count - 1; allowed && i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        if (!item.AllowSecureTrade(m_From.Mobile, m_To.Mobile, m_To.Mobile, true))
                        {
                            allowed = false;
                        }
                    }
                }

                list = m_To.Container.Items;

                for (int i = list.Count - 1; allowed && i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        if (!item.AllowSecureTrade(m_To.Mobile, m_From.Mobile, m_From.Mobile, true))
                        {
                            allowed = false;
                        }
                    }
                }

                if (!allowed)
                {
                    m_From.Accepted = false;
                    m_To.Accepted   = false;

                    m_From.Mobile.Send(new UpdateSecureTrade(m_From.Container, m_From.Accepted, m_To.Accepted));
                    m_To.Mobile.Send(new UpdateSecureTrade(m_To.Container, m_To.Accepted, m_From.Accepted));

                    return;
                }

                list = m_From.Container.Items;

                for (int i = list.Count - 1; i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        item.OnSecureTrade(m_From.Mobile, m_To.Mobile, m_To.Mobile, true);

                        if (!item.Deleted)
                        {
                            m_To.Mobile.AddToBackpack(item);
                        }
                    }
                }

                list = m_To.Container.Items;

                for (int i = list.Count - 1; i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        item.OnSecureTrade(m_To.Mobile, m_From.Mobile, m_From.Mobile, true);

                        if (!item.Deleted)
                        {
                            m_From.Mobile.AddToBackpack(item);
                        }
                    }
                }

                Close();
            }
            else
            {
                m_From.Mobile.Send(new UpdateSecureTrade(m_From.Container, m_From.Accepted, m_To.Accepted));
                m_To.Mobile.Send(new UpdateSecureTrade(m_To.Container, m_To.Accepted, m_From.Accepted));
            }
        }
Пример #3
0
        public void Update()
        {
            if (!Valid)
            {
                return;
            }

            if (!From.IsDisposed && From.Accepted && !To.IsDisposed && To.Accepted)
            {
                System.Collections.Generic.List <Item> list = From.Container.Items;

                bool allowed = true;

                for (int i = list.Count - 1; allowed && i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        if (item == From.VirtualCheck)
                        {
                            continue;
                        }

                        if (!item.AllowSecureTrade(From.Mobile, To.Mobile, To.Mobile, true))
                        {
                            allowed = false;
                        }
                    }
                }

                list = To.Container.Items;

                for (int i = list.Count - 1; allowed && i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        if (item == To.VirtualCheck)
                        {
                            continue;
                        }

                        if (!item.AllowSecureTrade(To.Mobile, From.Mobile, From.Mobile, true))
                        {
                            allowed = false;
                        }
                    }
                }

                if (AccountGold.Enabled)
                {
                    if (From.Mobile.Account != null)
                    {
                        double cur = From.Mobile.Account.TotalCurrency;
                        double off = From.Plat + (From.Gold / Math.Max(1.0, AccountGold.CurrencyThreshold));

                        if (off > cur)
                        {
                            allowed = false;
                            From.Mobile.SendMessage("You do not have enough currency to complete this trade.");
                        }
                    }

                    if (To.Mobile.Account != null)
                    {
                        double cur = To.Mobile.Account.TotalCurrency;
                        double off = To.Plat + (To.Gold / Math.Max(1.0, AccountGold.CurrencyThreshold));

                        if (off > cur)
                        {
                            allowed = false;
                            To.Mobile.SendMessage("You do not have enough currency to complete this trade.");
                        }
                    }
                }

                if (!allowed)
                {
                    From.Accepted = false;
                    To.Accepted   = false;

                    From.Mobile.Send(new UpdateSecureTrade(From.Container, From.Accepted, To.Accepted));
                    To.Mobile.Send(new UpdateSecureTrade(To.Container, To.Accepted, From.Accepted));

                    return;
                }

                if (AccountGold.Enabled && From.Mobile.Account != null && To.Mobile.Account != null)
                {
                    HandleAccountGoldTrade();
                }

                list = From.Container.Items;

                for (int i = list.Count - 1; i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        if (item == From.VirtualCheck)
                        {
                            continue;
                        }

                        item.OnSecureTrade(From.Mobile, To.Mobile, To.Mobile, true);

                        if (!item.Deleted)
                        {
                            To.Mobile.AddToBackpack(item);
                        }
                    }
                }

                list = To.Container.Items;

                for (int i = list.Count - 1; i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        if (item == To.VirtualCheck)
                        {
                            continue;
                        }

                        item.OnSecureTrade(To.Mobile, From.Mobile, From.Mobile, true);

                        if (!item.Deleted)
                        {
                            From.Mobile.AddToBackpack(item);
                        }
                    }
                }

                Close();
            }
            else if (!From.IsDisposed && !To.IsDisposed)
            {
                From.Mobile.Send(new UpdateSecureTrade(From.Container, From.Accepted, To.Accepted));
                To.Mobile.Send(new UpdateSecureTrade(To.Container, To.Accepted, From.Accepted));
            }
        }
Пример #4
0
        public void Update()
        {
            if (!m_Valid)
            {
                return;
            }

            if (m_From.Accepted && m_To.Accepted)
            {
                //List<Item> list = m_From.Container.Items;
                List <Item> list = new List <Item>();
                try
                {
                    for (int i = 0; i < m_From.Container.Items.Count; i++)
                    {
                        try
                        {
                            Item it = m_From.Container.Items[i] as Item;
                            if (it != null)
                            {
                                list.Add(it);
                            }
                        }
                        catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
                    }
                }
                catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }

                bool allowed = true;

                for (int i = list.Count - 1; allowed && i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        if (!item.AllowSecureTrade(m_From.Mobile, m_To.Mobile, m_To.Mobile, true))
                        {
                            allowed = false;
                        }
                    }
                }

                //list = m_To.Container.Items;
                list = new List <Item>();
                try
                {
                    for (int i = 0; i < m_To.Container.Items.Count; i++)
                    {
                        try
                        {
                            Item it = m_To.Container.Items[i] as Item;
                            if (it != null)
                            {
                                list.Add(it);
                            }
                        }
                        catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
                    }
                }
                catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }


                for (int i = list.Count - 1; allowed && i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        if (!item.AllowSecureTrade(m_To.Mobile, m_From.Mobile, m_From.Mobile, true))
                        {
                            allowed = false;
                        }
                    }
                }

                if (!allowed)
                {
                    m_From.Accepted = false;
                    m_To.Accepted   = false;

                    m_From.Mobile.Send(new UpdateSecureTrade(m_From.Container, m_From.Accepted, m_To.Accepted));
                    m_To.Mobile.Send(new UpdateSecureTrade(m_To.Container, m_To.Accepted, m_From.Accepted));

                    return;
                }

                //list = m_From.Container.Items;
                list = new List <Item>();
                try
                {
                    for (int i = 0; i < m_From.Container.Items.Count; i++)
                    {
                        try
                        {
                            Item it = m_From.Container.Items[i] as Item;
                            if (it != null)
                            {
                                list.Add(it);
                            }
                        }
                        catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
                    }
                }
                catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }

                for (int i = list.Count - 1; i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        item.OnSecureTrade(m_From.Mobile, m_To.Mobile, m_To.Mobile, true);

                        if (!item.Deleted)
                        {
                            m_To.Mobile.AddToBackpack(item);
                        }
                    }
                }

                //list = m_To.Container.Items;
                list = new List <Item>();
                try
                {
                    for (int i = 0; i < m_To.Container.Items.Count; i++)
                    {
                        try
                        {
                            Item it = m_To.Container.Items[i] as Item;
                            if (it != null)
                            {
                                list.Add(it);
                            }
                        }
                        catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
                    }
                }
                catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }


                for (int i = list.Count - 1; i >= 0; --i)
                {
                    if (i < list.Count)
                    {
                        Item item = list[i];

                        item.OnSecureTrade(m_To.Mobile, m_From.Mobile, m_From.Mobile, true);

                        if (!item.Deleted)
                        {
                            m_From.Mobile.AddToBackpack(item);
                        }
                    }
                }

                Close();
            }
            else
            {
                m_From.Mobile.Send(new UpdateSecureTrade(m_From.Container, m_From.Accepted, m_To.Accepted));
                m_To.Mobile.Send(new UpdateSecureTrade(m_To.Container, m_To.Accepted, m_From.Accepted));
            }
        }