private bool Deliver(string message, params object[] args) { IAccount a = DeliverTo.Account; if (a == null) { return(false); } if (AutoDonate.Find(a) == null) { AutoDonate.Register(a, new DonationProfile(a)); } AutoDonate.Profiles[a].Credits += _Credit; if (IsGift) { AutoDonate.Profiles[a].AddGift(this, message, args); } return(DeliveryConversion()); }
private bool DeliveryConversion() { const int amountCap = 60000; double exchangeRate = AutoDonate.CMOptions.ExchangeRate; DonationProfile dp = AutoDonate.Find(DeliverTo.Account); Container bank = DeliverTo.BankBox; if (bank != null) { Bag bag = new Bag(); if (IsGift) { bag.Name = "A Donation Gift Bag"; bag.Hue = 1152; string text = dp.Gifts.ContainsKey(ID) ? dp.Gifts[ID] : null; if (String.IsNullOrWhiteSpace(text)) { text = "Hi, " + DeliverTo.RawName + ", "; text += "Here is a gift, a token of my appreciation. "; text += "Don't spend it all in one place! "; text += "Regards, " + DeliverFrom.RawName; } bag.DropItem(new DonationGiftBook(DeliverFrom, text)); } else { bag.Name = "A Donation Reward Bag"; bag.Hue = 1152; } long exchanged = (long)(Credit * exchangeRate); while (exchanged >= amountCap) { Item cur = AutoDonate.CMOptions.CurrencyType.CreateInstance(); cur.Amount = amountCap; bag.DropItem(cur); if (cur.IsChildOf(bag)) { exchanged -= cur.Amount; } } if (exchanged > 0) { Item cur = AutoDonate.CMOptions.CurrencyType.CreateInstance(); cur.Amount = (int)exchanged; bag.DropItem(cur); if (cur.IsChildOf(bag)) { exchanged -= cur.Amount; } } if (exchanged > 0) { bag.Delete(); return(false); } bank.DropItem(bag); dp.Credits -= Credit; } return(true); }