Skip to content

Commit

Permalink
Merge pull request #4227 from IllianiCBT/market_descriptionsAndPrice
Browse files Browse the repository at this point in the history
Updated Unit Market Descriptions & Refactored Unit Market Prices
  • Loading branch information
IllianiCBT authored Jun 21, 2024
2 parents 60f82a2 + a5ab83d commit 84b2aa2
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 38 deletions.
5 changes: 3 additions & 2 deletions MekHQ/resources/mekhq/resources/GUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1287,8 +1287,9 @@ chkFilterByPercentageOfCost.text=Show only units at
chkFilterByPercentageOfCost.toolTipText=Filter out units above the specified percentage of market value.
spnFilterByPercentageOfCost.toolTipText=Filter out units with market value above this percentage when the filter is enabled.
lblCostPercentageThreshold.text=% of market value or lower
### Black Market Panel
lblBlackMarketWarning.text=<html><b>Open Market & Mercenary Auction:</b> The public sale of units available to your campaign faction\
### Market Description Panel
lblMarketDescriptions.text=<html><b>Open Market:</b> The public sale of units available to your campaign faction\
<br><b>Mercenary Auction:</b> The sale of unwanted units sold through the MRBC (or the era-appropriate equivalent)\
<br><b>Employer Market:</b> Units or salvage no longer wanted by your employer\
<br><b>Factory Line:</b> Brand-new units fresh off the production line\
<br><b>Black Market:</b> Potentially brand-new units which come with the risk of being swindled</html>
Expand Down
42 changes: 42 additions & 0 deletions MekHQ/src/mekhq/campaign/market/enums/UnitMarketType.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,49 @@ public String toString() {
return name;
}

/**
* Calculates the price percentage based on a given modifier and d6 roll.
*
* @param modifier the modifier to adjust the price (a negative modifier decreases price, positive increases price)
* @return the calculated price
* @throws IllegalStateException if the roll value is unexpected
*/
public static int getPricePercentage(int modifier) {
int roll = Compute.d6(2);
int value;

switch (roll) {
case 2:
value = modifier + 3;
break;
case 3:
value = modifier + 2;
break;
case 4:
case 5:
value = modifier + 1;
break;
case 6:
case 7:
case 8:
value = modifier;
break;
case 9:
case 10:
value = modifier - 1;
break;
case 11:
value = modifier - 2;
break;
case 12:
value = modifier - 3;
break;
default:
throw new IllegalStateException("Unexpected value in mekhq/campaign/market/unitMarket/AtBMonthlyUnitMarket.java/getPrice: " + roll);
}

return 100 + (value * 5);
}

