public bool TryBuyout(Mobile m) { if (!OnGoing || InClaimPeriod || Buyout <= 0) { return(false); } if (m.Account is Account acct) { if (!acct.WithdrawGold(Buyout)) { m.SendLocalizedMessage(1155867); // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction. return(false); } VaultLogging.Buyout(this, m, Buyout); if (HighestBid != null && HighestBid.Mobile != m) { DoOutBidMessage(HighestBid.Mobile); HighestBid.Refund(this, HighestBid.CurrentBid); } HighestBid = GetBidEntry(m, true); HighestBid.CurrentBid = Buyout - (int)(Buyout * .05); CurrentBid = Buyout; EndAuction(true); ClaimPrize(m); return(true); } return(false); }
public void Refund(Auction auction, long amount) { if (Mobile.Account is Account a) { a.DepositGold(amount); VaultLogging.LogRefund(auction, Mobile, amount); } }
public void Refund(Auction auction, long amount) { Account a = Mobile.Account as Account; if (a != null) { a.DepositGold(amount); VaultLogging.LogRefund(auction, Mobile, amount); } }
public void EndAuction(bool buyout) { if (HighestBid != null && HighestBid.Mobile != null) { var isPublic = PublicAuction; var m = HighestBid.Mobile; string name = AuctionItemName(); if (string.IsNullOrEmpty(name)) { name = "the item you bid on"; } NewMaginciaMessage message = new NewMaginciaMessage(null, isPublic ? 1158078 : 1156426, TimeSpan.FromHours(72), string.Format("{0}\t{1}\t{2}", name, CurrentPlatBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")), CurrentGoldBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")))); /* You have won an auction for ~1_ITEMNAME~! Your bid amount of ~2_BIDAMT~plat and ~3_BIDAMT~gp won the auction. * You have 3 days from the end of the auction to claim your item or it will be lost.*/ MaginciaLottoSystem.SendMessageTo(HighestBid.Mobile, message); if (!buyout) { VaultLogging.WinAuction(this, m, CurrentBid, HighestBid.CurrentBid); } Account a = m.Account as Account; Account b = isPublic ? null : Owner.Account as Account; long dif = HighestBid.CurrentBid - CurrentBid; if (a != null && dif > 0) { a.DepositGold(dif); } if (b != null) { b.DepositGold(HighestBid.CurrentBid); } if (!isPublic) { message = new NewMaginciaMessage(null, new TextDefinition(1156428), TimeSpan.FromHours(24), string.Format("{0}\t{1}\t{2}", name, CurrentPlatBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")), CurrentGoldBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")))); /*Your auction for ~1_ITEMNAME~ has ended with a winning bid of ~2_BIDAMT~plat and ~3_BIDAMT~gp. The winning bid has * been deposited into your currency account.*/ MaginciaLottoSystem.SendMessageTo(Owner, message); } ClaimPeriod = DateTime.UtcNow + TimeSpan.FromDays(3); } else { TrayAuction(); } CloseGumps(); }
public bool TryPlaceBid(Mobile m, long bidTotal) { if (!OnGoing || InClaimPeriod) { m.SendLocalizedMessage(1156432); // There is no active auction to complete this action. return(false); } BidEntry entry = GetBidEntry(m); Account acct = m.Account as Account; bool firstBid = HighestBid == null; long highestBid = firstBid ? CurrentBid : HighestBid.CurrentBid; if (acct == null || Banker.GetBalance(m) < bidTotal) { m.SendLocalizedMessage(1155867); // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction. return(false); } if ((firstBid && bidTotal < highestBid) || (!firstBid && bidTotal <= highestBid)) { m.SendLocalizedMessage(1156445); // You have been out bid. if (bidTotal > CurrentBid) { CurrentBid = bidTotal; AddToHistory(m, bidTotal); } } else { acct.WithdrawGold(bidTotal); entry.CurrentBid = bidTotal; var mobile = HighestBid != null ? HighestBid.Mobile : null; if (!firstBid) { if (mobile != m) { DoOutBidMessage(mobile); } HighestBid.Refund(this, highestBid); } else { AddToHistory(m, bidTotal); } m.SendLocalizedMessage(1156433); // Your bid has been placed. AuctionMap map = new AuctionMap(Safe); if (m.Backpack == null || !m.Backpack.TryDropItem(m, map, false)) { map.Delete(); } else { m.SendLocalizedMessage(1156478); // The auction safe map has been placed in your backpack. } VaultLogging.NewHighBid(this, m, mobile, bidTotal); HighestBid = entry; return(true); } return(false); }