Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added Support for Handling Medical Discharge #4617

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions MekHQ/src/mekhq/campaign/Campaign.java
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,9 @@ public boolean applyRetirement(Money totalPayout, Map<UUID, UUID> unitAssignment
boolean wasSacked = getRetirementDefectionTracker().getPayout(pid).isWasSacked();

if ((!wasKilled) && (!wasSacked)) {
if (isBreakingContract(person, getLocalDate(), getCampaignOptions().getServiceContractDuration())) {
if (!person.getPermanentInjuries().isEmpty()) {
person.changeStatus(this, getLocalDate(), PersonnelStatus.RETIRED);
} if (isBreakingContract(person, getLocalDate(), getCampaignOptions().getServiceContractDuration())) {
if (!getActiveContracts().isEmpty()) {
int roll = Compute.randomInt(20);

Expand All @@ -751,7 +753,11 @@ public boolean applyRetirement(Money totalPayout, Map<UUID, UUID> unitAssignment
}

if (wasSacked) {
person.changeStatus(this, getLocalDate(), PersonnelStatus.SACKED);
if (person.getPermanentInjuries().isEmpty()) {
person.changeStatus(this, getLocalDate(), PersonnelStatus.SACKED);
} else {
person.changeStatus(this, getLocalDate(), PersonnelStatus.RETIRED);
}
}

// civilian spouses follow their partner in departing
Expand Down
6 changes: 6 additions & 0 deletions MekHQ/src/mekhq/campaign/personnel/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -3877,6 +3877,12 @@ public List<Injury> getInjuries() {
return new ArrayList<>(injuries);
}

public List<Injury> getPermanentInjuries() {
return injuries.stream()
.filter(Injury::isPermanent)
.collect(Collectors.toList());
}

public void clearInjuries() {
injuries.clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -966,15 +966,18 @@ private void calculatePayout(final Campaign campaign, final Person person, final
// person was killed
if (killed) {
payoutAmount = getPayoutOrBonusValue(campaign, person).multipliedBy(campaign.getCampaignOptions().getPayoutRetirementMultiplier());
// person was sacked
} else if (sacked) {
payoutAmount = Money.of(0);
// person is getting medically discharged
} else if (!person.getPermanentInjuries().isEmpty()) {
payoutAmount = getPayoutOrBonusValue(campaign, person).multipliedBy(campaign.getCampaignOptions().getPayoutRetirementMultiplier());
// person is defecting
} else if (isBreakingContract(person, campaign.getLocalDate(), campaign.getCampaignOptions().getServiceContractDuration())) {
payoutAmount = Money.of(0);
// person is retiring
} else if (person.getAge(campaign.getLocalDate()) >= 50) {
payoutAmount = getPayoutOrBonusValue(campaign, person).multipliedBy(campaign.getCampaignOptions().getPayoutRetirementMultiplier());
// person was sacked
} else if (sacked) {
payoutAmount = Money.of(0);
// person is resigning
} else {
payoutAmount = getPayoutOrBonusValue(campaign, person);
Expand Down