Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Discretionary Spending System Based on Wealth Trait #6565

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,11 @@ lblNewFinancialYearFinancesToCSVExportBox.tooltip=This writes the finance table
\ the first day of a new financial term, right before the table is carried over to the next period.
lblSimulateGrayMonday.text=Simulate Gray Monday \u2728
lblSimulateGrayMonday.tooltip=Simulate the economic and social upheaval of Gray Monday.
lblAllowMonthlyReinvestment.text=Allow Monthly Reinvestment of Wealth \u2728
lblAllowMonthlyReinvestment.tooltip=Each month the campaign commander will use their Wealth trait to\
\ reinvest money back into the campaign.\
<br>\
<br>This is based on the Wealth Trait Check rules from the A Time of War:Companion.
# createSalesPanel
lblSalesPanel.text=Sales
lblSellUnitsBox.text=Enable the Sale of Units
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# suppress inspection "UnusedProperty" for the whole file
report.format.monthly={0} has used {1}<b>Wealth {2}</b>{3} to transfer {4} C-Bills into the\
\ unit''s coffers. The funds have cleared and are available for spending.
report.format.extreme={0} has {1}<b>exhausted</b>{2} their Wealth to transfer {3} C-Bills into the unit''s coffers. The\
\ funds have cleared and are available for spending. {4} has <b>{5}</b> Wealth remaining.
report.format.exhausted={0} has already {1}<b>exhausted</b>{2} their Wealth for this month and cannot reinvest into the unit.
finance.format=Transfer from {0}
14 changes: 3 additions & 11 deletions MekHQ/resources/mekhq/resources/Finances.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This is used to store any Finances Resources
## Generic Finances Resources
Error.text=Error

## Finances Enums
# FinancialTerm Enum
FinancialTerm.BIWEEKLY.text=Biweekly
Expand All @@ -14,7 +13,6 @@ FinancialTerm.SEMIANNUALLY.text=Semiannually
FinancialTerm.SEMIANNUALLY.toolTipText=The financial term is once every six months.
FinancialTerm.ANNUALLY.text=Annually
FinancialTerm.ANNUALLY.toolTipText=The financial term is one per year.

# FinancialYearDuration Enum
FinancialYearDuration.SEMIANNUAL.text=Semiannual
FinancialYearDuration.SEMIANNUAL.toolTipText=The financial term lasts six months
Expand All @@ -28,7 +26,6 @@ FinancialYearDuration.DECENNIAL.text=Decennial
FinancialYearDuration.DECENNIAL.toolTipText=The financial term lasts ten years
FinancialYearDuration.FOREVER.text=Forever (Not Recommended)
FinancialYearDuration.FOREVER.toolTipText=The financial term lasts forever. This option is not recommended and can cause issues in lengthy campaigns.

# TransactionType Enum
TransactionType.BATTLE_LOSS_COMPENSATION.text=Battle Loss Compensation
TransactionType.BATTLE_LOSS_COMPENSATION.toolTipText=A financial transaction where battle losses are partially to completely paid back by the employer, as per the current negotiated contract.
Expand Down Expand Up @@ -88,7 +85,8 @@ TransactionType.UNIT_SALE.text=Unit Sale(s)
TransactionType.UNIT_SALE.toolTipText=A financial transaction where a unit was or multiple units were sold.
TransactionType.BONUS_EXCHANGE.text=Bonus Exchange
TransactionType.BONUS_EXCHANGE.toolTipText=A financial transaction where Bonus Parts were exchanged for money.

TransactionType.WEALTH.text=Reinvestment
TransactionType.WEALTH.toolTipText=A financial transaction where the commander reinvested funds back into the unit.
## Finances Files
# Peacetime Operating Costs
PeacetimeCosts.title=Monthly Peacetime Operating Costs
Expand All @@ -99,24 +97,18 @@ PeacetimeCostsAmmunition.title=Monthly Ammunition
PeacetimeCostsAmmunition.text=Your account has been debited %s for training munitions
PeacetimeCostsFuel.title=Monthly Fuel bill
PeacetimeCostsFuel.text=Your account has been debited %s for fuel

