Ejemplo n.º 1
0
 public ResourceTransaction(TransactionType ttype)
 {
     m_TransType     = ttype;
     m_TransactionID = ResourceLogger.GetTransID();
     m_Date          = DateTime.Now;
     ResName         = "";
     Amount          = 0;
     Price           = 0;
     NewAmount       = 0;
     VendorID        = 0;
 }
Ejemplo n.º 2
0
        public static double AddToPool(Mobile seller, Type type, int amount, bool truncateprice, Serial vendorid)
        {
            if (m_Resources[type] == null)
            {
                return(-1);
            }

            ResourceTransaction rt = new ResourceTransaction(TransactionType.Sale);

            rt.Amount   = amount;
            rt.ResName  = ((ResourceData)m_Resources[type]).Name;
            rt.VendorID = vendorid;

            double ret = ((ResourceData)m_Resources[type]).Add(seller, amount, truncateprice);

            rt.NewAmount = ((ResourceData)m_Resources[type]).TotalCount;
            rt.Price     = ret;

            ResourceLogger.Add(rt, seller);

            return(ret);
        }
Ejemplo n.º 3
0
        public static bool SellOff(Type type, int amount, Serial vendorid, Mobile player)
        {
            if (((ResourceData)m_Resources[type]).TotalCount < amount)
            {
                return(false);
            }

            ResourceTransaction rt = new ResourceTransaction(TransactionType.Purchase);

            rt.Amount   = amount;
            rt.Price    = ((ResourceData)m_Resources[type]).ResalePrice;
            rt.ResName  = ((ResourceData)m_Resources[type]).Name;
            rt.VendorID = vendorid;

            ResourceConsignment[] topay = ((ResourceData)m_Resources[type]).Remove(amount);

            rt.NewAmount = ((ResourceData)m_Resources[type]).TotalCount;

            foreach (ResourceConsignment rc in topay)
            {
                if (rc.Seller == null || rc.Seller.Deleted)
                {
                    BountySystem.BountyKeeper.LBFund += (int)(rc.Amount * rc.Price * m_PaymentFactor);
                    continue;
                }

                // do this here instead of when writing check so player may know how much is waiting
                ResourceTransaction rtpay = new ResourceTransaction(TransactionType.Payment);
                rtpay.Amount   = rc.Amount;
                rtpay.Price    = rc.Price * m_PaymentFactor;
                rtpay.ResName  = ((ResourceData)m_Resources[type]).Name;
                rtpay.VendorID = vendorid;
                ResourceLogger.Add(rtpay, rc.Seller);

                if (m_Debts[rc.Seller] == null)
                {
                    m_Debts[rc.Seller] = (double)rc.Amount * rc.Price * m_PaymentFactor;
                }
                else
                {
                    m_Debts[rc.Seller] = (double)rc.Amount * rc.Price * m_PaymentFactor + (double)m_Debts[rc.Seller];
                }
            }

            Mobile[] keys = new Mobile[m_Debts.Count];
            m_Debts.Keys.CopyTo(keys, 0);
            foreach (Mobile m in keys)
            {
                double payment = (double)m_Debts[m];
                if (payment > 1)
                {
                    Container bank = m.BankBox;

                    PaymentCheck check = (PaymentCheck)bank.FindItemByType(typeof(PaymentCheck), false);
                    if (check != null)
                    {
                        check.Worth += (int)payment;
                        m_Debts[m]   = (double)m_Debts[m] - (int)payment;
                    }
                    else
                    {
                        check = new PaymentCheck((int)payment);
                        if (bank.Items.Count < 125)
                        {
                            check.SetLastMoved();
                            bank.DropItem(check);
                            m_Debts[m] = (double)m_Debts[m] - (int)payment;
                        }
                    }
                }
                if ((double)m_Debts[m] <= 0)
                {
                    m_Debts.Remove(m);
                }
            }

            ResourceLogger.Add(rt, player);

            return(true);
        }