Skip to content

Commit 29342db

Browse files
authored
Merge pull request #6565 from IllianiBird/spendingSpree
Added Discretionary Spending System Based on Wealth Trait
2 parents 0879ac7 + 99febee commit 29342db

File tree

11 files changed

+605
-166
lines changed

11 files changed

+605
-166
lines changed

MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties

+5
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,11 @@ lblNewFinancialYearFinancesToCSVExportBox.tooltip=This writes the finance table
12981298
\ the first day of a new financial term, right before the table is carried over to the next period.
12991299
lblSimulateGrayMonday.text=Simulate Gray Monday \u2728
13001300
lblSimulateGrayMonday.tooltip=Simulate the economic and social upheaval of Gray Monday.
1301+
lblAllowMonthlyReinvestment.text=Allow Monthly Reinvestment of Wealth \u2728
1302+
lblAllowMonthlyReinvestment.tooltip=Each month the campaign commander will use their Wealth trait to\
1303+
\ reinvest money back into the campaign.\
1304+
<br>\
1305+
<br>This is based on the Wealth Trait Check rules from the A Time of War:Companion.
13011306
# createSalesPanel
13021307
lblSalesPanel.text=Sales
13031308
lblSellUnitsBox.text=Enable the Sale of Units
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# suppress inspection "UnusedProperty" for the whole file
2+
report.format.monthly={0} has used {1}<b>Wealth {2}</b>{3} to transfer {4} C-Bills into the\
3+
\ unit''s coffers. The funds have cleared and are available for spending.
4+
report.format.extreme={0} has {1}<b>exhausted</b>{2} their Wealth to transfer {3} C-Bills into the unit''s coffers. The\
5+
\ funds have cleared and are available for spending. {4} has <b>{5}</b> Wealth remaining.
6+
report.format.exhausted={0} has already {1}<b>exhausted</b>{2} their Wealth for this month and cannot reinvest into the unit.
7+
finance.format=Transfer from {0}

MekHQ/resources/mekhq/resources/Finances.properties

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# This is used to store any Finances Resources
22
## Generic Finances Resources
33
Error.text=Error
4-
54
## Finances Enums
65
# FinancialTerm Enum
76
FinancialTerm.BIWEEKLY.text=Biweekly
@@ -14,7 +13,6 @@ FinancialTerm.SEMIANNUALLY.text=Semiannually
1413
FinancialTerm.SEMIANNUALLY.toolTipText=The financial term is once every six months.
1514
FinancialTerm.ANNUALLY.text=Annually
1615
FinancialTerm.ANNUALLY.toolTipText=The financial term is one per year.
17-
1816
# FinancialYearDuration Enum
1917
FinancialYearDuration.SEMIANNUAL.text=Semiannual
2018
FinancialYearDuration.SEMIANNUAL.toolTipText=The financial term lasts six months
@@ -28,7 +26,6 @@ FinancialYearDuration.DECENNIAL.text=Decennial
2826
FinancialYearDuration.DECENNIAL.toolTipText=The financial term lasts ten years
2927
FinancialYearDuration.FOREVER.text=Forever (Not Recommended)
3028
FinancialYearDuration.FOREVER.toolTipText=The financial term lasts forever. This option is not recommended and can cause issues in lengthy campaigns.
31-
3229
# TransactionType Enum
3330
TransactionType.BATTLE_LOSS_COMPENSATION.text=Battle Loss Compensation
3431
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.
@@ -88,7 +85,8 @@ TransactionType.UNIT_SALE.text=Unit Sale(s)
8885
TransactionType.UNIT_SALE.toolTipText=A financial transaction where a unit was or multiple units were sold.
8986
TransactionType.BONUS_EXCHANGE.text=Bonus Exchange
9087
TransactionType.BONUS_EXCHANGE.toolTipText=A financial transaction where Bonus Parts were exchanged for money.
91-
88+
TransactionType.WEALTH.text=Reinvestment
89+
TransactionType.WEALTH.toolTipText=A financial transaction where the commander reinvested funds back into the unit.
9290
## Finances Files
9391
# Peacetime Operating Costs
9492
PeacetimeCosts.title=Monthly Peacetime Operating Costs
@@ -99,24 +97,18 @@ PeacetimeCostsAmmunition.title=Monthly Ammunition
9997
PeacetimeCostsAmmunition.text=Your account has been debited %s for training munitions
10098
PeacetimeCostsFuel.title=Monthly Fuel bill
10199
PeacetimeCostsFuel.text=Your account has been debited %s for fuel
102-
103100
# Salaries and other Overhead
104101
Salaries.title=Monthly salaries
105102
Salaries.text=Payday! Your account has been debited for %s in personnel salaries
106103
Overhead.title=Monthly overhead
107104
Overhead.text=Your account has been debited for %s in overhead expenses
108-
109105
# Loans
110106
Loan.title=loan payment to %s
111107
Loan.text=Your account has been debited for %s in loan payment to %s
112108
Loan.insufficient.report=<b>You have insufficient funds to service the debt on loan %s!</b>%s Funds required: %s
113109
Loan.paid.report=You have fully paid off loan %s
114-
115110
# File Export
116111
FinanceExport.format=%s financial transactions written to file.
117-
118-
119-
120112
## Unsorted General Finances
121113
FinancialTermEndCarryover.finances=Carryover from previous financial term
122114
Taxes.finances=Taxes
@@ -135,4 +127,4 @@ OverheadCosts.text=overhead costs
135127
Shares.text=shares
136128
AssetPayment.finances=Income from %s
137129
AssetPayment.report=Your account has been credited for %s from %s
138-
loyaltyChangeGroup.text=Loyalty has changed across the unit.
130+
loyaltyChangeGroup.text=Loyalty has changed across the unit.

