Ejemplo n.º 1
0
        public void RemoveAuction(Auction auction)
        {
            if (auction == null || !auctions.ContainsKey(auction.AuctionId))
            {
                return;
            }
            auctions.Remove(auction.ItemLowId);
            items.Remove(auction.ItemLowId);
            AuctionMgr instance = Singleton <AuctionMgr> .Instance;
            ItemRecord record   = null;

            if (instance.AuctionItems.ContainsKey(auction.ItemLowId))
            {
                record = instance.AuctionItems[auction.ItemLowId];
                instance.AuctionItems.Remove(auction.ItemLowId);
            }

            ServerApp <RealmServer> .IOQueue.AddMessage(() =>
            {
                if (record != null)
                {
                    record.IsAuctioned = false;
                    record.Save();
                }

                auction.Delete();
            });
        }
Ejemplo n.º 2
0
        public void RemoveAuction(Auction auction)
        {
            if (auction == null)
            {
                return;
            }
            if (!auctions.ContainsKey(auction.AuctionId))
            {
                return;
            }
            auctions.Remove(auction.ItemLowId);
            items.Remove(auction.ItemLowId);
            AuctionMgr mgr    = AuctionMgr.Instance;
            ItemRecord record = null;

            if (mgr.AuctionItems.ContainsKey(auction.ItemLowId))
            {
                record = mgr.AuctionItems[auction.ItemLowId];
                mgr.AuctionItems.Remove(auction.ItemLowId);
            }


            //remove from database
            RealmServer.IOQueue.AddMessage(() => {
                if (record != null)
                {
                    record.IsAuctioned = false;
                    record.Save();
                }
                auction.Delete();
            });
        }
Ejemplo n.º 3
0
        public void AuctionSellItem(Character chr, NPC auctioneer, EntityId itemId, uint bid, uint buyout, uint time, uint stackSize)
        {
            if (!DoAuctioneerInteraction(chr, auctioneer))
            {
                return;
            }

            var item = chr.Inventory.GetItem(itemId, false);

            var msg = AuctionCheatChecks(auctioneer, item, bid, time);

            if (msg == AuctionError.Ok)
            {
                // Check that character has enough money to cover the deposit
                var houseFaction = auctioneer.AuctioneerEntry.LinkedHouseFaction;
                var deposit      = GetAuctionDeposit(item, houseFaction, time);
                if (chr.Money < deposit)
                {
                    AuctionHandler.SendAuctionCommandResult(chr.Client, null, AuctionAction.SellItem, AuctionError.NotEnoughMoney);
                    return;
                }

                if (item.Amount > stackSize)
                {
                    item = item.Split((int)stackSize);
                }

                if (item == null)
                {
                    AuctionHandler.SendAuctionCommandResult(chr.Client, null, AuctionAction.SellItem, AuctionError.ItemNotFound);
                    return;
                }


                // Charge the deposit to the character
                chr.Money -= deposit;


                // Create the new Auction and add it to the list.

                var newAuction = new Auction
                {
                    BidderLowId    = 0,
                    BuyoutPrice    = buyout,
                    CurrentBid     = bid,
                    Deposit        = deposit,
                    HouseFaction   = houseFaction,
                    ItemLowId      = item.EntityId.Low,
                    ItemTemplateId = item.Template.Id,
                    OwnerLowId     = chr.EntityId.Low,
                    TimeEnds       = DateTime.Now.AddMinutes(time),
                    IsNew          = true
                };



                //save new auction to database and add item to items container
                RealmServer.IOQueue.AddMessage(new Util.Threading.Message(() =>
                {
                    ItemRecord record  = item.Record;
                    record.IsAuctioned = true;
                    record.Save();
                    auctioneer.AuctioneerEntry.Auctions.AddAuction(
                        newAuction);
                    AuctionItems.Add(newAuction.ItemLowId, record);
                    item.Remove(false);
                    AuctionListOwnerItems(chr, auctioneer);
                }));

                // Send the all-good message
                AuctionHandler.SendAuctionCommandResult(chr.Client, newAuction, AuctionAction.SellItem, AuctionError.Ok);
            }
            else
            {
                AuctionHandler.SendAuctionCommandResult(chr.Client, null, AuctionAction.SellItem, msg);
            }
        }