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

Removed Predictable Scenario Generation Schedule #5286

Merged
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,11 @@ public static LayeredForceIconOperationalStatus determineLayeredForceIconOperati
return NOT_OPERATIONAL;
}

switch (unit.getDamageState()) {
case Entity.DMG_NONE:
return FULLY_OPERATIONAL;
case Entity.DMG_LIGHT:
case Entity.DMG_MODERATE:
return SUBSTANTIALLY_OPERATIONAL;
case Entity.DMG_HEAVY:
case Entity.DMG_CRIPPLED:
return MARGINALLY_OPERATIONAL;
default:
return NOT_OPERATIONAL;
}
return switch (unit.getDamageState()) {
case Entity.DMG_NONE -> FULLY_OPERATIONAL;
case Entity.DMG_LIGHT, Entity.DMG_MODERATE -> SUBSTANTIALLY_OPERATIONAL;
case Entity.DMG_HEAVY, Entity.DMG_CRIPPLED -> MARGINALLY_OPERATIONAL;
default -> NOT_OPERATIONAL;
};
}
}
38 changes: 38 additions & 0 deletions MekHQ/src/mekhq/campaign/stratcon/StratconCampaignState.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlTransient;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import megamek.logging.MMLogger;
import mekhq.campaign.mission.AtBContract;
import org.w3c.dom.Node;

import javax.xml.namespace.QName;
import java.io.PrintWriter;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -63,6 +66,8 @@ public class StratconCampaignState {
@XmlElement(name = "campaignTrack")
private final List<StratconTrackState> tracks;

private List<LocalDate> weeklyScenarios;

@XmlTransient
public AtBContract getContract() {
return contract;
Expand All @@ -74,10 +79,12 @@ public void setContract(AtBContract contract) {

public StratconCampaignState() {
tracks = new ArrayList<>();
weeklyScenarios = new ArrayList<>();
}

public StratconCampaignState(AtBContract contract) {
tracks = new ArrayList<>();
weeklyScenarios = new ArrayList<>();
setContract(contract);
}

Expand All @@ -102,6 +109,21 @@ public void addTrack(StratconTrackState track) {
tracks.add(track);
}

@XmlJavaTypeAdapter(value = LocalDateAdapter.class)
@XmlElementWrapper(name = "weeklyScenarios")
@XmlElement(name = "weeklyScenario")
public List<LocalDate> getWeeklyScenarios() {
return weeklyScenarios;
}

public void addWeeklyScenario(LocalDate weeklyScenario) {
weeklyScenarios.add(weeklyScenario);
}

public void setWeeklyScenarios(final List<LocalDate> weeklyScenarios) {
this.weeklyScenarios = weeklyScenarios;
}

public int getSupportPoints() {
return supportPoints;
}
Expand Down Expand Up @@ -232,4 +254,20 @@ public static StratconCampaignState Deserialize(Node xmlNode) {

return resultingCampaignState;
}

/**
* This adapter provides a way to convert between a LocalDate and the ISO-8601 string
* representation of the date that is used for XML marshaling and unmarshalling in JAXB.
*/
public static class LocalDateAdapter extends XmlAdapter<String, LocalDate> {
@Override
public String marshal(LocalDate date) {
return date.toString();
}

@Override
public LocalDate unmarshal(String date) throws Exception {
return LocalDate.parse(date);
}
}
}
Loading
Loading