From 93081e17b1d13ced9b7ad7c28ca73bb99448828c Mon Sep 17 00:00:00 2001
From: IllianiCBT
Date: Wed, 25 Sep 2024 12:33:51 -0500
Subject: [PATCH 1/4] Fixed Birthday Anniversary Events
Fixed birthday anniversary events to actually declare when a character has a birthday (previously we were incorrectly only checking whether today's date matched the characters literal date of birth, whoops).
Renamed `p` to `person` in the `processNewDayPersonnel` method to improve code readability.
Added detailed Javadoc comments to explain the daily tasks performed on each active person for better maintenance and understanding.
---
.../mekhq/resources/Campaign.properties | 2 +-
MekHQ/src/mekhq/campaign/Campaign.java | 194 ++++++++++--------
2 files changed, 104 insertions(+), 92 deletions(-)
diff --git a/MekHQ/resources/mekhq/resources/Campaign.properties b/MekHQ/resources/mekhq/resources/Campaign.properties
index 4f99d2dde7..5f6a19f483 100644
--- a/MekHQ/resources/mekhq/resources/Campaign.properties
+++ b/MekHQ/resources/mekhq/resources/Campaign.properties
@@ -39,7 +39,7 @@ LayeredForceIconLayer.LOGO.text=Logos
LayeredForceIconLayer.LOGO.toolTipText=This tab contains canon faction logos that can be added to the center of a force icon.
#### Anniversaries
-anniversaryBirthday.text=%s is %s today!
+anniversaryBirthday.text=%s is %s%s%s today!
#### Personnel Removal
personnelRemoval.text=Old personnel records have been tidied away.
diff --git a/MekHQ/src/mekhq/campaign/Campaign.java b/MekHQ/src/mekhq/campaign/Campaign.java
index 12116d680e..db3ab9d0a3 100644
--- a/MekHQ/src/mekhq/campaign/Campaign.java
+++ b/MekHQ/src/mekhq/campaign/Campaign.java
@@ -21,23 +21,6 @@
*/
package mekhq.campaign;
-import static mekhq.campaign.personnel.backgrounds.BackgroundsController.randomMercenaryCompanyNameGenerator;
-import static mekhq.campaign.personnel.education.EducationController.getAcademy;
-import static mekhq.campaign.personnel.turnoverAndRetention.RetirementDefectionTracker.Payout.isBreakingContract;
-import static mekhq.campaign.unit.Unit.SITE_FACILITY_MAINTENANCE;
-
-import java.io.PrintWriter;
-import java.text.MessageFormat;
-import java.time.DayOfWeek;
-import java.time.LocalDate;
-import java.time.Month;
-import java.time.temporal.ChronoUnit;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
-import javax.swing.JOptionPane;
-
import megamek.client.generator.RandomGenderGenerator;
import megamek.client.generator.RandomNameGenerator;
import megamek.client.generator.RandomUnitGenerator;
@@ -54,11 +37,7 @@
import megamek.common.loaders.BLKFile;
import megamek.common.loaders.EntityLoadingException;
import megamek.common.loaders.EntitySavingException;
-import megamek.common.options.GameOptions;
-import megamek.common.options.IBasicOption;
-import megamek.common.options.IOption;
-import megamek.common.options.IOptionGroup;
-import megamek.common.options.OptionsConstants;
+import megamek.common.options.*;
import megamek.common.util.BuildingBlock;
import megamek.common.weapons.autocannons.ACWeapon;
import megamek.common.weapons.flamers.FlamerWeapon;
@@ -71,11 +50,7 @@
import mekhq.campaign.Quartermaster.PartAcquisitionResult;
import mekhq.campaign.againstTheBot.AtBConfiguration;
import mekhq.campaign.event.*;
-import mekhq.campaign.finances.Accountant;
-import mekhq.campaign.finances.CurrencyManager;
-import mekhq.campaign.finances.Finances;
-import mekhq.campaign.finances.Loan;
-import mekhq.campaign.finances.Money;
+import mekhq.campaign.finances.*;
import mekhq.campaign.finances.enums.TransactionType;
import mekhq.campaign.force.Force;
import mekhq.campaign.force.Lance;
@@ -90,12 +65,7 @@
import mekhq.campaign.market.ShoppingList;
import mekhq.campaign.market.unitMarket.AbstractUnitMarket;
import mekhq.campaign.market.unitMarket.DisabledUnitMarket;
-import mekhq.campaign.mission.AtBContract;
-import mekhq.campaign.mission.AtBDynamicScenario;
-import mekhq.campaign.mission.AtBScenario;
-import mekhq.campaign.mission.Contract;
-import mekhq.campaign.mission.Mission;
-import mekhq.campaign.mission.Scenario;
+import mekhq.campaign.mission.*;
import mekhq.campaign.mission.atb.AtBScenarioFactory;
import mekhq.campaign.mission.enums.AtBLanceRole;
import mekhq.campaign.mission.enums.MissionStatus;
@@ -105,12 +75,7 @@
import mekhq.campaign.parts.equipment.AmmoBin;
import mekhq.campaign.parts.equipment.EquipmentPart;
import mekhq.campaign.parts.equipment.MissingEquipmentPart;
-import mekhq.campaign.personnel.Bloodname;
-import mekhq.campaign.personnel.Person;
-import mekhq.campaign.personnel.PersonnelOptions;
-import mekhq.campaign.personnel.Skill;
-import mekhq.campaign.personnel.SkillType;
-import mekhq.campaign.personnel.SpecialAbility;
+import mekhq.campaign.personnel.*;
import mekhq.campaign.personnel.autoAwards.AutoAwardsController;
import mekhq.campaign.personnel.death.AbstractDeath;
import mekhq.campaign.personnel.death.DisabledRandomDeath;
@@ -118,12 +83,7 @@
import mekhq.campaign.personnel.divorce.DisabledRandomDivorce;
import mekhq.campaign.personnel.education.Academy;
import mekhq.campaign.personnel.education.EducationController;
-import mekhq.campaign.personnel.enums.FamilialRelationshipType;
-import mekhq.campaign.personnel.enums.PersonnelRole;
-import mekhq.campaign.personnel.enums.PersonnelStatus;
-import mekhq.campaign.personnel.enums.Phenotype;
-import mekhq.campaign.personnel.enums.PrisonerStatus;
-import mekhq.campaign.personnel.enums.SplittingSurnameStyle;
+import mekhq.campaign.personnel.enums.*;
import mekhq.campaign.personnel.generator.AbstractPersonnelGenerator;
import mekhq.campaign.personnel.generator.DefaultPersonnelGenerator;
import mekhq.campaign.personnel.generator.RandomPortraitGenerator;
@@ -136,21 +96,16 @@
import mekhq.campaign.personnel.ranks.Ranks;
import mekhq.campaign.personnel.turnoverAndRetention.Fatigue;
import mekhq.campaign.personnel.turnoverAndRetention.RetirementDefectionTracker;
+import mekhq.campaign.rating.CamOpsReputation.ReputationController;
import mekhq.campaign.rating.FieldManualMercRevDragoonsRating;
import mekhq.campaign.rating.IUnitRating;
import mekhq.campaign.rating.UnitRatingMethod;
-import mekhq.campaign.rating.CamOpsReputation.ReputationController;
import mekhq.campaign.storyarc.StoryArc;
import mekhq.campaign.stratcon.StratconContractInitializer;
import mekhq.campaign.stratcon.StratconRulesManager;
import mekhq.campaign.stratcon.StratconTrackState;
-import mekhq.campaign.unit.CargoStatistics;
import mekhq.campaign.unit.CrewType;
-import mekhq.campaign.unit.HangarStatistics;
-import mekhq.campaign.unit.TestUnit;
-import mekhq.campaign.unit.Unit;
-import mekhq.campaign.unit.UnitOrder;
-import mekhq.campaign.unit.UnitTechProgression;
+import mekhq.campaign.unit.*;
import mekhq.campaign.universe.*;
import mekhq.campaign.universe.Planet.PlanetaryEvent;
import mekhq.campaign.universe.PlanetarySystem.PlanetarySystemEvent;
@@ -170,6 +125,25 @@
import mekhq.service.IAutosaveService;
import mekhq.service.mrms.MRMSService;
import mekhq.utilities.MHQXMLUtility;
+import mekhq.utilities.ReportingUtilities;
+
+import javax.swing.*;
+import java.io.PrintWriter;
+import java.text.MessageFormat;
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.time.Month;
+import java.time.Year;
+import java.time.temporal.ChronoUnit;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+
+import static mekhq.campaign.personnel.backgrounds.BackgroundsController.randomMercenaryCompanyNameGenerator;
+import static mekhq.campaign.personnel.education.EducationController.getAcademy;
+import static mekhq.campaign.personnel.turnoverAndRetention.RetirementDefectionTracker.Payout.isBreakingContract;
+import static mekhq.campaign.unit.Unit.SITE_FACILITY_MAINTENANCE;
+import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG;
/**
* The main campaign class, keeps track of teams and units
@@ -3618,33 +3592,64 @@ && getCampaignOptions().getRandomDependentMethod().isAgainstTheBot()
processNewDayATBScenarios();
}
+ /**
+ * Processes the new day for all active personnel.
+ *
+ * This method loops through all active personnel and performs the necessary actions
+ * for each person for a new day.
+ *
+ *
+ * The following tasks are performed for each person:
+ *
+ * - Death - If the person has died, skip processing further for the dead person.
+ * - Marriage - Process any marriage-related actions.
+ * - Reset minutes left for the person.
+ * - Reset acquisitions made to 0.
+ * - Healing - If the person needs healing and advanced medical is not used,
+ * decrement the days to wait for healing and heal naturally or with a doctor.
+ * - Advanced Medical - If advanced medical is used, resolve the daily healing for the person.
+ * - Reset current edge points for support personnel on Mondays.
+ * - Idle XP - If idle XP is enabled and it's the first day of the month,
+ * check if the person qualifies for idle XP and award them if they do.
+ * - Divorce - Process any divorce-related actions.
+ * - Procreation - Process any procreation-related actions.
+ * - Anniversaries - Check if it's the person's birthday or 18th birthday
+ * and announce it if needed.
+ * - Auto Awards - If it's the first day of the month, calculate the auto award
+ * support points based on the person's roles and experience level.
+ *
+ *
+ *
+ * Note: This method uses several other methods to perform the specific actions for each task.
+ *
+ */
public void processNewDayPersonnel() {
// This MUST use getActivePersonnel as we only want to process active personnel,
// and
// furthermore, this allows us to add and remove personnel without issue
- for (Person p : getActivePersonnel()) {
+ for (Person person : getActivePersonnel()) {
// Death
- if (getDeath().processNewDay(this, getLocalDate(), p)) {
+ if (getDeath().processNewDay(this, getLocalDate(), person)) {
// The person has died, so don't continue to process the dead
continue;
}
// Marriage
- getMarriage().processNewDay(this, getLocalDate(), p);
+ getMarriage().processNewDay(this, getLocalDate(), person);
- p.resetMinutesLeft();
+ person.resetMinutesLeft();
// Reset acquisitions made to 0
- p.setAcquisition(0);
- if (p.needsFixing() && !getCampaignOptions().isUseAdvancedMedical()) {
- p.decrementDaysToWaitForHealing();
- Person doctor = getPerson(p.getDoctorId());
+ person.setAcquisition(0);
+ if (person.needsFixing() && !getCampaignOptions().isUseAdvancedMedical()) {
+ person.decrementDaysToWaitForHealing();
+ Person doctor = getPerson(person.getDoctorId());
if ((doctor != null) && doctor.isDoctor()) {
- if (p.getDaysToWaitForHealing() <= 0) {
- addReport(healPerson(p, doctor));
+ if (person.getDaysToWaitForHealing() <= 0) {
+ addReport(healPerson(person, doctor));
}
- } else if (p.checkNaturalHealing(15)) {
- addReport(p.getHyperlinkedFullTitle() + " heals naturally!");
- Unit u = p.getUnit();
+ } else if (person.checkNaturalHealing(15)) {
+ addReport(person.getHyperlinkedFullTitle() + " heals naturally!");
+ Unit u = person.getUnit();
if (u != null) {
u.resetPilotAndEntity();
}
@@ -3652,8 +3657,8 @@ public void processNewDayPersonnel() {
}
// TODO Advanced Medical needs to go away from here later on
if (getCampaignOptions().isUseAdvancedMedical()) {
- InjuryUtil.resolveDailyHealing(this, p);
- Unit u = p.getUnit();
+ InjuryUtil.resolveDailyHealing(this, person);
+ Unit u = person.getUnit();
if (u != null) {
u.resetPilotAndEntity();
}
@@ -3664,43 +3669,50 @@ public void processNewDayPersonnel() {
// TODO : p.isEngineer will need to stay, however
// Reset edge points to the purchased value each week. This should only
// apply for support personnel - combat troops reset with each new mm game
- if ((p.isAdministrator() || p.isDoctor() || p.isEngineer() || p.isTech())
+ if ((person.isAdministrator() || person.isDoctor() || person.isEngineer() || person.isTech())
&& (getLocalDate().getDayOfWeek() == DayOfWeek.MONDAY)) {
- p.resetCurrentEdge();
+ person.resetCurrentEdge();
}
if ((getCampaignOptions().getIdleXP() > 0) && (getLocalDate().getDayOfMonth() == 1)
- && !p.getPrisonerStatus().isCurrentPrisoner()) { // Prisoners can't gain XP, while Bondsmen can gain
+ && !person.getPrisonerStatus().isCurrentPrisoner()) { // Prisoners can't gain XP, while Bondsmen can gain
// xp
- p.setIdleMonths(p.getIdleMonths() + 1);
- if (p.getIdleMonths() >= getCampaignOptions().getMonthsIdleXP()) {
+ person.setIdleMonths(person.getIdleMonths() + 1);
+ if (person.getIdleMonths() >= getCampaignOptions().getMonthsIdleXP()) {
if (Compute.d6(2) >= getCampaignOptions().getTargetIdleXP()) {
- p.awardXP(this, getCampaignOptions().getIdleXP());
- addReport(p.getHyperlinkedFullTitle() + " has gained "
+ person.awardXP(this, getCampaignOptions().getIdleXP());
+ addReport(person.getHyperlinkedFullTitle() + " has gained "
+ getCampaignOptions().getIdleXP() + " XP");
}
- p.setIdleMonths(0);
+ person.setIdleMonths(0);
}
}
// Divorce
- getDivorce().processNewDay(this, getLocalDate(), p);
+ getDivorce().processNewDay(this, getLocalDate(), person);
// Procreation
- getProcreation().processNewDay(this, getLocalDate(), p);
+ getProcreation().processNewDay(this, getLocalDate(), person);
// Anniversaries
- if ((p.getRank().isOfficer()) || (!getCampaignOptions().isAnnounceOfficersOnly())) {
- if ((p.getBirthday().isEqual(getLocalDate())) && (campaignOptions.isAnnounceBirthdays())) {
+ LocalDate birthday = person.getBirthday();
+ birthday = birthday.withYear(Year.now().getValue());
+
+ if ((person.getRank().isOfficer()) || (!getCampaignOptions().isAnnounceOfficersOnly())) {
+ if ((birthday.isEqual(getLocalDate())) && (campaignOptions.isAnnounceBirthdays())) {
addReport(String.format(resources.getString("anniversaryBirthday.text"),
- p.getHyperlinkedFullTitle(),
- p.getAge(getLocalDate())));
+ person.getHyperlinkedFullTitle(),
+ ReportingUtilities.spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorPositiveHexColor()),
+ person.getAge(getLocalDate()),
+ CLOSING_SPAN_TAG));
}
- } else if ((p.getAge(getLocalDate()) == 18) && (campaignOptions.isAnnounceChildBirthdays())) {
- if (p.getBirthday().isEqual(getLocalDate())) {
+ } else if ((person.getAge(getLocalDate()) == 18) && (campaignOptions.isAnnounceChildBirthdays())) {
+ if (birthday.isEqual(getLocalDate())) {
addReport(String.format(resources.getString("anniversaryBirthday.text"),
- p.getHyperlinkedFullTitle(),
- 18));
+ person.getHyperlinkedFullTitle(),
+ ReportingUtilities.spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorPositiveHexColor()),
+ person.getAge(getLocalDate()),
+ CLOSING_SPAN_TAG));
}
}
@@ -3710,8 +3722,8 @@ public void processNewDayPersonnel() {
int score = 0;
- if (p.getPrimaryRole().isSupport(true)) {
- int dice = p.getExperienceLevel(this, false);
+ if (person.getPrimaryRole().isSupport(true)) {
+ int dice = person.getExperienceLevel(this, false);
if (dice > 0) {
score = Compute.d6(dice);
@@ -3720,19 +3732,19 @@ public void processNewDayPersonnel() {
multiplier += 0.5;
}
- if (p.getSecondaryRole().isSupport(true)) {
- int dice = p.getExperienceLevel(this, true);
+ if (person.getSecondaryRole().isSupport(true)) {
+ int dice = person.getExperienceLevel(this, true);
if (dice > 0) {
score += Compute.d6(dice);
}
multiplier += 0.5;
- } else if (p.getSecondaryRole().isNone()) {
+ } else if (person.getSecondaryRole().isNone()) {
multiplier += 0.5;
}
- p.changeAutoAwardSupportPoints((int) (score * multiplier));
+ person.changeAutoAwardSupportPoints((int) (score * multiplier));
}
}
}
From ac7b17995f658925194e40680c7cc0896ae7c408 Mon Sep 17 00:00:00 2001
From: IllianiCBT
Date: Wed, 25 Sep 2024 13:15:33 -0500
Subject: [PATCH 2/4] Add recruitment anniversary tracking and updates
Introduced recruitment anniversary notifications and related configurations. Updated methods to use `getDateOfBirth` for birthday data extraction to enhance clarity.
---
.../mekhq/resources/Campaign.properties | 1 +
.../CampaignOptionsDialog.properties | 4 +-
MekHQ/src/mekhq/campaign/Campaign.java | 26 ++++---
MekHQ/src/mekhq/campaign/CampaignOptions.java | 41 ++++++++---
.../src/mekhq/campaign/MercRosterAccess.java | 32 ++++-----
.../src/mekhq/campaign/personnel/Person.java | 60 ++++++++--------
.../gui/dialog/CreateCharacterDialog.java | 8 +--
.../gui/dialog/CustomizePersonDialog.java | 50 ++++---------
MekHQ/src/mekhq/gui/dialog/GMToolsDialog.java | 52 +++++---------
.../mekhq/gui/dialog/MedicalViewDialog.java | 52 +++++++-------
.../gui/enums/PersonnelTableModelColumn.java | 28 +++-----
.../mekhq/gui/panes/CampaignOptionsPane.java | 70 +++++++++----------
12 files changed, 192 insertions(+), 232 deletions(-)
diff --git a/MekHQ/resources/mekhq/resources/Campaign.properties b/MekHQ/resources/mekhq/resources/Campaign.properties
index 5f6a19f483..b411a3f0d7 100644
--- a/MekHQ/resources/mekhq/resources/Campaign.properties
+++ b/MekHQ/resources/mekhq/resources/Campaign.properties
@@ -40,6 +40,7 @@ LayeredForceIconLayer.LOGO.toolTipText=This tab contains canon faction logos tha
#### Anniversaries
anniversaryBirthday.text=%s is %s%s%s today!
+anniversaryRecruitment.text=%s celebrates %s%s%s years with %s!
#### Personnel Removal
personnelRemoval.text=Old personnel records have been tidied away.
diff --git a/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties
index 2cd8013647..7899b0a552 100644
--- a/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties
+++ b/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties
@@ -364,8 +364,10 @@ chkUseRemovalExemptRetirees.toolTipText=Data from retired personnel is exempt fr
anniversaryPanel.title=Anniversaries
chkAnnounceBirthdays.text=Announce Birthdays
chkAnnounceBirthdays.toolTipText=A daily report notification will occur whenever someone celebrates their birthday.
+chkAnnounceRecruitmentAnniversaries.text=Announce Recruitment Anniversaries
+chkAnnounceRecruitmentAnniversaries.toolTipText=A daily report notification will occur whenever someone celebrates a recruitment anniversary.
chkAnnounceOfficersOnly.text=Officers Only
-chkAnnounceOfficersOnly.toolTipText=Only report officer birthdays.
+chkAnnounceOfficersOnly.toolTipText=Only report officer anniversaries.
chkAnnounceChildBirthdays.text=Coming of Age Override
chkAnnounceChildBirthdays.toolTipText=If enabled, 18th birthdays will always be announced. Enabling this option will override any other settings.
diff --git a/MekHQ/src/mekhq/campaign/Campaign.java b/MekHQ/src/mekhq/campaign/Campaign.java
index db3ab9d0a3..cf42f2d61f 100644
--- a/MekHQ/src/mekhq/campaign/Campaign.java
+++ b/MekHQ/src/mekhq/campaign/Campaign.java
@@ -133,7 +133,6 @@
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;
-import java.time.Year;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.Map.Entry;
@@ -3597,7 +3596,6 @@ && getCampaignOptions().getRandomDependentMethod().isAgainstTheBot()
*
* This method loops through all active personnel and performs the necessary actions
* for each person for a new day.
- *
*
* The following tasks are performed for each person:
*
@@ -3618,10 +3616,8 @@ && getCampaignOptions().getRandomDependentMethod().isAgainstTheBot()
* - Auto Awards - If it's the first day of the month, calculate the auto award
* support points based on the person's roles and experience level.
*
- *
*
* Note: This method uses several other methods to perform the specific actions for each task.
- *
*/
public void processNewDayPersonnel() {
// This MUST use getActivePersonnel as we only want to process active personnel,
@@ -3695,19 +3691,31 @@ public void processNewDayPersonnel() {
getProcreation().processNewDay(this, getLocalDate(), person);
// Anniversaries
- LocalDate birthday = person.getBirthday();
- birthday = birthday.withYear(Year.now().getValue());
-
if ((person.getRank().isOfficer()) || (!getCampaignOptions().isAnnounceOfficersOnly())) {
- if ((birthday.isEqual(getLocalDate())) && (campaignOptions.isAnnounceBirthdays())) {
+ if ((person.getBirthday(getGameYear()).isEqual(getLocalDate()))
+ && (campaignOptions.isAnnounceBirthdays())) {
addReport(String.format(resources.getString("anniversaryBirthday.text"),
person.getHyperlinkedFullTitle(),
ReportingUtilities.spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorPositiveHexColor()),
person.getAge(getLocalDate()),
CLOSING_SPAN_TAG));
}
+
+ LocalDate recruitmentDate = person.getRecruitment();
+ if (recruitmentDate != null) {
+ LocalDate recruitmentAnniversary = recruitmentDate.withYear(getGameYear());
+ int yearsOfEmployment = (int) ChronoUnit.YEARS.between(recruitmentDate, currentDay);
+
+ if ((recruitmentAnniversary.isEqual(getLocalDate()))
+ && (campaignOptions.isAnnounceRecruitmentAnniversaries())) {
+ addReport(String.format(resources.getString("anniversaryRecruitment.text"),
+ person.getHyperlinkedFullTitle(),
+ ReportingUtilities.spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorPositiveHexColor()),
+ yearsOfEmployment, CLOSING_SPAN_TAG, name));
+ }
+ }
} else if ((person.getAge(getLocalDate()) == 18) && (campaignOptions.isAnnounceChildBirthdays())) {
- if (birthday.isEqual(getLocalDate())) {
+ if (person.getBirthday(getGameYear()).isEqual(getLocalDate())) {
addReport(String.format(resources.getString("anniversaryBirthday.text"),
person.getHyperlinkedFullTitle(),
ReportingUtilities.spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorPositiveHexColor()),
diff --git a/MekHQ/src/mekhq/campaign/CampaignOptions.java b/MekHQ/src/mekhq/campaign/CampaignOptions.java
index 7dcb4f182a..e3e90e941d 100644
--- a/MekHQ/src/mekhq/campaign/CampaignOptions.java
+++ b/MekHQ/src/mekhq/campaign/CampaignOptions.java
@@ -19,17 +19,6 @@
*/
package mekhq.campaign;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
import megamek.Version;
import megamek.codeUtilities.MathUtility;
import megamek.common.EquipmentType;
@@ -49,6 +38,12 @@
import mekhq.campaign.rating.UnitRatingMethod;
import mekhq.service.mrms.MRMSOption;
import mekhq.utilities.MHQXMLUtility;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.PrintWriter;
+import java.util.*;
+import java.util.Map.Entry;
/**
* @author natit
@@ -340,6 +335,7 @@ public static String getTransitUnitName(final int unit) {
// Anniversaries
private boolean announceBirthdays;
+ private boolean announceRecruitmentAnniversaries;
private boolean announceOfficersOnly;
private boolean announceChildBirthdays;
@@ -851,6 +847,7 @@ public CampaignOptions() {
// Anniversaries
setAnnounceBirthdays(true);
+ setAnnounceRecruitmentAnniversaries(true);
setAnnounceOfficersOnly(true);
setAnnounceChildBirthdays(true);
@@ -2198,6 +2195,25 @@ public void setAnnounceBirthdays(final boolean announceBirthdays) {
this.announceBirthdays = announceBirthdays;
}
+ /**
+ * Checks if recruitment anniversaries should be announced.
+ *
+ * @return {@code true} if recruitment anniversaries should be announced, {@code false} otherwise.
+ */
+ public boolean isAnnounceRecruitmentAnniversaries() {
+ return announceRecruitmentAnniversaries;
+ }
+
+ /**
+ * Set whether to announce recruitment anniversaries.
+ *
+ * @param announceRecruitmentAnniversaries {@code true} to announce recruitment anniversaries,
+ * {@code false} otherwise
+ */
+ public void setAnnounceRecruitmentAnniversaries(final boolean announceRecruitmentAnniversaries) {
+ this.announceRecruitmentAnniversaries = announceRecruitmentAnniversaries;
+ }
+
public boolean isAnnounceOfficersOnly() {
return announceOfficersOnly;
}
@@ -4871,6 +4887,7 @@ public void writeToXml(final PrintWriter pw, int indent) {
// region Announcements
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "announceBirthdays", isAnnounceBirthdays());
+ MHQXMLUtility.writeSimpleXMLTag(pw, indent, "announceRecruitmentAnniversaries", isAnnounceRecruitmentAnniversaries());
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "announceOfficersOnly", isAnnounceOfficersOnly());
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "announceChildBirthdays", isAnnounceChildBirthdays());
// endregion Announcements
@@ -5578,6 +5595,8 @@ public static CampaignOptions generateCampaignOptionsFromXml(Node wn, Version ve
// region anniversaries
} else if (wn2.getNodeName().equalsIgnoreCase("announceBirthdays")) {
retVal.setAnnounceBirthdays(Boolean.parseBoolean(wn2.getTextContent().trim()));
+ } else if (wn2.getNodeName().equalsIgnoreCase("announceRecruitmentAnniversaries")) {
+ retVal.setAnnounceRecruitmentAnniversaries(Boolean.parseBoolean(wn2.getTextContent().trim()));
} else if (wn2.getNodeName().equalsIgnoreCase("announceOfficersOnly")) {
retVal.setAnnounceOfficersOnly(Boolean.parseBoolean(wn2.getTextContent().trim()));
} else if (wn2.getNodeName().equalsIgnoreCase("announceChildBirthdays")) {
diff --git a/MekHQ/src/mekhq/campaign/MercRosterAccess.java b/MekHQ/src/mekhq/campaign/MercRosterAccess.java
index ed403a0837..0f87ba64ab 100644
--- a/MekHQ/src/mekhq/campaign/MercRosterAccess.java
+++ b/MekHQ/src/mekhq/campaign/MercRosterAccess.java
@@ -18,21 +18,6 @@
*/
package mekhq.campaign;
-import java.sql.Connection;
-import java.sql.Date;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.UUID;
-
-import javax.swing.SwingWorker;
-
import megamek.common.UnitType;
import megamek.logging.MMLogger;
import mekhq.campaign.force.Force;
@@ -44,6 +29,13 @@
import mekhq.campaign.personnel.ranks.Rank;
import mekhq.campaign.unit.Unit;
+import javax.swing.*;
+import java.sql.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.UUID;
+
public class MercRosterAccess extends SwingWorker {
private static final MMLogger logger = MMLogger.create(MercRosterAccess.class);
@@ -91,7 +83,7 @@ public void connect() throws SQLException {
conProperties.put("password", passwd);
try {
Class.forName("com.mysql.jdbc.Driver");
- connect = DriverManager.getConnection("jdbc:mysql://" + hostname + ":" + port + "/" + table, conProperties);
+ connect = DriverManager.getConnection("jdbc:mysql://" + hostname + ':' + port + '/' + table, conProperties);
} catch (SQLException e) {
throw e;
} catch (ClassNotFoundException e) {
@@ -562,10 +554,10 @@ private void writePersonnelData() {
preparedStatement.setInt(6, forceId);
preparedStatement.setInt(7, 1);
// TODO: get joining date right
- preparedStatement.setDate(8, Date.valueOf(p.getBirthday()));
+ preparedStatement.setDate(8, Date.valueOf(p.getDateOfBirth()));
// TODO: combine personnel log with biography
preparedStatement.setString(9, p.getBiography());
- preparedStatement.setDate(10, Date.valueOf(p.getBirthday()));
+ preparedStatement.setDate(10, Date.valueOf(p.getDateOfBirth()));
preparedStatement.setString(11, p.getId().toString());
if (preparedStatement.executeUpdate() < 1) {
// no prior record so insert
@@ -578,9 +570,9 @@ private void writePersonnelData() {
preparedStatement.setString(5, p.getStatus().toString());
preparedStatement.setInt(6, forceId);
preparedStatement.setInt(7, 1);
- preparedStatement.setDate(8, Date.valueOf(p.getBirthday()));
+ preparedStatement.setDate(8, Date.valueOf(p.getDateOfBirth()));
preparedStatement.setString(9, p.getBiography());
- preparedStatement.setDate(10, Date.valueOf(p.getBirthday()));
+ preparedStatement.setDate(10, Date.valueOf(p.getDateOfBirth()));
preparedStatement.setString(11, p.getId().toString());
preparedStatement.executeUpdate();
}
diff --git a/MekHQ/src/mekhq/campaign/personnel/Person.java b/MekHQ/src/mekhq/campaign/personnel/Person.java
index 7046bdbde8..59d2c113b9 100644
--- a/MekHQ/src/mekhq/campaign/personnel/Person.java
+++ b/MekHQ/src/mekhq/campaign/personnel/Person.java
@@ -19,20 +19,6 @@
*/
package mekhq.campaign.personnel;
-import static java.lang.Math.abs;
-
-import java.io.PrintWriter;
-import java.time.LocalDate;
-import java.time.temporal.ChronoUnit;
-import java.util.*;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import java.util.stream.Stream;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
import megamek.Version;
import megamek.client.generator.RandomNameGenerator;
import megamek.codeUtilities.StringUtility;
@@ -62,24 +48,11 @@
import mekhq.campaign.mod.am.InjuryUtil;
import mekhq.campaign.parts.Part;
import mekhq.campaign.personnel.education.Academy;
-import mekhq.campaign.personnel.enums.ManeiDominiClass;
-import mekhq.campaign.personnel.enums.ManeiDominiRank;
-import mekhq.campaign.personnel.enums.ModifierValue;
-import mekhq.campaign.personnel.enums.PersonnelRole;
-import mekhq.campaign.personnel.enums.PersonnelStatus;
-import mekhq.campaign.personnel.enums.Phenotype;
-import mekhq.campaign.personnel.enums.PrisonerStatus;
-import mekhq.campaign.personnel.enums.Profession;
-import mekhq.campaign.personnel.enums.ROMDesignation;
+import mekhq.campaign.personnel.enums.*;
import mekhq.campaign.personnel.enums.education.EducationLevel;
import mekhq.campaign.personnel.enums.education.EducationStage;
import mekhq.campaign.personnel.familyTree.Genealogy;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Aggression;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Ambition;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Greed;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Intelligence;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.PersonalityQuirk;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Social;
+import mekhq.campaign.personnel.randomEvents.enums.personalities.*;
import mekhq.campaign.personnel.ranks.Rank;
import mekhq.campaign.personnel.ranks.RankSystem;
import mekhq.campaign.personnel.ranks.RankValidator;
@@ -92,6 +65,19 @@
import mekhq.campaign.work.IPartWork;
import mekhq.utilities.MHQXMLUtility;
import mekhq.utilities.ReportingUtilities;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.PrintWriter;
+import java.time.LocalDate;
+import java.time.temporal.ChronoUnit;
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+
+import static java.lang.Math.abs;
/**
* @author Jay Lawson (jaylawson39 at yahoo.com)
@@ -1352,10 +1338,20 @@ public void setBirthday(final LocalDate birthday) {
*
* @return a LocalDate representing the person's date of birth
*/
- public LocalDate getBirthday() {
+ public LocalDate getDateOfBirth() {
return birthday;
}
+ /**
+ * Retrieves the birthday for a person, with the year set to the same as the provided year.
+ *
+ * @param currentYear the current in-game year
+ * @return the birthday with the year updated to match the provided year
+ */
+ public LocalDate getBirthday(int currentYear) {
+ return birthday.withYear(currentYear);
+ }
+
public @Nullable LocalDate getDateOfDeath() {
return dateOfDeath;
}
@@ -1371,7 +1367,7 @@ public int getAge(LocalDate today) {
today = getDateOfDeath();
}
- return Math.toIntExact(ChronoUnit.YEARS.between(getBirthday(), today));
+ return Math.toIntExact(ChronoUnit.YEARS.between(getDateOfBirth(), today));
}
public @Nullable LocalDate getRecruitment() {
@@ -2042,7 +2038,7 @@ public void writeToXML(final PrintWriter pw, int indent, final Campaign campaign
if (overtimeLeft > 0) {
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "overtimeLeft", overtimeLeft);
}
- MHQXMLUtility.writeSimpleXMLTag(pw, indent, "birthday", getBirthday());
+ MHQXMLUtility.writeSimpleXMLTag(pw, indent, "birthday", getDateOfBirth());
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "deathday", getDateOfDeath());
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "recruitment", getRecruitment());
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "lastRankChangeDate", getLastRankChangeDate());
diff --git a/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java b/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java
index aaaac74387..f00588b1c7 100644
--- a/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java
+++ b/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java
@@ -157,7 +157,7 @@ public CreateCharacterDialog(JFrame parent, boolean modal, Person person, Campai
}
private void initializePilotAndOptions () {
- birthdate = person.getBirthday();
+ birthdate = person.getDateOfBirth();
selectedPhenotype = person.getPhenotype();
options = person.getOptions();
portrait = person.getPortrait();
@@ -937,7 +937,7 @@ private DefaultComboBoxModel getFactionsComboBoxModel() {
int endYear = person.getRecruitment() != null
? Math.min(person.getRecruitment().getYear(), year)
: year;
- if (faction.validBetween(person.getBirthday().getYear(), endYear)) {
+ if (faction.validBetween(person.getDateOfBirth().getYear(), endYear)) {
factionsModel.addElement(faction);
}
}
@@ -964,8 +964,8 @@ private DefaultComboBoxModel getPlanetarySystemsComboBoxModel(F
DefaultComboBoxModel model = new DefaultComboBoxModel<>();
List orderedSystems = campaign.getSystems().stream()
- .filter(a -> a.getFactionSet(person.getBirthday()).contains(faction))
- .sorted(Comparator.comparing(a -> a.getName(person.getBirthday())))
+ .filter(a -> a.getFactionSet(person.getDateOfBirth()).contains(faction))
+ .sorted(Comparator.comparing(a -> a.getName(person.getDateOfBirth())))
.toList();
for (PlanetarySystem system : orderedSystems) {
model.addElement(system);
diff --git a/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java b/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java
index 4c5b25dbe2..586769e74c 100644
--- a/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java
+++ b/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java
@@ -18,25 +18,6 @@
*/
package mekhq.gui.dialog;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.time.LocalDate;
-import java.time.Period;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.ResourceBundle;
-
-import javax.swing.*;
-
import megamek.client.generator.RandomCallsignGenerator;
import megamek.client.generator.RandomNameGenerator;
import megamek.client.ui.baseComponents.MMComboBox;
@@ -55,20 +36,11 @@
import megamek.logging.MMLogger;
import mekhq.MekHQ;
import mekhq.campaign.Campaign;
-import mekhq.campaign.personnel.Bloodname;
-import mekhq.campaign.personnel.Person;
-import mekhq.campaign.personnel.PersonnelOptions;
-import mekhq.campaign.personnel.SkillType;
-import mekhq.campaign.personnel.SpecialAbility;
+import mekhq.campaign.personnel.*;
import mekhq.campaign.personnel.enums.Phenotype;
import mekhq.campaign.personnel.enums.education.EducationLevel;
import mekhq.campaign.personnel.randomEvents.PersonalityController;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Aggression;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Ambition;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Greed;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Intelligence;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.PersonalityQuirk;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Social;
+import mekhq.campaign.personnel.randomEvents.enums.personalities.*;
import mekhq.campaign.unit.Unit;
import mekhq.campaign.universe.Faction;
import mekhq.campaign.universe.Faction.Tag;
@@ -82,9 +54,17 @@
import mekhq.gui.control.EditScenarioLogControl;
import mekhq.gui.utilities.MarkdownEditorPanel;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.time.LocalDate;
+import java.time.Period;
+import java.util.List;
+import java.util.*;
+
/**
* This dialog is used to both hire new pilots and to edit existing ones
- *
+ *
* @author Jay Lawson (jaylawson39 at yahoo.com)
*/
public class CustomizePersonDialog extends JDialog implements DialogOptionListener {
@@ -165,7 +145,7 @@ public CustomizePersonDialog(JFrame parent, boolean modal, Person person, Campai
}
private void initializePilotAndOptions() {
- birthdate = person.getBirthday();
+ birthdate = person.getDateOfBirth();
if (person.getRecruitment() != null) {
recruitment = person.getRecruitment();
}
@@ -1110,7 +1090,7 @@ private DefaultComboBoxModel getFactionsComboBoxModel() {
int endYear = person.getRecruitment() != null
? Math.min(person.getRecruitment().getYear(), year)
: year;
- if (faction.validBetween(person.getBirthday().getYear(), endYear)) {
+ if (faction.validBetween(person.getDateOfBirth().getYear(), endYear)) {
factionsModel.addElement(faction);
}
}
@@ -1135,8 +1115,8 @@ private DefaultComboBoxModel getPlanetarySystemsComboBoxModel(F
DefaultComboBoxModel model = new DefaultComboBoxModel<>();
List orderedSystems = campaign.getSystems().stream()
- .filter(a -> a.getFactionSet(person.getBirthday()).contains(faction))
- .sorted(Comparator.comparing(a -> a.getName(person.getBirthday())))
+ .filter(a -> a.getFactionSet(person.getDateOfBirth()).contains(faction))
+ .sorted(Comparator.comparing(a -> a.getName(person.getDateOfBirth())))
.toList();
for (PlanetarySystem system : orderedSystems) {
model.addElement(system);
diff --git a/MekHQ/src/mekhq/gui/dialog/GMToolsDialog.java b/MekHQ/src/mekhq/gui/dialog/GMToolsDialog.java
index ab6d22f00e..0a83d49444 100644
--- a/MekHQ/src/mekhq/gui/dialog/GMToolsDialog.java
+++ b/MekHQ/src/mekhq/gui/dialog/GMToolsDialog.java
@@ -20,43 +20,14 @@
*/
package mekhq.gui.dialog;
-import static mekhq.campaign.personnel.backgrounds.BackgroundsController.randomMercenaryCompanyNameGenerator;
-
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Cursor;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.List;
-import java.util.Objects;
-import java.util.StringJoiner;
-import java.util.function.Predicate;
-
-import javax.swing.*;
-import javax.swing.GroupLayout.Alignment;
-
import megamek.client.generator.RandomCallsignGenerator;
import megamek.client.generator.RandomNameGenerator;
import megamek.client.ui.baseComponents.MMButton;
import megamek.client.ui.baseComponents.MMComboBox;
import megamek.client.ui.dialogs.EntityReadoutDialog;
-import megamek.client.ui.preferences.JComboBoxPreference;
-import megamek.client.ui.preferences.JIntNumberSpinnerPreference;
-import megamek.client.ui.preferences.JTabbedPanePreference;
-import megamek.client.ui.preferences.JTextFieldPreference;
-import megamek.client.ui.preferences.PreferencesNode;
+import megamek.client.ui.preferences.*;
import megamek.codeUtilities.StringUtility;
-import megamek.common.Compute;
-import megamek.common.Entity;
-import megamek.common.EntityWeightClass;
-import megamek.common.MekFileParser;
-import megamek.common.MekSummary;
-import megamek.common.Messages;
-import megamek.common.UnitType;
+import megamek.common.*;
import megamek.common.annotations.Nullable;
import megamek.common.enums.Gender;
import megamek.logging.MMLogger;
@@ -78,6 +49,19 @@
import mekhq.gui.displayWrappers.FactionDisplay;
import mekhq.gui.panels.LayeredForceIconCreationPanel;
+import javax.swing.*;
+import javax.swing.GroupLayout.Alignment;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.List;
+import java.util.Objects;
+import java.util.StringJoiner;
+import java.util.function.Predicate;
+
+import static mekhq.campaign.personnel.backgrounds.BackgroundsController.randomMercenaryCompanyNameGenerator;
+
public class GMToolsDialog extends AbstractMHQDialog {
private static final MMLogger logger = MMLogger.create(GMToolsDialog.class);
@@ -708,7 +692,7 @@ private JPanel createRATPanel() {
final DefaultComboBoxModel factionModel = new DefaultComboBoxModel<>();
factionModel.addAll(FactionDisplay.getSortedValidFactionDisplays(Factions.getInstance().getFactions(),
- (getPerson() == null) ? getGUI().getCampaign().getLocalDate() : getPerson().getBirthday()));
+ (getPerson() == null) ? getGUI().getCampaign().getLocalDate() : getPerson().getDateOfBirth()));
setComboRATFaction(new MMComboBox<>("comboRATFaction", factionModel));
getComboRATFaction().setSelectedIndex(0);
gbc.gridx++;
@@ -854,7 +838,7 @@ private JPanel createNamePanel() {
final DefaultComboBoxModel factionModel = new DefaultComboBoxModel<>();
factionModel.addAll(FactionDisplay.getSortedValidFactionDisplays(Factions.getInstance().getFactions(),
- (getPerson() == null) ? getGUI().getCampaign().getLocalDate() : getPerson().getBirthday()));
+ (getPerson() == null) ? getGUI().getCampaign().getLocalDate() : getPerson().getDateOfBirth()));
setComboNameGeneratorFaction(new MMComboBox<>("comboRATFaction", factionModel));
getComboNameGeneratorFaction().setSelectedIndex(0);
gbc.gridx++;
@@ -1398,7 +1382,7 @@ private void setValuesFromPerson() {
getChkClanPersonnel().setSelected(getPerson().isClanPersonnel());
// Now we figure out the person's origin faction
- final FactionDisplay faction = new FactionDisplay(getPerson().getOriginFaction(), getPerson().getBirthday());
+ final FactionDisplay faction = new FactionDisplay(getPerson().getOriginFaction(), getPerson().getDateOfBirth());
getComboRATFaction().setSelectedItem(faction);
getComboNameGeneratorFaction().setSelectedItem(faction);
diff --git a/MekHQ/src/mekhq/gui/dialog/MedicalViewDialog.java b/MekHQ/src/mekhq/gui/dialog/MedicalViewDialog.java
index ae220ea98e..75e916c7ef 100644
--- a/MekHQ/src/mekhq/gui/dialog/MedicalViewDialog.java
+++ b/MekHQ/src/mekhq/gui/dialog/MedicalViewDialog.java
@@ -18,34 +18,14 @@
*/
package mekhq.gui.dialog;
-import java.awt.*;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.time.Period;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.ResourceBundle;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import java.util.stream.Stream;
-
-import javax.swing.*;
-
import megamek.client.ui.preferences.JWindowPreference;
import megamek.client.ui.preferences.PreferencesNode;
import megamek.logging.MMLogger;
import mekhq.MekHQ;
import mekhq.Utilities;
import mekhq.campaign.Campaign;
-import mekhq.campaign.ExtraData;
+import mekhq.campaign.ExtraData.Key;
+import mekhq.campaign.ExtraData.StringKey;
import mekhq.campaign.force.Force;
import mekhq.campaign.log.LogEntry;
import mekhq.campaign.log.LogEntryType;
@@ -56,15 +36,31 @@
import mekhq.campaign.personnel.enums.InjuryLevel;
import mekhq.gui.view.Paperdoll;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.time.Period;
+import java.util.List;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+
public class MedicalViewDialog extends JDialog {
private static final MMLogger logger = MMLogger.create(MedicalViewDialog.class);
private static final String MENU_CMD_SEPARATOR = ",";
- private static final ExtraData.Key DOCTOR_NOTES = new ExtraData.StringKey("doctor_notes");
+ private static final Key DOCTOR_NOTES = new StringKey("doctor_notes");
// TODO: Custom paper dolls
@SuppressWarnings("unused")
- private static final ExtraData.Key PAPERDOLL = new ExtraData.StringKey("paperdoll_xml_file");
+ private static final Key PAPERDOLL = new StringKey("paperdoll_xml_file");
private final Campaign campaign;
private final Person person;
@@ -324,7 +320,7 @@ private JPanel genBaseData(Campaign c, Person p) {
surname = p.getBloodname();
}
- Period age = Period.between(p.getBirthday(), c.getLocalDate());
+ Period age = Period.between(p.getDateOfBirth(), c.getLocalDate());
String phenotype = p.getPhenotype().isNone() ? resourceMap.getString("baselinePhenotype.text")
: p.getPhenotype().toString();
@@ -343,7 +339,7 @@ private JPanel genBaseData(Campaign c, Person p) {
panel.add(genWrittenPanel(givenName));
panel.add(genLabel(resourceMap.getString("birthDate.text")));
panel.add(genLabel(resourceMap.getString("age.text")));
- panel.add(genWrittenPanel(MekHQ.getMHQOptions().getDisplayFormattedDate(p.getBirthday())));
+ panel.add(genWrittenPanel(MekHQ.getMHQOptions().getDisplayFormattedDate(p.getDateOfBirth())));
panel.add(genWrittenPanel(String.format(resourceMap.getString("age.format"), age.getYears(), age.getMonths())));
panel.add(genLabel(resourceMap.getString("gender.text")));
panel.add(genLabel(resourceMap.getString("phenotype.text")));
@@ -373,7 +369,7 @@ private JPanel genMedicalHistory(Campaign c, Person p) {
Collectors.groupingBy(entry -> MekHQ.getMHQOptions().getDisplayFormattedDate(entry.getDate())));
groupedEntries.entrySet().stream()
.filter(e -> !e.getValue().isEmpty())
- .sorted(Map.Entry.comparingByKey())
+ .sorted(Entry.comparingByKey())
.forEachOrdered(e -> {
if (e.getValue().size() > 1) {
panel.add(genWrittenText(e.getKey()));
@@ -433,7 +429,7 @@ private Stream maxInjuryLevelLocationStream(Person p) {
.forEach(bl -> levelMap.put(bl, getMaxInjuryLevel(p, bl)));
return levelMap.entrySet().stream()
.sorted((entry1, entry2) -> Integer.compare(entry2.getValue().ordinal(), entry1.getValue().ordinal()))
- .map(Map.Entry::getKey);
+ .map(Entry::getKey);
}
private JPanel fillInjuries(JPanel panel, Campaign c, Person p) {
diff --git a/MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java b/MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java
index 3d7a673fb9..8b42f7fd2c 100644
--- a/MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java
+++ b/MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java
@@ -18,14 +18,6 @@
*/
package mekhq.gui.enums;
-import java.util.Comparator;
-import java.util.ResourceBundle;
-import java.util.stream.Collectors;
-
-import javax.swing.JTable;
-import javax.swing.SortOrder;
-import javax.swing.SwingConstants;
-
import megamek.codeUtilities.StringUtility;
import megamek.common.Entity;
import megamek.common.Jumpship;
@@ -41,19 +33,15 @@
import mekhq.campaign.personnel.PersonnelOptions;
import mekhq.campaign.personnel.SkillType;
import mekhq.campaign.personnel.enums.GenderDescriptors;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Aggression;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Ambition;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Greed;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Intelligence;
-import mekhq.campaign.personnel.randomEvents.enums.personalities.Social;
+import mekhq.campaign.personnel.randomEvents.enums.personalities.*;
import mekhq.campaign.unit.Unit;
import mekhq.campaign.universe.Planet;
-import mekhq.gui.sorter.BonusSorter;
-import mekhq.gui.sorter.DateStringComparator;
-import mekhq.gui.sorter.FormattedNumberSorter;
-import mekhq.gui.sorter.IntegerStringSorter;
-import mekhq.gui.sorter.LevelSorter;
-import mekhq.gui.sorter.PersonRankStringSorter;
+import mekhq.gui.sorter.*;
+
+import javax.swing.*;
+import java.util.Comparator;
+import java.util.ResourceBundle;
+import java.util.stream.Collectors;
public enum PersonnelTableModelColumn {
// region Enum Declarations
@@ -495,7 +483,7 @@ public String getCellValue(final Campaign campaign, final PersonnelMarket person
return person.getCallsign();
case AGE:
case BIRTHDAY:
- return MekHQ.getMHQOptions().getDisplayFormattedDate(person.getBirthday());
+ return MekHQ.getMHQOptions().getDisplayFormattedDate(person.getDateOfBirth());
case PERSONNEL_STATUS:
return person.getStatus().toString();
case GENDER:
diff --git a/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java
index f9877dff18..f6eb3d979b 100644
--- a/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java
+++ b/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java
@@ -18,43 +18,6 @@
*/
package mekhq.gui.panes;
-import static megamek.client.ui.WrapLayout.wordWrap;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.GridLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.time.LocalDate;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.Vector;
-import java.util.stream.IntStream;
-
-import javax.swing.*;
-import javax.swing.GroupLayout.Alignment;
-import javax.swing.JSpinner.DefaultEditor;
-import javax.swing.JSpinner.NumberEditor;
-import javax.swing.LayoutStyle.ComponentPlacement;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.DefaultTableModel;
-import javax.swing.table.JTableHeader;
-import javax.swing.table.TableColumn;
-
import megamek.client.generator.RandomGenderGenerator;
import megamek.client.generator.RandomNameGenerator;
import megamek.client.ui.baseComponents.JDisableablePanel;
@@ -112,6 +75,29 @@
import mekhq.module.PersonnelMarketServiceManager;
import mekhq.module.api.PersonnelMarketMethod;
+import javax.swing.*;
+import javax.swing.GroupLayout.Alignment;
+import javax.swing.JSpinner.DefaultEditor;
+import javax.swing.JSpinner.NumberEditor;
+import javax.swing.LayoutStyle.ComponentPlacement;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.JTableHeader;
+import javax.swing.table.TableColumn;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.time.LocalDate;
+import java.util.List;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.stream.IntStream;
+
+import static megamek.client.ui.WrapLayout.wordWrap;
+
/**
* @author Justin 'Windchild' Bowen
*/
@@ -461,6 +447,7 @@ public class CampaignOptionsPane extends AbstractMHQTabbedPane {
// Anniversaries
private final JPanel anniversaryPanel = new JPanel();
private JCheckBox chkAnnounceBirthdays;
+ private JCheckBox chkAnnounceRecruitmentAnniversaries;
private JCheckBox chkAnnounceOfficersOnly;
private JCheckBox chkAnnounceChildBirthdays;
@@ -5285,10 +5272,13 @@ private JPanel createAnniversaryPanel() {
chkAnnounceBirthdays.addActionListener(evt -> {
final boolean isEnabled = chkAnnounceBirthdays.isSelected();
- chkAnnounceOfficersOnly.setEnabled(isEnabled);
chkAnnounceChildBirthdays.setEnabled(isEnabled);
});
+ chkAnnounceRecruitmentAnniversaries = new JCheckBox(resources.getString("chkAnnounceRecruitmentAnniversaries.text"));
+ chkAnnounceRecruitmentAnniversaries.setToolTipText(resources.getString("chkAnnounceRecruitmentAnniversaries.toolTipText"));
+ chkAnnounceRecruitmentAnniversaries.setName("chkAnnounceRecruitmentAnniversaries");
+
chkAnnounceOfficersOnly = new JCheckBox(resources.getString("chkAnnounceOfficersOnly.text"));
chkAnnounceOfficersOnly.setToolTipText(resources.getString("chkAnnounceOfficersOnly.toolTipText"));
chkAnnounceOfficersOnly.setName("chkAnnounceOfficersOnly");
@@ -5311,12 +5301,14 @@ private JPanel createAnniversaryPanel() {
layout.setVerticalGroup(
layout.createSequentialGroup()
.addComponent(chkAnnounceBirthdays)
+ .addComponent(chkAnnounceRecruitmentAnniversaries)
.addComponent(chkAnnounceOfficersOnly)
.addComponent(chkAnnounceChildBirthdays));
layout.setHorizontalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addComponent(chkAnnounceBirthdays)
+ .addComponent(chkAnnounceRecruitmentAnniversaries)
.addComponent(chkAnnounceOfficersOnly)
.addComponent(chkAnnounceChildBirthdays));
@@ -8691,6 +8683,7 @@ public void setOptions(@Nullable CampaignOptions options,
// Anniversaries
chkAnnounceBirthdays.setSelected(options.isAnnounceBirthdays());
+ chkAnnounceRecruitmentAnniversaries.setSelected(options.isAnnounceRecruitmentAnniversaries());
chkAnnounceOfficersOnly.setSelected(options.isAnnounceOfficersOnly());
chkAnnounceChildBirthdays.setSelected(options.isAnnounceChildBirthdays());
@@ -9440,6 +9433,7 @@ public void updateOptions() {
// Anniversaries
options.setAnnounceBirthdays(chkAnnounceBirthdays.isSelected());
+ options.setAnnounceRecruitmentAnniversaries(chkAnnounceRecruitmentAnniversaries.isSelected());
options.setAnnounceOfficersOnly(chkAnnounceOfficersOnly.isSelected());
options.setAnnounceChildBirthdays(chkAnnounceChildBirthdays.isSelected());
From 7ea1c5e6056b4c330efe307b2516a0deb2708669 Mon Sep 17 00:00:00 2001
From: IllianiCBT
Date: Wed, 25 Sep 2024 13:20:08 -0500
Subject: [PATCH 3/4] Refactor `setBirthday` to `setDateOfBirth` for clarity
Updated method names in various files to use `setDateOfBirth` instead of `setBirthday` to enhance clarity and consistency throughout the codebase. This change involved updating method calls and documentation comments accordingly.
---
.../src/mekhq/campaign/personnel/Person.java | 9 +++--
.../generator/AbstractPersonnelGenerator.java | 10 +++---
.../procreation/AbstractProcreation.java | 2 +-
.../storypoint/CreateCharacterStoryPoint.java | 17 +++++-----
.../gui/dialog/CreateCharacterDialog.java | 2 +-
.../gui/dialog/CustomizePersonDialog.java | 2 +-
.../gui/dialog/HireBulkPersonnelDialog.java | 33 +++++++++----------
7 files changed, 38 insertions(+), 37 deletions(-)
diff --git a/MekHQ/src/mekhq/campaign/personnel/Person.java b/MekHQ/src/mekhq/campaign/personnel/Person.java
index 59d2c113b9..309383615b 100644
--- a/MekHQ/src/mekhq/campaign/personnel/Person.java
+++ b/MekHQ/src/mekhq/campaign/personnel/Person.java
@@ -327,7 +327,7 @@ public Person(final String preNominal, final String givenName, final String surn
secondaryRole = PersonnelRole.NONE;
primaryDesignator = ROMDesignation.NONE;
secondaryDesignator = ROMDesignation.NONE;
- setBirthday(LocalDate.now());
+ setDateOfBirth(LocalDate.now());
originFaction = Factions.getInstance().getFaction(factionCode);
originPlanet = null;
@@ -1329,7 +1329,12 @@ public Gender getGender() {
return gender;
}
- public void setBirthday(final LocalDate birthday) {
+ /**
+ * Sets the date of birth (the date they are born) for the person.
+ *
+ * @param birthday the person's new date of birth
+ */
+ public void setDateOfBirth(final LocalDate birthday) {
this.birthday = birthday;
}
diff --git a/MekHQ/src/mekhq/campaign/personnel/generator/AbstractPersonnelGenerator.java b/MekHQ/src/mekhq/campaign/personnel/generator/AbstractPersonnelGenerator.java
index 2df7224d5a..86d5d16c6a 100644
--- a/MekHQ/src/mekhq/campaign/personnel/generator/AbstractPersonnelGenerator.java
+++ b/MekHQ/src/mekhq/campaign/personnel/generator/AbstractPersonnelGenerator.java
@@ -18,11 +18,8 @@
*/
package mekhq.campaign.personnel.generator;
-import java.time.LocalDate;
-import java.util.Objects;
-
-import megamek.client.generator.RandomNameGenerator;
import megamek.client.generator.RandomGenderGenerator;
+import megamek.client.generator.RandomNameGenerator;
import megamek.common.Compute;
import megamek.common.enums.Gender;
import mekhq.Utilities;
@@ -33,6 +30,9 @@
import mekhq.campaign.personnel.enums.PersonnelRole;
import mekhq.campaign.personnel.enums.Phenotype;
+import java.time.LocalDate;
+import java.util.Objects;
+
/**
* Represents a class which can generate new {@link Person} objects
* for a {@link Campaign}.
@@ -215,6 +215,6 @@ protected void generateBirthday(Campaign campaign, Person person, int expLvl, bo
int nDays = birthday.isLeapYear() ? 366 : 365;
int randomDay = Compute.randomInt(nDays) + 1;
- person.setBirthday(birthday.withDayOfYear(randomDay));
+ person.setDateOfBirth(birthday.withDayOfYear(randomDay));
}
}
diff --git a/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java b/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java
index d72ac2c824..faedb75dbb 100644
--- a/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java
+++ b/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java
@@ -322,7 +322,7 @@ public void birth(final Campaign campaign, final LocalDate today, final Person m
final Person baby = campaign.newDependent(true);
baby.setSurname(campaign.getCampaignOptions().getBabySurnameStyle()
.generateBabySurname(mother, father, baby.getGender()));
- baby.setBirthday(today);
+ baby.setDateOfBirth(today);
// Create reports and log the birth
campaign.addReport(String.format(resources.getString("babyBorn.report"),
diff --git a/MekHQ/src/mekhq/campaign/storyarc/storypoint/CreateCharacterStoryPoint.java b/MekHQ/src/mekhq/campaign/storyarc/storypoint/CreateCharacterStoryPoint.java
index bf98e5bcc3..599bfe6201 100644
--- a/MekHQ/src/mekhq/campaign/storyarc/storypoint/CreateCharacterStoryPoint.java
+++ b/MekHQ/src/mekhq/campaign/storyarc/storypoint/CreateCharacterStoryPoint.java
@@ -20,14 +20,6 @@
*/
package mekhq.campaign.storyarc.storypoint;
-import java.io.PrintWriter;
-import java.text.ParseException;
-import java.util.Enumeration;
-import java.util.UUID;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
import megamek.Version;
import megamek.common.options.IOption;
import megamek.common.options.IOptionGroup;
@@ -54,6 +46,13 @@
import mekhq.gui.dialog.CreateCharacterDialog;
import mekhq.gui.dialog.CreateCharacterDialog.NameRestrictions;
import mekhq.utilities.MHQXMLUtility;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.PrintWriter;
+import java.text.ParseException;
+import java.util.Enumeration;
+import java.util.UUID;
/**
* This StoryPoint opens a {@link CreateCharacterDialog CreateCharacterDialog}
@@ -180,7 +179,7 @@ public Person createPerson() {
AbstractSkillGenerator skillGenerator = new DefaultSkillGenerator(skillPrefs);
skillGenerator.generateSkills(getCampaign(), p, SkillType.EXP_ULTRA_GREEN);
- p.setBirthday(getCampaign().getLocalDate().minusYears(age));
+ p.setDateOfBirth(getCampaign().getLocalDate().minusYears(age));
// set education
EducationController.setInitialEducation(campaign, p);
diff --git a/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java b/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java
index f00588b1c7..d906d5fdf1 100644
--- a/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java
+++ b/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java
@@ -1458,7 +1458,7 @@ private void done() {
? ((Gender) choiceGender.getSelectedItem()).getInternalVariant()
: (Gender) choiceGender.getSelectedItem());
}
- person.setBirthday(birthdate);
+ person.setDateOfBirth(birthdate);
person.setOriginFaction((Faction) choiceFaction.getSelectedItem());
if (choiceSystem.getSelectedItem() != null && choicePlanet.getSelectedItem() != null) {
person.setOriginPlanet((Planet)choicePlanet.getSelectedItem());
diff --git a/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java b/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java
index 586769e74c..226aa934db 100644
--- a/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java
+++ b/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java
@@ -1181,7 +1181,7 @@ private void btnOkActionPerformed(ActionEvent evt) {
: (Gender) choiceGender.getSelectedItem());
}
- person.setBirthday(birthdate);
+ person.setDateOfBirth(birthdate);
person.setRecruitment(recruitment);
person.setLastRankChangeDate(lastRankChangeDate);
person.setRetirement(retirement);
diff --git a/MekHQ/src/mekhq/gui/dialog/HireBulkPersonnelDialog.java b/MekHQ/src/mekhq/gui/dialog/HireBulkPersonnelDialog.java
index cff27f2aee..f7e4eec44f 100644
--- a/MekHQ/src/mekhq/gui/dialog/HireBulkPersonnelDialog.java
+++ b/MekHQ/src/mekhq/gui/dialog/HireBulkPersonnelDialog.java
@@ -18,23 +18,6 @@
*/
package mekhq.gui.dialog;
-import static mekhq.campaign.personnel.SkillType.*;
-import static mekhq.campaign.personnel.generator.AbstractSkillGenerator.addSkill;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.time.LocalDate;
-import java.time.temporal.ChronoUnit;
-import java.util.Objects;
-import java.util.ResourceBundle;
-
-import javax.swing.*;
-import javax.swing.JSpinner.DefaultEditor;
-import javax.swing.JSpinner.NumberEditor;
-
import megamek.client.ui.baseComponents.MMComboBox;
import megamek.client.ui.preferences.JWindowPreference;
import megamek.client.ui.preferences.PreferencesNode;
@@ -53,6 +36,20 @@
import mekhq.gui.CampaignGUI;
import mekhq.gui.displayWrappers.RankDisplay;
+import javax.swing.*;
+import javax.swing.JSpinner.DefaultEditor;
+import javax.swing.JSpinner.NumberEditor;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.time.LocalDate;
+import java.time.temporal.ChronoUnit;
+import java.util.Objects;
+import java.util.ResourceBundle;
+
+import static mekhq.campaign.personnel.SkillType.*;
+import static mekhq.campaign.personnel.generator.AbstractSkillGenerator.addSkill;
+
/**
* @author Jay Lawson
*/
@@ -353,7 +350,7 @@ private void hire(boolean isGmHire) {
if (useAge) {
if ((age > maxAgeVal) || (age < minAgeVal)) {
LocalDate birthDay = earliestBirthDate.plusDays(Compute.randomInt(days));
- person.setBirthday(birthDay);
+ person.setDateOfBirth(birthDay);
age = person.getAge(today);
}
}
From d46fdef6115d55596947a947e4b0b7a92b341107 Mon Sep 17 00:00:00 2001
From: IllianiCBT
Date: Wed, 25 Sep 2024 19:44:23 -0500
Subject: [PATCH 4/4] merge conflicts
---
MekHQ/src/mekhq/campaign/Campaign.java | 30 +++++--------------
.../personnel/marriage/AbstractMarriage.java | 4 +--
.../procreation/AbstractProcreation.java | 2 +-
3 files changed, 10 insertions(+), 26 deletions(-)
diff --git a/MekHQ/src/mekhq/campaign/Campaign.java b/MekHQ/src/mekhq/campaign/Campaign.java
index 060032c212..8d6228b5a2 100644
--- a/MekHQ/src/mekhq/campaign/Campaign.java
+++ b/MekHQ/src/mekhq/campaign/Campaign.java
@@ -59,7 +59,9 @@
import mekhq.campaign.log.HistoricalLogEntry;
import mekhq.campaign.log.LogEntry;
import mekhq.campaign.log.ServiceLogger;
-import mekhq.campaign.market.*;
+import mekhq.campaign.market.PartsStore;
+import mekhq.campaign.market.PersonnelMarket;
+import mekhq.campaign.market.ShoppingList;
import mekhq.campaign.market.contractMarket.AbstractContractMarket;
import mekhq.campaign.market.contractMarket.AtbMonthlyContractMarket;
import mekhq.campaign.market.unitMarket.AbstractUnitMarket;
@@ -83,9 +85,7 @@
import mekhq.campaign.personnel.education.Academy;
import mekhq.campaign.personnel.education.EducationController;
import mekhq.campaign.personnel.enums.*;
-import mekhq.campaign.personnel.generator.AbstractPersonnelGenerator;
-import mekhq.campaign.personnel.generator.DefaultPersonnelGenerator;
-import mekhq.campaign.personnel.generator.RandomPortraitGenerator;
+import mekhq.campaign.personnel.generator.*;
import mekhq.campaign.personnel.marriage.AbstractMarriage;
import mekhq.campaign.personnel.marriage.DisabledRandomMarriage;
import mekhq.campaign.personnel.procreation.AbstractProcreation;
@@ -145,22 +145,6 @@
import static mekhq.campaign.unit.Unit.SITE_FACILITY_MAINTENANCE;
import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG;
-import javax.swing.*;
-import java.io.PrintWriter;
-import java.text.MessageFormat;
-import java.time.DayOfWeek;
-import java.time.LocalDate;
-import java.time.Month;
-import java.time.temporal.ChronoUnit;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
-import static mekhq.campaign.personnel.backgrounds.BackgroundsController.randomMercenaryCompanyNameGenerator;
-import static mekhq.campaign.personnel.education.EducationController.getAcademy;
-import static mekhq.campaign.personnel.turnoverAndRetention.RetirementDefectionTracker.Payout.isBreakingContract;
-import static mekhq.campaign.unit.Unit.SITE_FACILITY_MAINTENANCE;
-
/**
* The main campaign class, keeps track of teams and units
*
@@ -1682,7 +1666,7 @@ public boolean recruitPerson(Person p, PrisonerStatus prisonerStatus, boolean gm
private void simulateRelationshipHistory(Person person) {
// how many weeks should the simulation run?
LocalDate localDate = getLocalDate();
- long weeksBetween = ChronoUnit.WEEKS.between(person.getBirthday().plusYears(18), localDate);
+ long weeksBetween = ChronoUnit.WEEKS.between(person.getDateOfBirth().plusYears(18), localDate);
// this means there is nothing to simulate
if (weeksBetween == 0) {
@@ -3897,9 +3881,9 @@ public void processNewDayPersonnel() {
if ((person.getStatus().isOnMaternityLeave()) && (!children.isEmpty())) {
- children.sort(Comparator.comparing(Person::getBirthday).reversed());
+ children.sort(Comparator.comparing(Person::getDateOfBirth).reversed());
- if (getLocalDate().isAfter(children.get(0).getBirthday().plusDays(41))) {
+ if (getLocalDate().isAfter(children.get(0).getDateOfBirth().plusDays(41))) {
person.changeStatus(this, getLocalDate(), PersonnelStatus.ACTIVE);
}
}
diff --git a/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java b/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java
index 536434303c..3f5ef99913 100644
--- a/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java
+++ b/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java
@@ -389,11 +389,11 @@ Person createExternalSpouse(final Campaign campaign, final LocalDate today, fina
if (externalSpouseAge < externalSpouseMinAge) {
int difference = externalSpouseMinAge - externalSpouseAge;
- externalSpouse.setBirthday(externalSpouse.getBirthday().minusYears(difference));
+ externalSpouse.setDateOfBirth(externalSpouse.getDateOfBirth().minusYears(difference));
} else if (externalSpouseAge > externalSpouseMaxAge) {
int difference = externalSpouseMaxAge - externalSpouseAge;
- externalSpouse.setBirthday(externalSpouse.getBirthday().plusYears(difference));
+ externalSpouse.setDateOfBirth(externalSpouse.getDateOfBirth().plusYears(difference));
}
return externalSpouse;
diff --git a/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java b/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java
index c3c4e15468..7d2794d92e 100644
--- a/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java
+++ b/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java
@@ -441,7 +441,7 @@ public List birthHistoric(final Campaign campaign, final LocalDate today
baby.setSurname(campaign.getCampaignOptions().getBabySurnameStyle()
.generateBabySurname(mother, father, baby.getGender()));
- baby.setBirthday(today);// Limit skills by age for children and adolescents
+ baby.setDateOfBirth(today);// Limit skills by age for children and adolescents
baby.removeAllSkills();