8000 Improvement: Adjusted the Rate of Captured Clan Personnel Committing Bondsref; Added the Ability for Captured Combine Personnel to Commit Seppuku by IllianiBird · Pull Request #6907 · MegaMek/mekhq · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improvement: Adjusted the Rate of Captured Clan Personnel Committing Bondsref; Added the Ability for Captured Combine Personnel to Commit Seppuku #6907

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

Merged
merged 10 commits into from
May 8, 2025
4 changes: 4 additions & 0 deletions MekHQ/resources/mekhq/resources/PersonnelStatus.properties
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ BONDSREF.label=Bondsref
BONDSREF.tooltip=They have performed Bondsref
BONDSREF.report=%s has preformed {0}<b>Bondsref</b>{1} instead of becoming a Bondsman.
BONDSREF.log=Performed Bondsref
SEPPUKU.label=Seppuku
SEPPUKU.tooltip=They have performed Seppuku
SEPPUKU.report=%s has performed {0}<b>Seppuku</b>{1} instead of becoming a Prisoner.
SEPPUKU.log=Performed Seppuku
### DEATH
KIA.label=Killed in Action
KIA.tooltip=They have been killed in action.
Expand Down
2 changes: 2 additions & 0 deletions MekHQ/resources/mekhq/resources/PrisonerEvents.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# CapturePrisoners.java
bondsref.report={0} has performed {1}<b>Bondsref</b>{2} instead of accepting capture by our forces.\
\ Their body has been transported to the morgue.
seppuku.report={0} has performed {1}<b>Seppuku</b>{2} instead of accepting capture by our forces.\
\ Their body has been transported to the morgue.
# EVENT GENERAL
result.ooc=Closing or canceling this conversation will automatically pick the first option.\
<p>Normally this situation will be caused by low <a href=''GLOSSARY:PRISONER_CAPACITY''>Prisoner Capacity</a>. If that\
Expand Down
20 changes: 17 additions & 3 deletions MekHQ/src/mekhq/campaign/personnel/enums/PersonnelStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
*
* Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of
* InMediaRes Productions, LLC.
*
* MechWarrior Copyright Microsoft Corporation. MekHQ was created under
* Microsoft's "Game Content Usage Rules"
* <https://www.xbox.com/en-US/developers/rules> and it is not endorsed by or
* affiliated with Microsoft.
*/
package mekhq.campaign.personnel.enums;

