Skip to content

Commit

Permalink
Merge pull request #1673 from Windchild292/dev_Windchild_RMB
Browse files Browse the repository at this point in the history
Random Marriages: Minor Prisoner Marriage Bugfix/Improvement
  • Loading branch information
Windchild292 authored Apr 15, 2020
2 parents 7b8bd9c + dfda30d commit 8793402
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions MekHQ/src/mekhq/campaign/personnel/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,7 @@ public boolean safeSpouse(Person p) {
// can't marry a prisoner, unless you are also a prisoner (this is purposely left open for prisoners to marry who they want)
// can't marry a person who is dead or MIA
// can't marry inactive personnel (this is to show how they aren't part of the force anymore)
// TODO : can't marry anyone who is not located at the same planet as the person - GitHub #1672: Implement current planet tracking for personnel
// can't marry a close relative
return (
!this.equals(p)
Expand All @@ -1330,26 +1331,27 @@ public boolean safeSpouse(Person p) {
&& !p.isDeadOrMIA()
&& p.isActive()
&& ((getAncestorsId() == null)
|| !campaign.getAncestors(getAncestorsId()).checkMutualAncestors(campaign.getAncestors(p.getAncestorsId())))
|| !getCampaign().getAncestors(getAncestorsId()).checkMutualAncestors(
getCampaign().getAncestors(p.getAncestorsId())))
);
}

public boolean oldEnoughToMarry() {
return (getAge(getCampaign().getLocalDate()) >= campaign.getCampaignOptions().getMinimumMarriageAge());
return (getAge(getCampaign().getLocalDate()) >= getCampaign().getCampaignOptions().getMinimumMarriageAge());
}

public void randomMarriage() {
// Don't attempt to generate is someone has a spouse, isn't old enough to marry,
// is actively deployed, or is currently a prisoner
if (hasSpouse() || !oldEnoughToMarry() || isDeployed() || isPrisoner()) {
// or is actively deployed
if (hasSpouse() || !oldEnoughToMarry() || isDeployed()) {
return;
}

// setting is the fractional chance that this attempt at finding a marriage will result in one
if (Compute.randomFloat() < (campaign.getCampaignOptions().getChanceRandomMarriages())) {
if (Compute.randomFloat() < (getCampaign().getCampaignOptions().getChanceRandomMarriages())) {
addRandomSpouse(false);
} else if (campaign.getCampaignOptions().useRandomSameSexMarriages()) {
if (Compute.randomFloat() < (campaign.getCampaignOptions().getChanceRandomSameSexMarriages())) {
} else if (getCampaign().getCampaignOptions().useRandomSameSexMarriages()) {
if (Compute.randomFloat() < (getCampaign().getCampaignOptions().getChanceRandomSameSexMarriages())) {
addRandomSpouse(true);
}
}
Expand All @@ -1358,7 +1360,7 @@ public void randomMarriage() {
public void addRandomSpouse(boolean sameSex) {
List<Person> potentials = new ArrayList<>();
int gender = sameSex ? getGender() : (isMale() ? Crew.G_FEMALE : Crew.G_MALE);
for (Person p : campaign.getPersonnel()) {
for (Person p : getCampaign().getActivePersonnel()) {
if (isPotentialRandomSpouse(p, gender)) {
potentials.add(p);
}
Expand All @@ -1371,9 +1373,7 @@ public void addRandomSpouse(boolean sameSex) {
}

public boolean isPotentialRandomSpouse(Person p, int gender) {
if (p.getGender() != gender) {
return false;
} else if (!safeSpouse(p)) {
if ((p.getGender() != gender) || !safeSpouse(p) || !(isFree() || (isPrisoner() && p.isPrisoner()))) {
return false;
}

Expand Down

0 comments on commit 8793402

Please sign in to comment.