MekHQ/resources/mekhq/resources/GUI.properties

+4-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ spendOnReputation.tooltip=If this character is the campaign commander unit Reput
154154
\ modifies all Negotiation, Protocols, and Streetwise skills by %s.
155155
spendOnWealth.text=Wealth -> %s (%s xp)
156156
spendOnWealth.tooltip=Raising this trait to at least rank 7 will improve unit Reputation by 1 if this character is the\
157-
\ campaign commander.
157+
\ campaign commander. If this character is the campaign commander, they will reinvest funds back into the unit at the\
158+
\ beginning of each month.
158159
spendOnUnlucky.text=Unlucky -> %s (%s xp)
159160
spendOnUnlucky.tooltip=Decreases the character's available Edge by %s.
160161
spendOnAttributes.increase=Increase Attribute Scores
@@ -197,6 +198,8 @@ addScenarioEntry.text=Add Single Scenario Entry
197198
assignKill.text=Add Single Kill Entry
198199
exportPersonnel.text=Export Personnel
199200
sack.text=Sack
201+
wealth.extreme.single=Perform Extreme Expenditure (+%s C-Bills, -1 Wealth)
202+
wealth.extreme.multiple=Perform Extreme Expenditure (-1 Wealth)
200203
eduEducation.text=Education
201204
eduCivilian.text=Civilian
202205
eduMilitary.text=Military

MekHQ/src/mekhq/campaign/Campaign.java

+14
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import static mekhq.campaign.mission.resupplyAndCaches.Resupply.isProhibitedUnitType;
4747
import static mekhq.campaign.mission.resupplyAndCaches.ResupplyUtilities.processAbandonedConvoy;
4848
import static mekhq.campaign.parts.enums.PartQuality.QUALITY_A;
49+
import static mekhq.campaign.personnel.DiscretionarySpending.performDiscretionarySpending;
4950
import static mekhq.campaign.personnel.backgrounds.BackgroundsController.randomMercenaryCompanyNameGenerator;
5051
import static mekhq.campaign.personnel.education.EducationController.getAcademy;
5152
import static mekhq.campaign.personnel.education.TrainingCombatTeams.processTrainingCombatTeams;
@@ -4925,6 +4926,19 @@ public void processNewDayPersonnel() {
49254926
personnelWhoAdvancedInXP.add(person);
49264927
}
49274928
}
4929+
4930+
if (person.isCommander() &&
4931+
campaignOptions.isAllowMonthlyReinvestment() &&
4932+
!person.isHasPerformedExtremeExpenditure()) {
4933+
String reportString = performDiscretionarySpending(person, finances, currentDay);
4934+
if (reportString != null) {
4935+
addReport(reportString);
4936+
} else {
4937+
logger.error("Unable to process discretionary spending for {}", person.getFullTitle());
4938+
}
4939+
}
4940+
4941+
person.setHasPerformedExtremeExpenditure(false);
49284942
}
49294943