Expand Down Expand Up @@ -81,7 +86,8 @@ public enum PersonnelStatus {
UNDETERMINED(NotificationSeverity.NEGATIVE, true, true),
SUICIDE(NotificationSeverity.NEGATIVE, true, true),
ENEMY_BONDSMAN(NotificationSeverity.NEGATIVE, false, false),
BONDSREF(NotificationSeverity.NEGATIVE, true, true);
BONDSREF(NotificationSeverity.NEGATIVE, true, true),
SEPPUKU(NotificationSeverity.NEGATIVE, true, true);

/**
* Represents the severity levels of a status.
Expand Down Expand Up @@ -490,6 +496,15 @@ public boolean isBondsref() {
return this == BONDSREF;
}

/**
* Checks if the character has the {@code SEPPUKU} personnel status.
*
* @return {@code true} if the character has the {@code SEPPUKU} personnel status {@code false} otherwise.
*/
public boolean isSeppuku() {
return this == SEPPUKU;
}

/**
* @return {@code true} if a person is currently absent from the core force, otherwise {@code false}
*/
Expand Down Expand Up @@ -533,8 +548,7 @@ public boolean isDead() {
isMedicalComplications() ||
isPregnancyComplications() ||
isUndetermined() ||
isSuicide() ||
isBondsref();
isSuicide() || isBondsref() || isSeppuku();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@
*
* Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of
* InMediaRes Productions, LLC.
*
* MechWarrior Copyright Microsoft Corporation. MekHQ was created under
* Microsoft's "Game Content Usage Rules"
* <https://www.xbox.com/en-US/developers/rules> and it is not endorsed by or
* affiliated with Microsoft.
*/
package mekhq.campaign.randomEvents.prisoners;

import static java.lang.Math.round;
import static megamek.common.Board.T_SPACE;
import static megamek.common.MiscType.createBeagleActiveProbe;
import static megamek.common.MiscType.createCLImprovedSensors;
Expand All @@ -38,6 +42,7 @@
import static mekhq.campaign.personnel.enums.PersonnelStatus.KIA;
import static mekhq.campaign.personnel.enums.PersonnelStatus.MIA;
import static mekhq.campaign.personnel.enums.PersonnelStatus.POW;
import static mekhq.campaign.personnel.enums.PersonnelStatus.SEPPUKU;
import static mekhq.campaign.randomEvents.prisoners.enums.PrisonerStatus.BECOMING_BONDSMAN;
import static mekhq.campaign.randomEvents.prisoners.enums.PrisonerStatus.PRISONER;
import static mekhq.campaign.randomEvents.prisoners.enums.PrisonerStatus.PRISONER_DEFECTOR;
Expand All @@ -49,6 +54,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import megamek.common.Compute;
import megamek.common.ITechnology;
Expand Down Expand Up @@ -275,7 +281,7 @@ void processPrisoner(Person prisoner, @Nullable Faction capturingFaction, boolea

int bondsmanRoll = d6(1);
if (capturingFaction != null && capturingFaction.isClan()) {
if (isMekHQCaptureStyle && prisoner.isClanPersonnel() && (bondsmanRoll == 1)) {
if (isMekHQCaptureStyle && prisoner.isClanPersonnel() && (bondsmanRoll + d6(1) == 2)) {
Comment on lines 283 to +284
Copy link
Preview
Copilot AI May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider extracting the dice roll calculation (bondsmanRoll + d6(1)) into a clearly named variable to clarify that it simulates a 2d6 roll, which would improve overall readability.

Copilot uses AI. Check for mistakes.

if (isNPC) {
campaign.addReport(getFormattedTextAt(RESOURCE_BUNDLE,
"bondsref.report",
Expand All @@ -297,6 +303,40 @@ void processPrisoner(Person prisoner, @Nullable Faction capturingFaction, boolea
}
return;
}
} else if (capturingFaction != null && capturingFaction.getHonorRating(campaign) == HonorRating.NONE) {
if (bondsmanRoll == 1) {
if (isNPC) {
campaign.addReport(getFormattedTextAt(RESOURCE_BUNDLE,
"bondsref.report",
prisoner.getFullName(),
spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorNegativeHexColor()),
CLOSING_SPAN_TAG));

campaign.removePerson(prisoner);
} else {
prisoner.changeStatus(campaign, today, POW);
}
return;
}
}

if (isMekHQCaptureStyle) {
if (Objects.equals(prisoner.getOriginFaction().getShortName(), "DC")) {
Copy link
Preview
Copilot AI May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The hard-coded faction short name "DC" appears as a magic string; consider defining it as a constant for improved maintainability and clarity.

Copilot uses AI. Check for mistakes.

if (d6(2) == 2) {
if (isNPC) {
campaign.addReport(getFormattedTextAt(RESOURCE_BUNDLE,
"seppuku.report",
prisoner.getFullName(),
spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorNegativeHexColor()),
CLOSING_SPAN_TAG));

campaign.removePerson(prisoner);
} else {
prisoner.changeStatus(campaign, today, SEPPUKU);
}
return;
}
}
}

if (isNPC) {
Expand All @@ -323,7 +363,7 @@ int determineDefectionChance(Person potentialDefector, boolean isNPC) {
int adjustedDefectionChance = DEFECTION_CHANCE;

if (potentialDefector.getOriginFaction().isMercenary()) {
adjustedDefectionChance = (int) round(adjustedDefectionChance * MERCENARY_MULTIPLIER);
adjustedDefectionChance = (int) Math.round(adjustedDefectionChance * MERCENARY_MULTIPLIER);
}

if (potentialDefector.isClanPersonnel()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,23 @@
*
* Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of
* InMediaRes Productions, LLC.
*
* MechWarrior Copyright Microsoft Corporation. MekHQ was created under
* Microsoft's "Game Content Usage Rules"
* <https://www.xbox.com/en-US/developers/rules> and it is not endorsed by or
* affiliated with Microsoft.
*/
package mekhq.campaign.personnel.enums;

import org.junit.jupiter.api.Test;

import java.util.List;

import static mekhq.campaign.personnel.enums.PersonnelStatus.*;
import static mekhq.utilities.MHQInternationalization.isResourceKeyValid;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.List;

import org.junit.jupiter.api.Test;

public class PersonnelStatusTest {
@Test
public void testFromString_ValidStatus() {
Expand Down Expand Up @@ -119,7 +124,9 @@ public void testIsAbsent() {
public void testIsDepartedUnit() {
List<PersonnelStatus> deadStatuses = List.of(KIA, HOMICIDE, WOUNDS, DISEASE, ACCIDENTAL,
NATURAL_CAUSES, OLD_AGE, MEDICAL_COMPLICATIONS, PREGNANCY_COMPLICATIONS, UNDETERMINED,
SUICIDE, BONDSREF);
SUICIDE,
BONDSREF,
SEPPUKU);
List<PersonnelStatus> validStatuses = List.of(RETIRED, RESIGNED, SACKED, DESERTED,
DEFECTED, MISSING, LEFT, ENEMY_BONDSMAN);

Expand All @@ -134,7 +141,9 @@ public void testIsDepartedUnit() {
public void testIsDead() {
List<PersonnelStatus> validStatuses = List.of(KIA, HOMICIDE, WOUNDS, DISEASE, ACCIDENTAL,
NATURAL_CAUSES, OLD_AGE, MEDICAL_COMPLICATIONS, PREGNANCY_COMPLICATIONS, UNDETERMINED,
SUICIDE, BONDSREF);
SUICIDE,
BONDSREF,
SEPPUKU);

for (PersonnelStatus status : PersonnelStatus.values()) {
boolean isDead = validStatuses.contains(status);
Expand All @@ -147,7 +156,10 @@ public void testIsDead() {
public void testIsDeadOrMIA() {
List<PersonnelStatus> validStatuses = List.of(KIA, HOMICIDE, WOUNDS, DISEASE, ACCIDENTAL,
NATURAL_CAUSES, OLD_AGE, MEDICAL_COMPLICATIONS, PREGNANCY_COMPLICATIONS, UNDETERMINED,
SUICIDE, BONDSREF, MIA);
SUICIDE,
BONDSREF,
MIA,
SEPPUKU);

for (PersonnelStatus status : PersonnelStatus.values()) {
boolean isDeadOrMIA = validStatuses.contains(status);
Expand Down
Loading
0