Skip to content

Commit

Permalink
Refactor setBirthday to setDateOfBirth for clarity
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
IllianiCBT committed Sep 25, 2024
1 parent ac7b179 commit 7ea1c5e
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 37 deletions.
9 changes: 7 additions & 2 deletions MekHQ/src/mekhq/campaign/personnel/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}.
Expand Down Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 15 additions & 18 deletions MekHQ/src/mekhq/gui/dialog/HireBulkPersonnelDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
*/
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 7ea1c5e

Please sign in to comment.