Skip to content

Commit

Permalink
Merge pull request #5257 from DM0000/InitiativeBonus
Browse files Browse the repository at this point in the history
Add Persistent Initiative Bonus to campaign
  • Loading branch information
HammerGS authored Nov 29, 2024
2 parents 5530d86 + 84e5f32 commit 3375380
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions MekHQ/src/mekhq/AtBGameThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public void run() {

client.getLocalPlayer().setCamouflage(app.getCampaign().getCamouflage().clone());
client.getLocalPlayer().setColour(app.getCampaign().getColour());
client.getLocalPlayer().setConstantInitBonus(campaign.getInitiativeBonus());

if (started) {
client.getGame().getOptions().loadOptions();
Expand Down
1 change: 1 addition & 0 deletions MekHQ/src/mekhq/GameThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ public void run() {
client.getLocalPlayer().setStartingAnyNWy(scenario.getStartingAnyNWy());
client.getLocalPlayer().setStartingAnySEx(scenario.getStartingAnySEx());
client.getLocalPlayer().setStartingAnySEy(scenario.getStartingAnySEy());
client.getLocalPlayer().setConstantInitBonus(campaign.getInitiativeBonus());

client.getLocalPlayer().setTeam(1);

Expand Down
19 changes: 18 additions & 1 deletion MekHQ/src/mekhq/campaign/Campaign.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ public class Campaign implements ITechManager {
private int crimeRating;
private int crimePirateModifier;
private LocalDate dateOfLastCrime;
private int initiativeBonus;
private final CampaignSummary campaignSummary;
private final Quartermaster quartermaster;
private StoryArc storyArc;
Expand Down Expand Up @@ -309,6 +310,7 @@ public Campaign() {
crimeRating = 0;
crimePirateModifier = 0;
dateOfLastCrime = null;
initiativeBonus = 0;
setRankSystemDirect(Ranks.getRankSystemFromCode(Ranks.DEFAULT_SYSTEM_CODE));
forces = new Force(name);
forceIds.put(0, forces);
Expand Down Expand Up @@ -4479,6 +4481,21 @@ private void processReputationChanges() {
}
}

public int getInitiativeBonus(){
return initiativeBonus;
}
public void setInitiativeBonus(int bonus){
initiativeBonus = bonus;
}

public void initiativeBonusIncrement(boolean change){
if(change){
setInitiativeBonus(++initiativeBonus);
}else{
setInitiativeBonus(--initiativeBonus);
}
}

/**
* This method processes the random dependents for a campaign. It shuffles the active dependents list and performs
* actions based on the campaign options and unit rating modifiers.
Expand Down Expand Up @@ -5503,7 +5520,7 @@ public void writeToXML(final PrintWriter pw) {
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "lastMissionId", lastMissionId);
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "lastScenarioId", lastScenarioId);
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "calendar", getLocalDate());

MHQXMLUtility.writeSimpleXMLTag(pw, indent, "InitiativeBonus", initiativeBonus);
MHQXMLUtility.writeSimpleXMLOpenTag(pw, indent++, "nameGen");
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "faction", RandomNameGenerator.getInstance().getChosenFaction());
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "percentFemale", RandomGenderGenerator.getPercentFemale());
Expand Down
2 changes: 2 additions & 0 deletions MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@ private static void processInfoNode(Campaign retVal, Node wni, Version version)
retVal.setRetainerStartDate(LocalDate.parse(wn.getTextContent()));
} else if (xn.equalsIgnoreCase("crimeRating")) {
retVal.setCrimeRating(Integer.parseInt(wn.getTextContent()));
} else if (xn.equalsIgnoreCase("initiativeBonus")) {
retVal.setInitiativeBonus(Integer.parseInt(wn.getTextContent()));
} else if (xn.equalsIgnoreCase("crimePirateModifier")) {
retVal.setCrimePirateModifier(Integer.parseInt(wn.getTextContent()));
} else if (xn.equalsIgnoreCase("dateOfLastCrime")) {
Expand Down

0 comments on commit 3375380

Please sign in to comment.