/**
* Returns the quality of a unit based on the given market type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import java.util.Collection;
import java.util.List;

import static mekhq.campaign.market.enums.UnitMarketType.getPricePercentage;

public class AtBMonthlyUnitMarket extends AbstractUnitMarket {
//region Constructors
public AtBMonthlyUnitMarket() {
Expand Down Expand Up @@ -76,70 +78,70 @@ public void generateUnitOffers(final Campaign campaign) {
Faction faction = campaign.getFaction();

addOffers(campaign, getMarketItemCount("uncommon"), UnitMarketType.OPEN, UnitType.MEK,
faction, IUnitRating.DRAGOON_F, 6);
faction, IUnitRating.DRAGOON_F, 1);

addOffers(campaign, getMarketItemCount("uncommon"), UnitMarketType.OPEN, UnitType.AEROSPACEFIGHTER,
faction, IUnitRating.DRAGOON_F, 6);
faction, IUnitRating.DRAGOON_F, 1);

addOffers(campaign, getMarketItemCount("very common"), UnitMarketType.OPEN, UnitType.TANK,
faction, IUnitRating.DRAGOON_F, 6);
faction, IUnitRating.DRAGOON_F, 1);

addOffers(campaign, getMarketItemCount("common"), UnitMarketType.OPEN, UnitType.CONV_FIGHTER,
faction, IUnitRating.DRAGOON_F, 6);
faction, IUnitRating.DRAGOON_F, 1);

if ((contract != null) && (campaign.getLocalDate().isAfter(contract.getStartDate().minusDays(1)))) {
// Employer Market
faction = contract.getEmployerFaction();

addOffers(campaign, getMarketItemCount("rare"), UnitMarketType.EMPLOYER, UnitType.MEK,
faction, IUnitRating.DRAGOON_D, 8);
faction, IUnitRating.DRAGOON_D, -1);

addOffers(campaign, getMarketItemCount("rare"), UnitMarketType.EMPLOYER, UnitType.AEROSPACEFIGHTER,
faction, IUnitRating.DRAGOON_D, 8);
faction, IUnitRating.DRAGOON_D, -1);

addOffers(campaign, getMarketItemCount("common"), UnitMarketType.EMPLOYER, UnitType.TANK,
faction, IUnitRating.DRAGOON_D, 8);
faction, IUnitRating.DRAGOON_D, -1);

addOffers(campaign, getMarketItemCount("uncommon"), UnitMarketType.EMPLOYER, UnitType.CONV_FIGHTER,
faction, IUnitRating.DRAGOON_D, 8);
faction, IUnitRating.DRAGOON_D, -1);

// Unwanted Salvage Market
faction = contract.getEnemy();

addOffers(campaign, getMarketItemCount("rare"), UnitMarketType.EMPLOYER, UnitType.MEK,
faction, IUnitRating.DRAGOON_F, 5);
faction, IUnitRating.DRAGOON_F, 2);

addOffers(campaign, getMarketItemCount("rare"), UnitMarketType.EMPLOYER, UnitType.AEROSPACEFIGHTER,
faction, IUnitRating.DRAGOON_F, 5);
faction, IUnitRating.DRAGOON_F, 2);

addOffers(campaign, getMarketItemCount("common"), UnitMarketType.EMPLOYER, UnitType.TANK,
faction, IUnitRating.DRAGOON_F, 5);
faction, IUnitRating.DRAGOON_F, 2);

addOffers(campaign, getMarketItemCount("uncommon"), UnitMarketType.EMPLOYER, UnitType.CONV_FIGHTER,
faction, IUnitRating.DRAGOON_F, 5);
faction, IUnitRating.DRAGOON_F, 2);
}

// Mercenary Market
if (!campaign.getFaction().isClan()) {
faction = Factions.getInstance().getFaction("MERC");

int modifier = -1;
int modifier = 1;

if (campaign.getFaction().isMercenary()) {
modifier = 1;
modifier = -1;
}

addOffers(campaign, getMarketItemCount("uncommon"), UnitMarketType.MERCENARY, UnitType.MEK,
faction, IUnitRating.DRAGOON_C, 7 + modifier);
faction, IUnitRating.DRAGOON_C, modifier);

addOffers(campaign, getMarketItemCount("uncommon"), UnitMarketType.MERCENARY, UnitType.AEROSPACEFIGHTER,
faction, IUnitRating.DRAGOON_C, 7 + modifier);
faction, IUnitRating.DRAGOON_C, modifier);

addOffers(campaign, getMarketItemCount("very common"), UnitMarketType.MERCENARY, UnitType.TANK,
faction, IUnitRating.DRAGOON_C, 7 + modifier);
faction, IUnitRating.DRAGOON_C, modifier);

addOffers(campaign, getMarketItemCount("common"), UnitMarketType.MERCENARY, UnitType.CONV_FIGHTER,
faction, IUnitRating.DRAGOON_C, 7 + modifier);
faction, IUnitRating.DRAGOON_C, modifier);
}

// Factory Market
Expand All @@ -149,16 +151,16 @@ public void generateUnitOffers(final Campaign campaign) {

if ((!campaign.getFaction().isClan()) && (faction != null) && (!faction.isClan())) {
addOffers(campaign, getMarketItemCount("rare"), UnitMarketType.FACTORY, UnitType.MEK,
faction, IUnitRating.DRAGOON_A, 6);
faction, IUnitRating.DRAGOON_A, 2);

addOffers(campaign, getMarketItemCount("rare"), UnitMarketType.FACTORY, UnitType.AEROSPACEFIGHTER,
faction, IUnitRating.DRAGOON_A, 6);
faction, IUnitRating.DRAGOON_A, 2);

addOffers(campaign, getMarketItemCount("common"), UnitMarketType.FACTORY, UnitType.TANK,
faction, IUnitRating.DRAGOON_A, 6);
faction, IUnitRating.DRAGOON_A, 2);

addOffers(campaign, getMarketItemCount("uncommon"), UnitMarketType.FACTORY, UnitType.CONV_FIGHTER,
faction, IUnitRating.DRAGOON_A, 6);
faction, IUnitRating.DRAGOON_A, 2);
}
}

Expand All @@ -167,13 +169,13 @@ public void generateUnitOffers(final Campaign campaign) {
// Clan Factory Market
if ((faction.isClan()) && (campaign.getCurrentSystem().getFactionSet(campaign.getLocalDate()).contains(faction))) {
addOffers(campaign, getMarketItemCount("very common"), UnitMarketType.FACTORY, UnitType.MEK,
faction, IUnitRating.DRAGOON_A, 9);
faction, IUnitRating.DRAGOON_A, -4);

addOffers(campaign, getMarketItemCount("common"), UnitMarketType.FACTORY, UnitType.AEROSPACEFIGHTER,
faction, IUnitRating.DRAGOON_A, 9);
faction, IUnitRating.DRAGOON_A, -4);

addOffers(campaign, getMarketItemCount("uncommon"), UnitMarketType.FACTORY, UnitType.TANK,
faction, IUnitRating.DRAGOON_A, 9);
faction, IUnitRating.DRAGOON_A, -4);
}

// Black Market
Expand All @@ -182,16 +184,16 @@ public void generateUnitOffers(final Campaign campaign) {
.getFactionSet(campaign.getLocalDate()));

addOffers(campaign, getMarketItemCount("very rare"), UnitMarketType.BLACK_MARKET, UnitType.MEK,
faction, IUnitRating.DRAGOON_A, 9);
faction, IUnitRating.DRAGOON_A, -8);

addOffers(campaign, getMarketItemCount("very rare"), UnitMarketType.BLACK_MARKET, UnitType.AEROSPACEFIGHTER,
faction, IUnitRating.DRAGOON_A, 9);
faction, IUnitRating.DRAGOON_A, -8);

addOffers(campaign, getMarketItemCount("uncommon"), UnitMarketType.BLACK_MARKET, UnitType.TANK,
faction, IUnitRating.DRAGOON_A, 9);
addOffers(campaign, getMarketItemCount("rare"), UnitMarketType.BLACK_MARKET, UnitType.TANK,
faction, IUnitRating.DRAGOON_A, -8);

addOffers(campaign, getMarketItemCount("rare"), UnitMarketType.BLACK_MARKET, UnitType.CONV_FIGHTER,
faction, IUnitRating.DRAGOON_A, 9);
faction, IUnitRating.DRAGOON_A, -8);
}

writeRefreshReport(campaign);
Expand Down Expand Up @@ -224,7 +226,7 @@ private int getMarketItemCount(String rarity) {
@Override
public void addOffers(final Campaign campaign, final int num, UnitMarketType market,
final int unitType, @Nullable Faction faction, final int quality,
final int priceTarget) {
final int priceModifier) {
if (faction == null) {
faction = RandomFactionGenerator.getInstance().getEmployerFaction();
}
Expand Down Expand Up @@ -268,8 +270,7 @@ public void addOffers(final Campaign campaign, final int num, UnitMarketType mar
}
}

final int percent = 100 - (Compute.d6(2) - priceTarget) * 5;
addSingleUnit(campaign, market, unitType, faction, quality, movementModes, missionRoles, percent);
addSingleUnit(campaign, market, unitType, faction, quality, movementModes, missionRoles, getPricePercentage(priceModifier));
}
}

Expand Down
6 changes: 3 additions & 3 deletions MekHQ/src/mekhq/gui/panes/UnitMarketPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ protected Component createLeftComponent() {

final JScrollPane marketTableScrollPane = createMarketTablePane();

final JLabel lblBlackMarketWarning = new JLabel(resources.getString("lblBlackMarketWarning.text"));
final JLabel lblMarketDescriptions = new JLabel(resources.getString("lblMarketDescriptions.text"));

// Layout the UI
JPanel panel = new JPanel();
Expand All @@ -215,7 +215,7 @@ protected Component createLeftComponent() {
.addComponent(filtersPanel)
.addComponent(getEntityImagePanel(), Alignment.LEADING))
.addComponent(marketTableScrollPane)
.addComponent(lblBlackMarketWarning)
.addComponent(lblMarketDescriptions)
);

layout.setHorizontalGroup(
Expand All @@ -224,7 +224,7 @@ protected Component createLeftComponent() {
.addComponent(filtersPanel)
.addComponent(getEntityImagePanel()))
.addComponent(marketTableScrollPane)
.addComponent(lblBlackMarketWarning, Alignment.TRAILING)
.addComponent(lblMarketDescriptions, Alignment.TRAILING)
);
return panel;
}
Expand Down

0 comments on commit 84b2aa2

Please sign in to comment.