# Salaries and other Overhead
Salaries.title=Monthly salaries
Salaries.text=Payday! Your account has been debited for %s in personnel salaries
Overhead.title=Monthly overhead
Overhead.text=Your account has been debited for %s in overhead expenses

# Loans
Loan.title=loan payment to %s
Loan.text=Your account has been debited for %s in loan payment to %s
Loan.insufficient.report=<b>You have insufficient funds to service the debt on loan %s!</b>%s Funds required: %s
Loan.paid.report=You have fully paid off loan %s

# File Export
FinanceExport.format=%s financial transactions written to file.



## Unsorted General Finances
FinancialTermEndCarryover.finances=Carryover from previous financial term
Taxes.finances=Taxes
Expand All @@ -135,4 +127,4 @@ OverheadCosts.text=overhead costs
Shares.text=shares
AssetPayment.finances=Income from %s
AssetPayment.report=Your account has been credited for %s from %s
loyaltyChangeGroup.text=Loyalty has changed across the unit.
loyaltyChangeGroup.text=Loyalty has changed across the unit.
5 changes: 4 additions & 1 deletion MekHQ/resources/mekhq/resources/GUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ spendOnReputation.tooltip=If this character is the campaign commander unit Reput
\ modifies all Negotiation, Protocols, and Streetwise skills by %s.
spendOnWealth.text=Wealth -> %s (%s xp)
spendOnWealth.tooltip=Raising this trait to at least rank 7 will improve unit Reputation by 1 if this character is the\
\ campaign commander.
\ campaign commander. If this character is the campaign commander, they will reinvest funds back into the unit at the\
\ beginning of each month.
spendOnUnlucky.text=Unlucky -> %s (%s xp)
spendOnUnlucky.tooltip=Decreases the character's available Edge by %s.
spendOnAttributes.increase=Increase Attribute Scores
Expand Down Expand Up @@ -197,6 +198,8 @@ addScenarioEntry.text=Add Single Scenario Entry
assignKill.text=Add Single Kill Entry
exportPersonnel.text=Export Personnel
sack.text=Sack
wealth.extreme.single=Perform Extreme Expenditure (+%s C-Bills, -1 Wealth)
wealth.extreme.multiple=Perform Extreme Expenditure (-1 Wealth)
eduEducation.text=Education
eduCivilian.text=Civilian
eduMilitary.text=Military
Expand Down
14 changes: 14 additions & 0 deletions MekHQ/src/mekhq/campaign/Campaign.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import static mekhq.campaign.mission.resupplyAndCaches.Resupply.isProhibitedUnitType;
import static mekhq.campaign.mission.resupplyAndCaches.ResupplyUtilities.processAbandonedConvoy;
import static mekhq.campaign.parts.enums.PartQuality.QUALITY_A;
import static mekhq.campaign.personnel.DiscretionarySpending.performDiscretionarySpending;
import static mekhq.campaign.personnel.backgrounds.BackgroundsController.randomMercenaryCompanyNameGenerator;
import static mekhq.campaign.personnel.education.EducationController.getAcademy;
import static mekhq.campaign.personnel.education.TrainingCombatTeams.processTrainingCombatTeams;
Expand Down Expand Up @@ -4930,6 +4931,19 @@ public void processNewDayPersonnel() {
personnelWhoAdvancedInXP.add(person);
}
}

if (person.isCommander() &&
campaignOptions.isAllowMonthlyReinvestment() &&
!person.isHasPerformedExtremeExpenditure()) {
String reportString = performDiscretionarySpending(person, finances, currentDay);
if (reportString != null) {
addReport(reportString);
} else {
logger.error("Unable to process discretionary spending for {}", person.getFullTitle());
}
}

person.setHasPerformedExtremeExpenditure(false);
}

