Skip to content

Commit 960ece9

Browse files
committed
Fixed Mercenary Auction Decline Auction Option
- Introduced `DECLINE_AUCTION_OPTION`. - Added an early return for the decline auction option, avoiding unnecessary processing. - Fixed bug where declining the auction made a bid, while bidding canceled the auction.
1 parent d2b7d98 commit 960ece9

File tree

1 file changed

+39
-36
lines changed

1 file changed

+39
-36
lines changed

MekHQ/src/mekhq/campaign/randomEvents/MercenaryAuction.java

+39-36
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class MercenaryAuction {
5555
private static final String RESOURCE_BUNDLE = "mekhq.resources." + MercenaryAuctionDialog.class.getSimpleName();
5656

5757
private static final int AUCTION_TIER_SUCCESS_PERCENT = 20;
58+
private static final int DECLINE_AUCTION_OPTION = 0;
5859

5960
/**
6061
* Creates and processes a mercenary auction.
@@ -67,7 +68,7 @@ public class MercenaryAuction {
6768
* @param unitType The type of unit being auctioned (e.g., `MECH`, `VEHICLE`).
6869
*/
6970
public MercenaryAuction(Campaign campaign, int requiredCombatTeams, StratconCampaignState campaignState,
70-
int unitType) {
71+
int unitType) {
7172
String faction = campaign.getFaction().getShortName();
7273

7374
Entity entity = getEntity(faction,
@@ -127,42 +128,44 @@ public MercenaryAuction(Campaign campaign, int requiredCombatTeams, StratconCamp
127128
max(requiredCombatTeams, 1));
128129
int finalBid = (mercenaryAuctionDialog.getSpinnerValue() / minimumBid) * AUCTION_TIER_SUCCESS_PERCENT;
129130

130-
// If the player confirmed the auction (option 0) then check whether they were successful,
131+
// If the player confirmed the auction, then check whether they were successful,
131132
// deliver the unit, and deduct funds.
132-
if (mercenaryAuctionDialog.getDialogChoice() == 0) {
133-
// The use of <= is important here as it ensures that even if the user bids 50 %, they can
134-
// still win.
135-
if (randomInt(100) <= finalBid) {
136-
campaignState.changeSupportPoints(finalBid);
137-
138-
// The delivery time is so that the unit addition is picked up by the 'mothball'
139-
// campaign option. It also makes sense the unit wouldn't magically materialize in your
140-
// hangar and has to get there.
141-
int deliveryTime = d6();
142-
// The +1 here is to account for this being an end of day event, so we automatically
143-
// eat the first day.
144-
campaign.addNewUnit(entity, false, deliveryTime + 1);
145-
146-
// This dialog informs the player their bid was successful
147-
new ImmersiveDialogSimple(campaign,
148-
campaign.getSeniorAdminPerson(TRANSPORT),
149-
null,
150-
getFormattedTextAt(RESOURCE_BUNDLE, "auction.successful", entity.getChassis(), deliveryTime),
151-
null,
152-
null,
153-
null,
154-
true);
155-
} else {
156-
// This dialog informs the player their bid was unsuccessful
157-
new ImmersiveDialogSimple(campaign,
158-
campaign.getSeniorAdminPerson(TRANSPORT),
159-
null,
160-
getFormattedTextAt(RESOURCE_BUNDLE, "auction.failure", entity.getChassis()),
161-
null,
162-
null,
163-
null,
164-
true);
165-
}
133+
if (mercenaryAuctionDialog.getDialogChoice() == DECLINE_AUCTION_OPTION) {
134+
return;
135+
}
136+
137+
// The use of <= is important here as it ensures that even if the user bids 50 %, they can
138+
// still win.
139+
if (randomInt(100) <= finalBid) {
140+
campaignState.changeSupportPoints(finalBid);
141+
142+
// The delivery time is so that the unit addition is picked up by the 'mothball'
143+
// campaign option. It also makes sense the unit wouldn't magically materialize in your
144+
// hangar and has to get there.
145+
int deliveryTime = d6();
146+
// The +1 here is to account for this being an end of day event, so we automatically
147+
// eat the first day.
148+
campaign.addNewUnit(entity, false, deliveryTime + 1);
149+
150+
// This dialog informs the player their bid was successful
151+
new ImmersiveDialogSimple(campaign,
152+
campaign.getSeniorAdminPerson(TRANSPORT),
153+
null,
154+
getFormattedTextAt(RESOURCE_BUNDLE, "auction.successful", entity.getChassis(), deliveryTime),
155+
null,
156+
null,
157+
null,
158+
true);
159+
} else {
160+
// This dialog informs the player their bid was unsuccessful
161+
new ImmersiveDialogSimple(campaign,
162+
campaign.getSeniorAdminPerson(TRANSPORT),
163+
null,
164+
getFormattedTextAt(RESOURCE_BUNDLE, "auction.failure", entity.getChassis()),
165+
null,
166+
null,
167+
null,
168+
true);
166169
}
167170
}
168171
}

0 commit comments

Comments
 (0)