🪲 Fixed bid increment logic to make more sense when using realistic bidding mode. Closes #52

Took 15 minutes
This commit is contained in:
Kiran Hart 2023-04-28 11:54:35 -04:00
parent 348fa536d9
commit 96a6a5a8d2
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
4 changed files with 20 additions and 9 deletions

View File

@ -68,6 +68,5 @@ public final class AuctionBid implements Bid {
@Override
public void store(Consumer<Bid> storedItem) {
// TODO implement auction bid store
}
}

View File

@ -205,8 +205,7 @@ public final class CommandSell extends AbstractCommand {
final boolean isBiddingItem = Settings.FORCE_AUCTION_USAGE.getBoolean() || buyNowPrice != null && startingBid != null && Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean();
// NOT USING THE BIDDING SYSTEM
if (!isBiddingItem /* && buyNowPrice != null */) {
// min item price todo fix it broke
if (!isBiddingItem) {
if (!AuctionAPI.getInstance().meetsMinItemPrice(isBundle, isBiddingItem, originalItem, buyNowPrice, isBiddingItem ? startingBid : 0)) {
instance.getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(instance.getMinItemPriceManager().getMinPrice(originalItem).getPrice())).sendPrefixedMessage(player);
return ReturnType.FAILURE;
@ -216,8 +215,7 @@ public final class CommandSell extends AbstractCommand {
if (!checkBasePrice(player, buyNowPrice, false)) return ReturnType.FAILURE;
}
if (isBiddingItem && /* buyNowPrice != null && */ startingBid != null) {
// min item price todo fix it broke
if (isBiddingItem && startingBid != null) {
if (!AuctionAPI.getInstance().meetsMinItemPrice(isBundle, isBiddingItem, originalItem, buyNowPrice, isBiddingItem ? startingBid : 0)) {
instance.getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(instance.getMinItemPriceManager().getMinPrice(originalItem).getPrice())).sendPrefixedMessage(player);
return ReturnType.FAILURE;

View File

@ -73,7 +73,10 @@ public class GUIBid extends AbstractPlaceholderGui {
}
e.gui.exit();
e.manager.showGUI(e.player, new GUIConfirmBid(this.auctionPlayer, auctionItem));
// THE MINIMUM
final double minBid = Settings.USE_REALISTIC_BIDDING.getBoolean() ? this.auctionItem.getCurrentPrice() + this.auctionItem.getBidIncrementPrice() : this.auctionItem.getBidIncrementPrice();
e.manager.showGUI(e.player, new GUIConfirmBid(this.auctionPlayer, auctionItem, minBid));
});
// TODO UPDATE BID
@ -110,6 +113,11 @@ public class GUIBid extends AbstractPlaceholderGui {
double newBiddingAmount = 0;
if (Settings.USE_REALISTIC_BIDDING.getBoolean()) {
if (value < auctionItem.getCurrentPrice() + auctionItem.getBidIncrementPrice()) {
AuctionHouse.getInstance().getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice() + auctionItem.getBidIncrementPrice())).sendPrefixedMessage(e.player);
return false;
}
if (value > GUIBid.this.auctionItem.getCurrentPrice()) {
newBiddingAmount = value;
} else {
@ -122,6 +130,11 @@ public class GUIBid extends AbstractPlaceholderGui {
newBiddingAmount = GUIBid.this.auctionItem.getCurrentPrice() + value;
}
} else {
if (value < auctionItem.getBidIncrementPrice()) {
AuctionHouse.getInstance().getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(auctionItem.getBidIncrementPrice())).sendPrefixedMessage(e.player);
return false;
}
newBiddingAmount = GUIBid.this.auctionItem.getCurrentPrice() + value;
}
@ -181,6 +194,7 @@ public class GUIBid extends AbstractPlaceholderGui {
auctionItem.setHighestBidder(e.player.getUniqueId());
auctionItem.setHighestBidderName(e.player.getName());
auctionItem.setCurrentPrice(newBiddingAmount);
if (auctionItem.getBasePrice() != -1 && Settings.SYNC_BASE_PRICE_TO_HIGHEST_PRICE.getBoolean() && auctionItem.getCurrentPrice() > auctionItem.getBasePrice()) {
auctionItem.setBasePrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(auctionItem.getCurrentPrice()) : auctionItem.getCurrentPrice());
}

View File

@ -49,9 +49,9 @@ public class GUIConfirmBid extends AbstractPlaceholderGui {
private final double bidAmount;
private BukkitTask bukkitTask;
public GUIConfirmBid(AuctionPlayer auctionPlayer, AuctionedItem auctionItem) {
this(auctionPlayer, auctionItem, -1);
}
// public GUIConfirmBid(AuctionPlayer auctionPlayer, AuctionedItem auctionItem) {
// this(auctionPlayer, auctionItem, -1);
// }
public GUIConfirmBid(AuctionPlayer auctionPlayer, AuctionedItem auctionItem, double bidAmount) {
super(auctionPlayer);