if (isCommandersDay && !faction.isClan() && (peopleWhoCelebrateCommandersDay < commanderDayTargetNumber)) {
Expand Down
17 changes: 15 additions & 2 deletions MekHQ/src/mekhq/campaign/CampaignOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ public static String getTechLevelName(final int techLevel) {
private FinancialYearDuration financialYearDuration;
private boolean newFinancialYearFinancesToCSVExport;
private boolean simulateGrayMonday;
private boolean allowMonthlyReinvestment;

// Price Multipliers
private double commonPartPriceMultiplier;
Expand Down Expand Up @@ -1068,6 +1069,7 @@ public CampaignOptions() {
setFinancialYearDuration(FinancialYearDuration.ANNUAL);
newFinancialYearFinancesToCSVExport = false;
simulateGrayMonday = false;
allowMonthlyReinvestment = false;

// Price Multipliers
setCommonPartPriceMultiplier(1.0);
Expand Down Expand Up @@ -3382,6 +3384,14 @@ public void setSimulateGrayMonday(final boolean simulateGrayMonday) {
this.simulateGrayMonday = simulateGrayMonday;
}

public boolean isAllowMonthlyReinvestment() {
return allowMonthlyReinvestment;
}

public void setAllowMonthlyReinvestment(final boolean allowMonthlyReinvestment) {
this.allowMonthlyReinvestment = allowMonthlyReinvestment;
}

// region Price Multipliers
public double getCommonPartPriceMultiplier() {
return commonPartPriceMultiplier;
Expand Down Expand Up @@ -5278,6 +5288,7 @@ public void writeToXml(final PrintWriter pw, int indent) {
"newFinancialYearFinancesToCSVExport",
newFinancialYearFinancesToCSVExport);
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "simulateGrayMonday", simulateGrayMonday);
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "allowMonthlyReinvestment", allowMonthlyReinvestment);

// region Price Multipliers
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "commonPartPriceMultiplier", getCommonPartPriceMultiplier());
Expand Down Expand Up @@ -6208,6 +6219,8 @@ public static CampaignOptions generateCampaignOptionsFromXml(Node wn, Version ve
retVal.newFinancialYearFinancesToCSVExport = Boolean.parseBoolean(wn2.getTextContent().trim());
} else if (nodeName.equalsIgnoreCase("simulateGrayMonday")) {
retVal.simulateGrayMonday = Boolean.parseBoolean(wn2.getTextContent().trim());
} else if (nodeName.equalsIgnoreCase("allowMonthlyReinvestment")) {
retVal.allowMonthlyReinvestment = Boolean.parseBoolean(wn2.getTextContent().trim());

// region Price Multipliers
} else if (nodeName.equalsIgnoreCase("commonPartPriceMultiplier")) {
Expand Down Expand Up @@ -6482,8 +6495,8 @@ public static CampaignOptions generateCampaignOptionsFromXml(Node wn, Version ve
retVal.getRandomOriginOptions()
.setExtraRandomOrigin(Boolean.parseBoolean(wn2.getTextContent().trim()));
} else if (nodeName.equalsIgnoreCase("originDistanceScale")) { // Legacy, 0.49.7 Removal
retVal.getRandomOriginOptions()
.setOriginDistanceScale(Double.parseDouble(wn2.getTextContent().trim()));
retVal.getRandomOriginOptions().setOriginDistanceScale(Double.parseDouble(wn2.getTextContent()
.trim()));
} else if (nodeName.equalsIgnoreCase("dependentsNeverLeave")) { // Legacy - 0.49.7 Removal
retVal.setUseRandomDependentRemoval(!Boolean.parseBoolean(wn2.getTextContent().trim()));
} else if (nodeName.equalsIgnoreCase("marriageAgeRange")) { // Legacy - 0.49.6 Removal
Expand Down
17 changes: 12 additions & 5 deletions MekHQ/src/mekhq/campaign/finances/enums/TransactionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
public enum TransactionType {
// region Enum Declarations
BATTLE_LOSS_COMPENSATION("TransactionType.BATTLE_LOSS_COMPENSATION.text",
"TransactionType.BATTLE_LOSS_COMPENSATION.toolTipText"),
"TransactionType.BATTLE_LOSS_COMPENSATION.toolTipText"),
CONSTRUCTION("TransactionType.CONSTRUCTION.text", "TransactionType.CONSTRUCTION.toolTipText"),
CONTRACT_PAYMENT("TransactionType.CONTRACT_PAYMENT.text", "TransactionType.CONTRACT_PAYMENT.toolTipText"),
EDUCATION("TransactionType.EDUCATION.text", "TransactionType.EDUCATION.toolTipText"),
EQUIPMENT_PURCHASE("TransactionType.EQUIPMENT_PURCHASE.text", "TransactionType.EQUIPMENT_PURCHASE.toolTipText"),
EQUIPMENT_SALE("TransactionType.EQUIPMENT_SALE.text", "TransactionType.EQUIPMENT_SALE.toolTipText"),
FINANCIAL_TERM_END_CARRYOVER("TransactionType.FINANCIAL_TERM_END_CARRYOVER.text",
"TransactionType.FINANCIAL_TERM_END_CARRYOVER.toolTipText"),
"TransactionType.FINANCIAL_TERM_END_CARRYOVER.toolTipText"),
FINE("TransactionType.FINE.text", "TransactionType.FINE.toolTipText"),
LOAN_PAYMENT("TransactionType.LOAN_PAYMENT.text", "TransactionType.LOAN_PAYMENT.toolTipText"),
LOAN_PRINCIPAL("TransactionType.LOAN_PRINCIPAL.text", "TransactionType.LOAN_PRINCIPAL.toolTipText"),
Expand All @@ -64,7 +64,8 @@ public enum TransactionType {
TRANSPORTATION("TransactionType.TRANSPORTATION.text", "TransactionType.TRANSPORTATION.toolTipText"),
UNIT_PURCHASE("TransactionType.UNIT_PURCHASE.text", "TransactionType.UNIT_PURCHASE.toolTipText"),
UNIT_SALE("TransactionType.UNIT_SALE.text", "TransactionType.UNIT_SALE.toolTipText"),
BONUS_EXCHANGE("TransactionType.BONUS_EXCHANGE.text", "TransactionType.BONUS_EXCHANGE.toolTipText");
BONUS_EXCHANGE("TransactionType.BONUS_EXCHANGE.text", "TransactionType.BONUS_EXCHANGE.toolTipText"),
WEALTH("TransactionType.WEALTH.text", "TransactionType.WEALTH.toolTipText");
// endregion Enum Declarations

// region Variable Declarations
Expand All @@ -75,7 +76,7 @@ public enum TransactionType {
// region Constructors
TransactionType(final String name, final String toolTipText) {
final ResourceBundle resources = ResourceBundle.getBundle("mekhq.resources.Finances",
MekHQ.getMHQOptions().getLocale());
MekHQ.getMHQOptions().getLocale());
this.name = resources.getString(name);
this.toolTipText = resources.getString(toolTipText);
}
Expand Down Expand Up @@ -203,6 +204,10 @@ public boolean isUnitSale() {
public boolean isBonusExchange() {
return this == BONUS_EXCHANGE;
}

public boolean isWealth() {
return this == WEALTH;
}
// endregion Boolean Comparison Methods

// region File I/O
Expand Down Expand Up @@ -264,6 +269,8 @@ public static TransactionType parseFromString(final String text) {
return TAXES;
case 21:
return BONUS_EXCHANGE;
case 22:
return WEALTH;
default:
break;
}
Expand All @@ -272,7 +279,7 @@ public static TransactionType parseFromString(final String text) {
}

MMLogger.create(TransactionType.class)
.error("Unable to parse " + text + " into a TransactionType. Returning MISCELLANEOUS.");
.error("Unable to parse " + text + " into a TransactionType. Returning MISCELLANEOUS.");
return MISCELLANEOUS;
}
// endregion File I/O
Expand Down
Loading
Loading