Example #1
0
        public void SendAuctionOutbidMail(BlackMarketEntry entry, SQLTransaction trans)
        {
            ObjectGuid oldBidder_guid = ObjectGuid.Create(HighGuid.Player, entry.GetBidder());
            Player     oldBidder      = Global.ObjAccessor.FindConnectedPlayer(oldBidder_guid);

            uint oldBidder_accId = 0;

            if (!oldBidder)
            {
                oldBidder_accId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(oldBidder_guid);
            }

            // old bidder exist
            if (!oldBidder && oldBidder_accId == 0)
            {
                return;
            }

            if (oldBidder)
            {
                oldBidder.GetSession().SendBlackMarketOutbidNotification(entry.GetTemplate());
            }

            new MailDraft(entry.BuildAuctionMailSubject(BMAHMailAuctionAnswers.Outbid), entry.BuildAuctionMailBody())
            .AddMoney(entry.GetCurrentBid())
            .SendMailTo(trans, new MailReceiver(oldBidder, entry.GetBidder()), new MailSender(entry), MailCheckMask.Copied);
        }
Example #2
0
        public void SendAuctionWonMail(BlackMarketEntry entry, SQLTransaction trans)
        {
            // Mail already sent
            if (entry.GetMailSent())
            {
                return;
            }

            uint       bidderAccId;
            ObjectGuid bidderGuid = ObjectGuid.Create(HighGuid.Player, entry.GetBidder());
            Player     bidder     = Global.ObjAccessor.FindConnectedPlayer(bidderGuid);
            // data for gm.log
            string bidderName = "";
            bool   logGmTrade;

            if (bidder)
            {
                bidderAccId = bidder.GetSession().GetAccountId();
                bidderName  = bidder.GetName();
                logGmTrade  = bidder.GetSession().HasPermission(RBACPermissions.LogGmTrade);
            }
            else
            {
                bidderAccId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(bidderGuid);
                if (bidderAccId == 0) // Account exists
                {
                    return;
                }

                logGmTrade = Global.AccountMgr.HasPermission(bidderAccId, RBACPermissions.LogGmTrade, Global.WorldMgr.GetRealmId().Index);

                if (logGmTrade && !Global.CharacterCacheStorage.GetCharacterNameByGuid(bidderGuid, out bidderName))
                {
                    bidderName = Global.ObjectMgr.GetCypherString(CypherStrings.Unknown);
                }
            }

            // Create item
            BlackMarketTemplate templ = entry.GetTemplate();
            Item item = Item.CreateItem(templ.Item.ItemID, templ.Quantity, ItemContext.BlackMarket);

            if (!item)
            {
                return;
            }

            if (templ.Item.ItemBonus.HasValue)
            {
                foreach (uint bonusList in templ.Item.ItemBonus.Value.BonusListIDs)
                {
                    item.AddBonuses(bonusList);
                }
            }

            item.SetOwnerGUID(bidderGuid);

            item.SaveToDB(trans);

            // Log trade
            if (logGmTrade)
            {
                Log.outCommand(bidderAccId, "GM {0} (Account: {1}) won item in blackmarket auction: {2} (Entry: {3} Count: {4}) and payed gold : {5}.",
                               bidderName, bidderAccId, item.GetTemplate().GetName(), item.GetEntry(), item.GetCount(), entry.GetCurrentBid() / MoneyConstants.Gold);
            }

            if (bidder)
            {
                bidder.GetSession().SendBlackMarketWonNotification(entry, item);
            }

            new MailDraft(entry.BuildAuctionMailSubject(BMAHMailAuctionAnswers.Won), entry.BuildAuctionMailBody())
            .AddItem(item)
            .SendMailTo(trans, new MailReceiver(bidder, entry.GetBidder()), new MailSender(entry), MailCheckMask.Copied);

            entry.MailSent();
        }