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
4 changes: 2 additions & 2 deletions MekHQ/src/mekhq/campaign/Campaign.java
Original file line number Diff line number Diff line change
Expand Up @@ -4537,15 +4537,15 @@ private void processReputationChanges() {
public int getInitiativeBonus() {
return initiativeBonus;
}

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

public void applyInitiativeBonus(int bonus) {
if (bonus > initiativeMaxBonus) {
initiativeMaxBonus = bonus;
}
}
if ((bonus + initiativeBonus) > initiativeMaxBonus) {
initiativeBonus = initiativeMaxBonus;
} else {
Expand Down
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;
};
}
}
54 changes: 45 additions & 9 deletions MekHQ/src/mekhq/campaign/stratcon/StratconCampaignState.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@
*/
package mekhq.campaign.stratcon;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.xml.namespace.QName;

import org.w3c.dom.Node;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.Marshaller;
Expand All @@ -34,8 +26,17 @@
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;

/**
* Contract-level state object for a StratCon campaign.
Expand Down Expand Up @@ -63,7 +64,9 @@ public class StratconCampaignState {

@XmlElementWrapper(name = "campaignTracks")
@XmlElement(name = "campaignTrack")
private List<StratconTrackState> tracks;
private final List<StratconTrackState> tracks;

private List<LocalDate> weeklyScenarios;

@XmlTransient
public AtBContract getContract() {
Expand All @@ -76,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 @@ -104,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 @@ -239,4 +259,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