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

Linked Scenarios/Interception #5946

Merged
merged 15 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from 7 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
242 changes: 147 additions & 95 deletions MekHQ/src/mekhq/campaign/Campaign.java

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions MekHQ/src/mekhq/campaign/mission/Scenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public class Scenario implements IPlayerSettings {
protected List<BotForce> botForces;
protected List<BotForceStub> botForcesStubs;

// linked Interception Scenario
private int linkedScenarioID;

// stores external id of bot forces
private Map<String, Entity> externalIDLookup;

Expand Down Expand Up @@ -150,6 +153,7 @@ public Scenario(String name) {
botForces = new ArrayList<>();
botForcesStubs = new ArrayList<>();
externalIDLookup = new HashMap<>();
linkedScenarioID = 0;

light = Light.DAY;
weather = Weather.CLEAR;
Expand Down Expand Up @@ -224,6 +228,14 @@ public void setDate(final @Nullable LocalDate date) {
this.date = date;
}

public int getLinkedScenario() {
return linkedScenarioID;
}

public void setlinkedScenarioID(int ScenarioID) {
linkedScenarioID = ScenarioID;
}

public boolean hasObjectives() {
return (scenarioObjectives != null) && !scenarioObjectives.isEmpty();
}
Expand Down Expand Up @@ -858,6 +870,7 @@ public boolean includesRequiredUnits(Campaign c) {
}

public boolean canStartScenario(Campaign c) {

if (!getStatus().isCurrent()) {
return false;
}
Expand Down Expand Up @@ -890,6 +903,7 @@ protected int writeToXMLBegin(final PrintWriter pw, int indent) {
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "startingAnySEy", startingAnySEy);
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "status", getStatus().name());
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "id", id);
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "linkedScenarioID", linkedScenarioID);
if (null != stub) {
stub.writeToXML(pw, indent);
} else {
Expand Down Expand Up @@ -1025,6 +1039,8 @@ public static Scenario generateInstanceFromXML(Node wn, Campaign c, Version vers
retVal.setReport(wn2.getTextContent());
} else if (wn2.getNodeName().equalsIgnoreCase("forceStub")) {
retVal.stub = ForceStub.generateInstanceFromXML(wn2, version);
} else if (wn2.getNodeName().equalsIgnoreCase("linkedScenarioID")) {
retVal.linkedScenarioID = Integer.parseInt(wn2.getTextContent());
} else if (wn2.getNodeName().equalsIgnoreCase("date")) {
retVal.date = MHQXMLUtility.parseDate(wn2.getTextContent().trim());
} else if (wn2.getNodeName().equalsIgnoreCase("cloaked")) {
Expand Down
Loading
Loading