|
65 | 65 | import static mekhq.campaign.personnel.skills.SkillType.*; |
66 | 66 | import static mekhq.campaign.randomEvents.personalities.PersonalityController.generateReasoning; |
67 | 67 | import static mekhq.campaign.randomEvents.personalities.PersonalityController.getTraitIndex; |
| 68 | +import static mekhq.utilities.MHQInternationalization.getFormattedText; |
68 | 69 | import static mekhq.utilities.MHQInternationalization.getFormattedTextAt; |
69 | 70 | import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG; |
70 | 71 | import static mekhq.utilities.ReportingUtilities.getNegativeColor; |
@@ -396,6 +397,7 @@ public class Person { |
396 | 397 | // region Flags |
397 | 398 | private boolean clanPersonnel; |
398 | 399 | private boolean commander; |
| 400 | + private boolean secondInCommand; |
399 | 401 | private boolean divorceable; |
400 | 402 | private boolean founder; // +1 share if using shares system |
401 | 403 | private boolean immortal; |
@@ -636,6 +638,7 @@ public Person(final String preNominal, final String givenName, final String surn |
636 | 638 | // region Flags |
637 | 639 | setClanPersonnel(originFaction.isClan()); |
638 | 640 | setCommander(false); |
| 641 | + setSecondInCommand(false); |
639 | 642 | setDivorceable(true); |
640 | 643 | setFounder(false); |
641 | 644 | setImmortal(false); |
@@ -1620,6 +1623,28 @@ public void changeStatus(final Campaign campaign, final LocalDate today, final P |
1620 | 1623 | } |
1621 | 1624 |
|
1622 | 1625 | setCommander(false); |
| 1626 | + |
| 1627 | + // promote second in command |
| 1628 | + Person secondInCommand = campaign.getSecondInCommand(); |
| 1629 | + if (secondInCommand != null) { |
| 1630 | + secondInCommand.setSecondInCommand(false); |
| 1631 | + secondInCommand.setCommander(true); |
| 1632 | + |
| 1633 | + String secondInCommandHyperlink = secondInCommand.getHyperlinkedFullTitle(); |
| 1634 | + campaign.addReport(PERSONNEL, getFormattedText("removedSecondInCommand.format", |
| 1635 | + secondInCommandHyperlink)); |
| 1636 | + campaign.addReport(PERSONNEL, String.format(resources.getString("setAsCommander.format"), |
| 1637 | + secondInCommandHyperlink)); |
| 1638 | + |
| 1639 | + campaign.personUpdated(secondInCommand); |
| 1640 | + } |
| 1641 | + } |
| 1642 | + |
| 1643 | + // release the second-in-command flag. |
| 1644 | + if (isSecondInCommand() && status.isDepartedUnit()) { |
| 1645 | + setSecondInCommand(false); |
| 1646 | + campaign.addReport(PERSONNEL, getFormattedText("removedSecondInCommand.format", |
| 1647 | + getHyperlinkedFullTitle())); |
1623 | 1648 | } |
1624 | 1649 |
|
1625 | 1650 | // clean up the save entry |
@@ -3003,6 +3028,14 @@ public void setCommander(final boolean commander) { |
3003 | 3028 | this.commander = commander; |
3004 | 3029 | } |
3005 | 3030 |
|
| 3031 | + public boolean isSecondInCommand() { |
| 3032 | + return secondInCommand; |
| 3033 | + } |
| 3034 | + |
| 3035 | + public void setSecondInCommand(final boolean secondInCommand) { |
| 3036 | + this.secondInCommand = secondInCommand; |
| 3037 | + } |
| 3038 | + |
3006 | 3039 | public boolean isDivorceable() { |
3007 | 3040 | return divorceable; |
3008 | 3041 | } |
@@ -3654,6 +3687,7 @@ public int writeToXMLHeadless(PrintWriter pw, int indent, Campaign campaign) { |
3654 | 3687 | // region Flags |
3655 | 3688 | MHQXMLUtility.writeSimpleXMLTag(pw, indent, "clanPersonnel", isClanPersonnel()); |
3656 | 3689 | MHQXMLUtility.writeSimpleXMLTag(pw, indent, "commander", commander); |
| 3690 | + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "secondInCommand", secondInCommand); |
3657 | 3691 | MHQXMLUtility.writeSimpleXMLTag(pw, indent, "divorceable", divorceable); |
3658 | 3692 | MHQXMLUtility.writeSimpleXMLTag(pw, indent, "founder", founder); |
3659 | 3693 | MHQXMLUtility.writeSimpleXMLTag(pw, indent, "immortal", immortal); |
@@ -4264,6 +4298,8 @@ public static Person generateInstanceFromXML(Node wn, Campaign campaign, Version |
4264 | 4298 | person.setClanPersonnel(Boolean.parseBoolean(wn2.getTextContent().trim())); |
4265 | 4299 | } else if (nodeName.equalsIgnoreCase("commander")) { |
4266 | 4300 | person.setCommander(Boolean.parseBoolean(wn2.getTextContent().trim())); |
| 4301 | + } else if (nodeName.equalsIgnoreCase("secondInCommand")) { |
| 4302 | + person.setSecondInCommand(Boolean.parseBoolean(wn2.getTextContent().trim())); |
4267 | 4303 | } else if (nodeName.equalsIgnoreCase("divorceable")) { |
4268 | 4304 | person.setDivorceable(Boolean.parseBoolean(wn2.getTextContent().trim())); |
4269 | 4305 | } else if (nodeName.equalsIgnoreCase("founder")) { |
|
0 commit comments