49304944
if (isCommandersDay && !faction.isClan() && (peopleWhoCelebrateCommandersDay < commanderDayTargetNumber)) {

MekHQ/src/mekhq/campaign/CampaignOptions.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ public static String getTechLevelName(final int techLevel) {
466466
private FinancialYearDuration financialYearDuration;
467467
private boolean newFinancialYearFinancesToCSVExport;
468468
private boolean simulateGrayMonday;
469+
private boolean allowMonthlyReinvestment;
469470

470471
// Price Multipliers
471472
private double commonPartPriceMultiplier;
@@ -1068,6 +1069,7 @@ public CampaignOptions() {
10681069
setFinancialYearDuration(FinancialYearDuration.ANNUAL);
10691070
newFinancialYearFinancesToCSVExport = false;
10701071
simulateGrayMonday = false;
1072+
allowMonthlyReinvestment = false;
10711073

10721074
// Price Multipliers
10731075
setCommonPartPriceMultiplier(1.0);
@@ -3382,6 +3384,14 @@ public void setSimulateGrayMonday(final boolean simulateGrayMonday) {
33823384
this.simulateGrayMonday = simulateGrayMonday;
33833385
}
33843386

3387+
public boolean isAllowMonthlyReinvestment() {
3388+
return allowMonthlyReinvestment;
3389+
}
3390+
3391+
public void setAllowMonthlyReinvestment(final boolean allowMonthlyReinvestment) {
3392+
this.allowMonthlyReinvestment = allowMonthlyReinvestment;
3393+
}
3394+
33853395
// region Price Multipliers
33863396
public double getCommonPartPriceMultiplier() {
33873397
return commonPartPriceMultiplier;
@@ -5278,6 +5288,7 @@ public void writeToXml(final PrintWriter pw, int indent) {
52785288
"newFinancialYearFinancesToCSVExport",
52795289
newFinancialYearFinancesToCSVExport);
52805290
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "simulateGrayMonday", simulateGrayMonday);
5291+
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "allowMonthlyReinvestment", allowMonthlyReinvestment);
52815292

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

62126225
// region Price Multipliers
62136226
} else if (nodeName.equalsIgnoreCase("commonPartPriceMultiplier")) {
@@ -6482,8 +6495,8 @@ public static CampaignOptions generateCampaignOptionsFromXml(Node wn, Version ve
64826495
retVal.getRandomOriginOptions()
64836496
.setExtraRandomOrigin(Boolean.parseBoolean(wn2.getTextContent().trim()));
64846497
} else if (nodeName.equalsIgnoreCase("originDistanceScale")) { // Legacy, 0.49.7 Removal
6485-
retVal.getRandomOriginOptions()
6486-
.setOriginDistanceScale(Double.parseDouble(wn2.getTextContent().trim()));
6498+
retVal.getRandomOriginOptions().setOriginDistanceScale(Double.parseDouble(wn2.getTextContent()
6499+
.trim()));
64876500
} else if (nodeName.equalsIgnoreCase("dependentsNeverLeave")) { // Legacy - 0.49.7 Removal
64886501
retVal.setUseRandomDependentRemoval(!Boolean.parseBoolean(wn2.getTextContent().trim()));
64896502
} else if (nodeName.equalsIgnoreCase("marriageAgeRange")) { // Legacy - 0.49.6 Removal

MekHQ/src/mekhq/campaign/finances/enums/TransactionType.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@
3535
public enum TransactionType {
3636
// region Enum Declarations
3737
BATTLE_LOSS_COMPENSATION("TransactionType.BATTLE_LOSS_COMPENSATION.text",
38-
"TransactionType.BATTLE_LOSS_COMPENSATION.toolTipText"),
38+
"TransactionType.BATTLE_LOSS_COMPENSATION.toolTipText"),
3939
CONSTRUCTION("TransactionType.CONSTRUCTION.text", "TransactionType.CONSTRUCTION.toolTipText"),
4040
CONTRACT_PAYMENT("TransactionType.CONTRACT_PAYMENT.text", "TransactionType.CONTRACT_PAYMENT.toolTipText"),
4141
EDUCATION("TransactionType.EDUCATION.text", "TransactionType.EDUCATION.toolTipText"),
4242
EQUIPMENT_PURCHASE("TransactionType.EQUIPMENT_PURCHASE.text", "TransactionType.EQUIPMENT_PURCHASE.toolTipText"),
4343
EQUIPMENT_SALE("TransactionType.EQUIPMENT_SALE.text", "TransactionType.EQUIPMENT_SALE.toolTipText"),
4444
FINANCIAL_TERM_END_CARRYOVER("TransactionType.FINANCIAL_TERM_END_CARRYOVER.text",
45-
"TransactionType.FINANCIAL_TERM_END_CARRYOVER.toolTipText"),
45+
"TransactionType.FINANCIAL_TERM_END_CARRYOVER.toolTipText"),
4646
FINE("TransactionType.FINE.text", "TransactionType.FINE.toolTipText"),
4747
LOAN_PAYMENT("TransactionType.LOAN_PAYMENT.text", "TransactionType.LOAN_PAYMENT.toolTipText"),
4848
LOAN_PRINCIPAL("TransactionType.LOAN_PRINCIPAL.text", "TransactionType.LOAN_PRINCIPAL.toolTipText"),
@@ -64,7 +64,8 @@ public enum TransactionType {
6464
TRANSPORTATION("TransactionType.TRANSPORTATION.text", "TransactionType.TRANSPORTATION.toolTipText"),
6565
UNIT_PURCHASE("TransactionType.UNIT_PURCHASE.text", "TransactionType.UNIT_PURCHASE.toolTipText"),
6666
UNIT_SALE("TransactionType.UNIT_SALE.text", "TransactionType.UNIT_SALE.toolTipText"),
67-
BONUS_EXCHANGE("TransactionType.BONUS_EXCHANGE.text", "TransactionType.BONUS_EXCHANGE.toolTipText");
67+
BONUS_EXCHANGE("TransactionType.BONUS_EXCHANGE.text", "TransactionType.BONUS_EXCHANGE.toolTipText"),
68+
WEALTH("TransactionType.WEALTH.text", "TransactionType.WEALTH.toolTipText");
6869
// endregion Enum Declarations
6970

7071
// region Variable Declarations
@@ -75,7 +76,7 @@ public enum TransactionType {
7576
// region Constructors
7677
TransactionType(final String name, final String toolTipText) {
7778
final ResourceBundle resources = ResourceBundle.getBundle("mekhq.resources.Finances",
78-
MekHQ.getMHQOptions().getLocale());
79+
MekHQ.getMHQOptions().getLocale());
7980
this.name = resources.getString(name);
8081
this.toolTipText = resources.getString(toolTipText);
8182
}
@@ -203,6 +204,10 @@ public boolean isUnitSale() {
203204
public boolean isBonusExchange() {
204205
return this == BONUS_EXCHANGE;
205206
}
207+
208+
public boolean isWealth() {
209+
return this == WEALTH;
210+
}
206211
// endregion Boolean Comparison Methods
207212

208213
// region File I/O
@@ -264,6 +269,8 @@ public static TransactionType parseFromString(final String text) {
264269
return TAXES;
265270
case 21:
266271
return BONUS_EXCHANGE;
272+
case 22:
273+
return WEALTH;
267274
default:
268275
break;
269276
}
@@ -272,7 +279,7 @@ public static TransactionType parseFromString(final String text) {
272279
}
273280

274281
MMLogger.create(TransactionType.class)
275-
.error("Unable to parse " + text + " into a TransactionType. Returning MISCELLANEOUS.");
282+
.error("Unable to parse " + text + " into a TransactionType. Returning MISCELLANEOUS.");
276283
return MISCELLANEOUS;
277284
}
278285
// endregion File I/O

0 commit comments

Comments
 (0)