public static uint GetMinimumNewBid(Auction auction) { return(auction.CurrentBid + GetMinimumNewBidIncrement(auction)); }
public void RemoveAuction(Auction auction) { AllianceAuctions.RemoveAuction(auction); HordeAuctions.RemoveAuction(auction); NeutralAuctions.RemoveAuction(auction); }
public void AuctionPlaceBid(Character chr, NPC auctioneer, uint auctionId, uint bid) { if (!DoAuctioneerInteraction(chr, auctioneer)) { return; } Auction auction = null; if (!auctioneer.AuctioneerEntry.Auctions.TryGetAuction(auctionId, out auction)) { AuctionHandler.SendAuctionCommandResult(chr.Client, null, AuctionAction.PlaceBid, AuctionError.InternalError); } else { AuctionError error = AuctionBidChecks(auction, chr, bid); if (error != AuctionError.Ok) { AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.PlaceBid, error); } else if (bid < auction.BuyoutPrice || auction.BuyoutPrice == 0U) { if (auction.BidderLowId == (long)(ulong)chr.EntityId) { chr.SubtractMoney(bid - auction.CurrentBid); } else { chr.SubtractMoney(bid); SendOutbidMail(auction, bid); } auction.BidderLowId = chr.EntityId.Low; auction.CurrentBid = bid; AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.PlaceBid, AuctionError.Ok); } else { if (auction.BidderLowId == (long)(ulong)chr.EntityId) { chr.SubtractMoney(auction.BuyoutPrice - auction.CurrentBid); } else { chr.SubtractMoney(auction.BuyoutPrice); if ((int)auction.BidderLowId != (int)auction.OwnerLowId) { SendOutbidMail(auction, auction.BuyoutPrice); } } auction.BidderLowId = chr.EntityId.Low; auction.CurrentBid = auction.BuyoutPrice; SendAuctionSuccessfullMail(auction); SendAuctionWonMail(auction); AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.PlaceBid, AuctionError.Ok); auctioneer.AuctioneerEntry.Auctions.RemoveAuction(auction); } } }
public static uint GetMinimumNewBid(Auction auction) { // Bids must increase by the larger of 5% or 1 copper each time. return(auction.CurrentBid + GetMinimumNewBidIncrement(auction)); }
public void AuctionPlaceBid(Character chr, NPC auctioneer, uint auctionId, uint bid) { if (!DoAuctioneerInteraction(chr, auctioneer)) { return; } Auction auction = null; if (!auctioneer.AuctioneerEntry.Auctions.TryGetAuction(auctionId, out auction)) { AuctionHandler.SendAuctionCommandResult(chr.Client, null, AuctionAction.PlaceBid, AuctionError.InternalError); return; } var msg = AuctionBidChecks(auction, chr, bid); if (msg != AuctionError.Ok) { AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.PlaceBid, msg); return; } if (bid < auction.BuyoutPrice || (auction.BuyoutPrice == 0)) { if (auction.BidderLowId == chr.EntityId) { chr.Money -= (bid - auction.CurrentBid); } else { chr.Money -= bid; // Send a mail to the outbid character with their bid money SendOutbidMail(auction, bid); } auction.BidderLowId = chr.EntityId.Low; auction.CurrentBid = bid; AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.PlaceBid, AuctionError.Ok); } else { // This is a buyout if (auction.BidderLowId == chr.EntityId) { chr.Money -= (auction.BuyoutPrice - auction.CurrentBid); } else { chr.Money -= auction.BuyoutPrice; if (auction.BidderLowId != auction.OwnerLowId) { // Someone had already bid on this item, send them a rejection letter SendOutbidMail(auction, auction.BuyoutPrice); } } auction.BidderLowId = chr.EntityId.Low; auction.CurrentBid = auction.BuyoutPrice; SendAuctionSuccessfullMail(auction); SendAuctionWonMail(auction); AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.PlaceBid, AuctionError.Ok); auctioneer.AuctioneerEntry.Auctions.RemoveAuction(auction); } }
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); } }
public bool TryGetAuction(uint auctionId, out Auction auction) { return(auctions.TryGetValue(auctionId, out auction)); }
public void RemoveAuction(Auction auction) { this.AllianceAuctions.RemoveAuction(auction); this.HordeAuctions.RemoveAuction(auction); this.NeutralAuctions.RemoveAuction(auction); }