Ejemplo n.º 1
0
        public void CancelAuction(Character chr, NPC auctioneer, uint auctionId)
        {
            if (!DoAuctioneerInteraction(chr, auctioneer))
            {
                return;
            }
            Auction auction;

            if (auctioneer.AuctioneerEntry.Auctions.TryGetAuction(auctionId, out auction))
            {
                if ((int)auction.OwnerLowId == (int)chr.EntityId.Low)
                {
                    ItemRecord recordById = ItemRecord.GetRecordByID(auction.ItemLowId);
                    if (recordById != null)
                    {
                        if ((int)auction.BidderLowId != (int)auction.OwnerLowId)
                        {
                            uint amount = CalcAuctionCut(auction.HouseFaction, auction.CurrentBid);
                            if (chr.Money < amount)
                            {
                                AuctionHandler.SendAuctionCommandResult(chr.Client, auction,
                                                                        AuctionAction.CancelAuction, AuctionError.NotEnoughMoney);
                                return;
                            }

                            auction.SendMail(MailAuctionAnswers.CancelledToBidder, auction.CurrentBid);
                            chr.SubtractMoney(amount);
                        }

                        auction.SendMail(MailAuctionAnswers.Cancelled, recordById);
                        auctioneer.AuctioneerEntry.Auctions.RemoveAuction(auction);
                        AuctionHandler.SendAuctionCommandResult(chr.Client, auction,
                                                                AuctionAction.CancelAuction, AuctionError.Ok);
                        auctioneer.AuctioneerEntry.Auctions.RemoveAuction(auction);
                    }
                    else
                    {
                        AuctionHandler.SendAuctionCommandResult(chr.Client, auction,
                                                                AuctionAction.CancelAuction, AuctionError.ItemNotFound);
                    }
                }
                else
                {
                    AuctionHandler.SendAuctionCommandResult(chr.Client, auction,
                                                            AuctionAction.CancelAuction, AuctionError.ItemNotFound);
                }
            }
            else
            {
                AuctionHandler.SendAuctionCommandResult(chr.Client, auction,
                                                        AuctionAction.CancelAuction, AuctionError.ItemNotFound);
            }
        }
Ejemplo n.º 2
0
        private static void SendAuctionWonMail(Auction auction)
        {
            if (auction == null)
            {
                return;
            }
            var body   = String.Format("{0,16:X}:{1,16:D}:{2,16:D}", auction.OwnerLowId, auction.CurrentBid, auction.BuyoutPrice);
            var record = ItemRecord.GetRecordByID(auction.ItemLowId);

            if (record != null)
            {
                auction.SendMail(MailAuctionAnswers.Won, 0, record, body);
                // log it?
            }
        }
Ejemplo n.º 3
0
        private static void SendAuctionWonMail(Auction auction)
        {
            if (auction == null)
            {
                return;
            }
            string body = string.Format("{0,16:X}:{1,16:D}:{2,16:D}", auction.OwnerLowId,
                                        auction.CurrentBid, auction.BuyoutPrice);
            ItemRecord recordById = ItemRecord.GetRecordByID(auction.ItemLowId);

            if (recordById == null)
            {
                return;
            }
            auction.SendMail(MailAuctionAnswers.Won, 0U, recordById, body);
        }
Ejemplo n.º 4
0
        public void CancelAuction(Character chr, NPC auctioneer, uint auctionId)
        {
            if (!DoAuctioneerInteraction(chr, auctioneer))
            {
                return;
            }

            Auction auction;

            if (auctioneer.AuctioneerEntry.Auctions.TryGetAuction(auctionId, out auction))
            {
                if (auction.OwnerLowId == chr.EntityId.Low)
                {
                    var itemRecord = ItemRecord.GetRecordByID(auction.ItemLowId);
                    if (itemRecord != null)
                    {
                        if (auction.BidderLowId != auction.OwnerLowId)
                        {
                            // someone has bid on the item already, his money must be returned
                            // and the cancelling player must be charged the auctionhouse's cut
                            var auctionhouseCut = CalcAuctionCut(auction.HouseFaction, auction.CurrentBid);
                            if (chr.Money < auctionhouseCut)
                            {
                                // the player is no-good for the money, the auction cannot be cancelled
                                AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.CancelAuction, AuctionError.NotEnoughMoney);
                                return;
                            }

                            //var bidder = WorldMgr.GetCharacter(auction.BidderLowId);
                            //if (bidder != null)
                            //{
                            // send bidder a notification?
                            //}
                            auction.SendMail(MailAuctionAnswers.CancelledToBidder, auction.CurrentBid);
                            chr.Money -= auctionhouseCut;
                        }

                        // return the item to the seller via mail
                        auction.SendMail(MailAuctionAnswers.Cancelled, itemRecord);
                        auctioneer.AuctioneerEntry.Auctions.RemoveAuction(auction);
                    }
                    else
                    {
                        // auction contains a non-existant item
                        AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.CancelAuction, AuctionError.ItemNotFound);
                        return;
                    }
                }
                else
                {
                    // trying to cancel someone else's auction -- CHEATER!
                    AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.CancelAuction, AuctionError.ItemNotFound);
                    return;
                }
            }
            else
            {
                // auction not found -- CHEATER?
                AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.CancelAuction, AuctionError.ItemNotFound);
                return;
            }

            AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.CancelAuction, AuctionError.Ok);
            auctioneer.AuctioneerEntry.Auctions.RemoveAuction(auction);
        }