diff --git a/MekHQ/src/mekhq/AtBGameThread.java b/MekHQ/src/mekhq/AtBGameThread.java index 85375bcd86..f68fccffe5 100644 --- a/MekHQ/src/mekhq/AtBGameThread.java +++ b/MekHQ/src/mekhq/AtBGameThread.java @@ -156,13 +156,13 @@ public void run() { PlanetaryConditions planetaryConditions = new PlanetaryConditions(); planetaryConditions.setLight(scenario.getLight()); planetaryConditions.setWeather(scenario.getWeather()); - planetaryConditions.setWindStrength(scenario.getWind()); + planetaryConditions.setWind(scenario.getWind()); planetaryConditions.setFog(scenario.getFog()); planetaryConditions.setAtmosphere(scenario.getAtmosphere()); planetaryConditions.setGravity(scenario.getGravity()); - planetaryConditions.setEMI(scenario.usesEMI()); - planetaryConditions.setBlowingSand(scenario.usesBlowingSand()); - planetaryConditions.setTemperature(scenario.getTemperature()); + planetaryConditions.setEMI(scenario.getEMI()); + planetaryConditions.setBlowingSand(scenario.getBlowingSand()); + planetaryConditions.setTemperature(scenario.getModifiedTemperature()); client.sendPlanetaryConditions(planetaryConditions); Thread.sleep(MekHQ.getMHQOptions().getStartGameDelay()); diff --git a/MekHQ/src/mekhq/GameThread.java b/MekHQ/src/mekhq/GameThread.java index 72404cf2ac..63596cf135 100644 --- a/MekHQ/src/mekhq/GameThread.java +++ b/MekHQ/src/mekhq/GameThread.java @@ -175,17 +175,17 @@ public void run() { PlanetaryConditions planetaryConditions = new PlanetaryConditions(); planetaryConditions.setLight(scenario.getLight()); planetaryConditions.setWeather(scenario.getWeather()); - planetaryConditions.setWindStrength(scenario.getWind()); + planetaryConditions.setWind(scenario.getWind()); planetaryConditions.setFog(scenario.getFog()); planetaryConditions.setAtmosphere(scenario.getAtmosphere()); - planetaryConditions.setTemperature(scenario.getTemperature()); + planetaryConditions.setTemperature(scenario.getModifiedTemperature()); planetaryConditions.setGravity(scenario.getGravity()); - planetaryConditions.setEMI(scenario.usesEMI()); - planetaryConditions.setBlowingSand(scenario.usesBlowingSand()); + planetaryConditions.setEMI(scenario.getEMI()); + planetaryConditions.setBlowingSand(scenario.getBlowingSand()); planetaryConditions.setShiftingWindDirection(scenario.canWindShiftDirection()); planetaryConditions.setShiftingWindStrength(scenario.canWindShiftStrength()); - planetaryConditions.setMaxWindStrength(scenario.getMaxWindStrength()); - planetaryConditions.setMinWindStrength(scenario.getMinWindStrength()); + planetaryConditions.setWindMax(scenario.getMaxWindStrength()); + planetaryConditions.setWindMin(scenario.getMinWindStrength()); client.sendPlanetaryConditions(planetaryConditions); Thread.sleep(MekHQ.getMHQOptions().getStartGameDelay()); diff --git a/MekHQ/src/mekhq/adapter/PressureAdapter.java b/MekHQ/src/mekhq/adapter/PressureAdapter.java index 87b2f09cd4..9fc8f04d4a 100644 --- a/MekHQ/src/mekhq/adapter/PressureAdapter.java +++ b/MekHQ/src/mekhq/adapter/PressureAdapter.java @@ -20,27 +20,28 @@ import jakarta.xml.bind.annotation.adapters.XmlAdapter; import megamek.common.PlanetaryConditions; +import megamek.common.enums.Atmosphere; public class PressureAdapter extends XmlAdapter { @Override public Integer unmarshal(String v) throws Exception { switch (v) { - case "Vacuum": return PlanetaryConditions.ATMO_VACUUM; - case "Trace": return PlanetaryConditions.ATMO_TRACE; + case "Vacuum": return Atmosphere.VACUUM.ordinal(); + case "Trace": return Atmosphere.TRACE.ordinal(); case "Thin": - case "Low": return PlanetaryConditions.ATMO_THIN; + case "Low": return Atmosphere.THIN.ordinal(); case "Standard": - case "Normal": return PlanetaryConditions.ATMO_STANDARD; - case "High": return PlanetaryConditions.ATMO_HIGH; - case "Very High": return PlanetaryConditions.ATMO_VHIGH; + case "Normal": return Atmosphere.STANDARD.ordinal(); + case "High": return Atmosphere.HIGH.ordinal(); + case "Very High": return Atmosphere.VERY_HIGH.ordinal(); default: return null; } } @Override public String marshal(Integer v) throws Exception { - return PlanetaryConditions.getAtmosphereDisplayableName(v); + return Atmosphere.getAtmosphere(v).toString(); } } diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index 80c849f85d..321b779ac4 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -30,6 +30,7 @@ import megamek.codeUtilities.StringUtility; import megamek.common.*; import megamek.common.annotations.Nullable; +import megamek.common.enums.Atmosphere; import megamek.common.enums.Gender; import megamek.common.enums.SkillLevel; import megamek.common.icons.Camouflage; @@ -784,7 +785,7 @@ private static void setPlanetaryConditions(AtBDynamicScenario scenario, AtBContr PlanetarySystem pSystem = Systems.getInstance().getSystemById(mission.getSystemId()); Planet p = pSystem.getPrimaryPlanet(); if (null != p) { - int atmosphere = ObjectUtility.nonNull(p.getPressure(campaign.getLocalDate()), scenario.getAtmosphere()); + Atmosphere atmosphere = Atmosphere.getAtmosphere(ObjectUtility.nonNull(p.getPressure(campaign.getLocalDate()), scenario.getAtmosphere().ordinal())); float gravity = ObjectUtility.nonNull(p.getGravity(), scenario.getGravity()).floatValue(); int temperature = ObjectUtility.nonNull(p.getTemperature(campaign.getLocalDate()), scenario.getTemperature()); diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index ba6cee2006..200a6cd082 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -26,7 +26,8 @@ import megamek.common.*; import megamek.common.annotations.Nullable; import megamek.common.EntityWeightClass; -import megamek.common.enums.SkillLevel; +import megamek.common.enums.*; +import megamek.common.enums.Atmosphere; import megamek.common.icons.Camouflage; import megamek.common.options.OptionsConstants; import mekhq.MHQConstants; @@ -222,11 +223,11 @@ public void initialize(Campaign c, Lance lance, boolean attacker, LocalDate date } } - light = PlanetaryConditions.L_DAY; - weather = PlanetaryConditions.WE_NONE; - wind = PlanetaryConditions.WI_NONE; - fog = PlanetaryConditions.FOG_NONE; - atmosphere = PlanetaryConditions.ATMO_STANDARD; + light = Light.DAY; + weather = Weather.CLEAR; + wind = Wind.CALM; + fog = Fog.FOG_NONE; + atmosphere = Atmosphere.STANDARD; gravity = (float) 1.0; deploymentDelay = 0; setDate(date); @@ -324,7 +325,7 @@ private int rollCondition(int[] odds) { return condition; } - private int rollLightCondition() { + private Light rollLightCondition() { int[] odds; String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); @@ -369,19 +370,15 @@ private int rollLightCondition() { odds = new int[]{50,20,10,10,10}; break; default: - return PlanetaryConditions.L_DAY; + return Light.DAY; } - int light = rollCondition(odds); - - if (light < PlanetaryConditions.L_DAY || light > PlanetaryConditions.L_PITCH_BLACK) { - return PlanetaryConditions.L_DAY; - } + Light light = Light.getLight(rollCondition(odds)); return light; } - private int rollWindCondition() { + private Wind rollWindCondition() { int[] odds; String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); @@ -426,23 +423,19 @@ private int rollWindCondition() { odds = new int[]{50,15,15,9,5,4,2}; break; default: - return PlanetaryConditions.WI_NONE; + return Wind.CALM; } - int wind = rollCondition(odds); + Wind wind = Wind.getWind(rollCondition(odds)); - if (wind < PlanetaryConditions.WI_NONE || wind > PlanetaryConditions.WI_TORNADO_F4) { - return PlanetaryConditions.WI_NONE; - } - - if (!WeatherRestriction.IsWindRestricted(wind, getAtmosphere(), getTemperature())) { + if (!WeatherRestriction.IsWindRestricted(wind.ordinal(), getAtmosphere().ordinal(), getTemperature())) { return wind; } else { - return PlanetaryConditions.WI_NONE; + return Wind.CALM; } } - private int rollWeatherCondition() { + private Weather rollWeatherCondition() { int[] odds; String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); @@ -465,6 +458,9 @@ private int rollWeatherCondition() { case "HotMountainsWet": case "HotSea": case "Jungle": + // hot wet + odds = new int[]{47,16,12,10,8,5,1,0,0,0,1,0}; + break; case "Sea": case "Swamp": // wet @@ -492,23 +488,19 @@ private int rollWeatherCondition() { odds = new int[]{87,2,1,1,1,1,2,1,1,1,1,1}; break; default: - return PlanetaryConditions.WE_NONE; + return Weather.CLEAR; } - int weather = rollCondition(odds); + Weather weather = Weather.getWeather(rollCondition(odds)); - if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { - return PlanetaryConditions.WE_NONE; - } - - if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { + if (!WeatherRestriction.IsWeatherRestricted(weather.ordinal(), getAtmosphere().ordinal(), getTemperature())) { return weather; } else { - return PlanetaryConditions.WE_NONE; + return Weather.CLEAR; } } - private int rollFogCondition() { + private Fog rollFogCondition() { int[] odds; String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); @@ -548,29 +540,19 @@ private int rollFogCondition() { odds = new int[]{60,20,20}; break; default: - return PlanetaryConditions.FOG_NONE; + return Fog.FOG_NONE; } - int fog = rollCondition(odds); - - if (fog < PlanetaryConditions.FOG_NONE || fog > PlanetaryConditions.FOG_HEAVY) { - return PlanetaryConditions.FOG_NONE; - } + Fog fog = Fog.getFog(rollCondition(odds)); - if (!WeatherRestriction.IsFogRestricted(fog, getAtmosphere(), getTemperature())) { + if (!WeatherRestriction.IsFogRestricted(fog.ordinal(), getAtmosphere().ordinal(), getTemperature())) { return fog; } else { - return PlanetaryConditions.FOG_NONE; + return Fog.FOG_NONE; } } - private boolean rollBlowingSandCondition(int wind, int weather, int fog) { - if (weather != PlanetaryConditions.WE_NONE - || fog != PlanetaryConditions.FOG_NONE - || wind < PlanetaryConditions.WI_MOD_GALE) { - return false; - } - + private BlowingSand rollBlowingSandCondition() { int[] odds; String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); @@ -606,13 +588,13 @@ private boolean rollBlowingSandCondition(int wind, int weather, int fog) { odds = new int[]{40,60}; break; default: - return false; + return BlowingSand.BLOWING_SAND_NONE; } - return rollCondition(odds) == 1; + return rollCondition(odds) == 1 ? BlowingSand.BLOWING_SAND : BlowingSand.BLOWING_SAND_NONE; } - private boolean rollEMICondition() { + private EMI rollEMICondition() { int[] odds; String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); @@ -640,10 +622,14 @@ private boolean rollEMICondition() { odds = new int[]{90,10}; break; default: - return false; + return EMI.EMI_NONE; } - return rollCondition(odds) == 1; + if (getAtmosphere().isDenserThan(Atmosphere.THIN)) { + return rollCondition(odds) == 1 ? EMI.EMI : EMI.EMI_NONE; + } else { + return EMI.EMI_NONE; + } } public void setLightConditions() { @@ -657,12 +643,18 @@ public void setWeather() { return; } - int wind = rollWindCondition(); - int weather = rollWeatherCondition(); - int fog = rollFogCondition(); - boolean blowingSand = rollBlowingSandCondition(wind, weather, fog); - boolean emi = rollEMICondition(); + Wind wind = rollWindCondition(); + Weather weather = rollWeatherCondition(); + Fog fog = rollFogCondition(); + BlowingSand blowingSand = rollBlowingSandCondition(); + EMI emi = rollEMICondition(); + + int temp = getTemperature(); + temp = PlanetaryConditions.setTempFromWeather(weather, temp); + wind = PlanetaryConditions.setWindFromWeather(weather, wind); + wind = PlanetaryConditions.setWindFromBlowingSand(blowingSand, wind); + setModifiedTemperature(temp); setWind(wind); setWeather(weather); setFog(fog); @@ -676,7 +668,7 @@ public void setPlanetaryConditions(Mission mission, Campaign campaign) { //assume primary planet for now Planet p = psystem.getPrimaryPlanet(); if (null != p) { - setAtmosphere(ObjectUtility.nonNull(p.getPressure(campaign.getLocalDate()), getAtmosphere())); + setAtmosphere(Atmosphere.getAtmosphere(ObjectUtility.nonNull(p.getPressure(campaign.getLocalDate()), getAtmosphere().ordinal()))); setGravity(ObjectUtility.nonNull(p.getGravity(), getGravity()).floatValue()); } } diff --git a/MekHQ/src/mekhq/campaign/mission/Scenario.java b/MekHQ/src/mekhq/campaign/mission/Scenario.java index 58196a1e51..951859d0c4 100644 --- a/MekHQ/src/mekhq/campaign/mission/Scenario.java +++ b/MekHQ/src/mekhq/campaign/mission/Scenario.java @@ -28,6 +28,7 @@ import megamek.common.MapSettings; import megamek.common.PlanetaryConditions; import megamek.common.annotations.Nullable; +import megamek.common.enums.*; import mekhq.MekHQ; import mekhq.utilities.MHQXMLUtility; import mekhq.campaign.Campaign; @@ -97,19 +98,20 @@ public class Scenario { private boolean usingFixedMap; /** planetary conditions parameters **/ - protected int light; - protected int weather; - protected int wind; - protected int fog; - protected int atmosphere; + protected Light light; + protected Weather weather; + protected Wind wind; + protected Fog fog; + protected Atmosphere atmosphere; private int temperature; + private int modifiedTemperature; protected float gravity; - private boolean emi; - private boolean blowingSand; + private EMI emi; + private BlowingSand blowingSand; private boolean shiftWindDirection; private boolean shiftWindStrength; - private int maxWindStrength; - private int minWindStrength; + private Wind maxWindStrength; + private Wind minWindStrength; /** player starting position **/ private int start; @@ -139,19 +141,19 @@ public Scenario(String n) { botForcesStubs = new ArrayList<>(); externalIDLookup = new HashMap<>(); - light = PlanetaryConditions.L_DAY; - weather = PlanetaryConditions.WE_NONE; - wind = PlanetaryConditions.WI_NONE; - fog = PlanetaryConditions.FOG_NONE; - atmosphere = PlanetaryConditions.ATMO_STANDARD; + light = Light.DAY; + weather = Weather.CLEAR; + wind = Wind.CALM; + fog = Fog.FOG_NONE; + atmosphere = Atmosphere.STANDARD; temperature = 25; gravity = (float) 1.0; - emi = false; - blowingSand = false; + emi = EMI.EMI_NONE; + blowingSand = BlowingSand.BLOWING_SAND_NONE; shiftWindDirection = false; shiftWindStrength = false; - maxWindStrength = PlanetaryConditions.WI_TORNADO_F4; - minWindStrength = PlanetaryConditions.WI_NONE; + maxWindStrength = Wind.TORNADO_F4; + minWindStrength = Wind.CALM; hasTrack = false; } @@ -283,43 +285,43 @@ public void setUsingFixedMap(boolean usingFixedMap) { this.usingFixedMap = usingFixedMap; } - public int getLight() { + public Light getLight() { return light; } - public void setLight(int light) { + public void setLight(Light light) { this.light = light; } - public int getWeather() { + public Weather getWeather() { return weather; } - public void setWeather(int weather) { + public void setWeather(Weather weather) { this.weather = weather; } - public int getWind() { + public Wind getWind() { return wind; } - public void setWind(int wind) { + public void setWind(Wind wind) { this.wind = wind; } - public int getFog() { + public Fog getFog() { return fog; } - public void setFog(int fog) { + public void setFog(Fog fog) { this.fog = fog; } - public int getAtmosphere() { + public Atmosphere getAtmosphere() { return atmosphere; } - public void setAtmosphere(int atmosphere) { + public void setAtmosphere(Atmosphere atmosphere) { this.atmosphere = atmosphere; } @@ -331,6 +333,14 @@ public void setTemperature(int temperature) { this.temperature = temperature; } + public int getModifiedTemperature() { + return modifiedTemperature; + } + + public void setModifiedTemperature(int modifiedTemperature) { + this.modifiedTemperature = modifiedTemperature; + } + public float getGravity() { return gravity; } @@ -339,27 +349,19 @@ public void setGravity(float gravity) { this.gravity = gravity; } - public boolean usesEMI() { - return emi; - } - - public void setEMI(boolean emi) { + public void setEMI(EMI emi) { this.emi = emi; } - public boolean getEMI() { + public EMI getEMI() { return emi; } - public boolean usesBlowingSand() { - return blowingSand; - } - - public void setBlowingSand(boolean blow) { + public void setBlowingSand(BlowingSand blow) { this.blowingSand = blow; } - public boolean getBlowingSand() { + public BlowingSand getBlowingSand() { return blowingSand; } @@ -371,13 +373,13 @@ public boolean getBlowingSand() { public void setShiftWindStrength(boolean b) { this.shiftWindStrength = b; } - public int getMaxWindStrength() { return maxWindStrength; } + public Wind getMaxWindStrength() { return maxWindStrength; } - public void setMaxWindStrength(int strength) { this.maxWindStrength = strength; } + public void setMaxWindStrength(Wind strength) { this.maxWindStrength = strength; } - public int getMinWindStrength() { return minWindStrength; } + public Wind getMinWindStrength() { return minWindStrength; } - public void setMinWindStrength(int strength) { this.minWindStrength = strength; } + public void setMinWindStrength(Wind strength) { this.minWindStrength = strength; } public ScenarioDeploymentLimit getDeploymentLimit() { return deploymentLimit; @@ -809,19 +811,19 @@ protected int writeToXMLBegin(final PrintWriter pw, int indent) { MHQXMLUtility.writeSimpleXMLTag(pw, indent, "usingFixedMap", isUsingFixedMap()); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "mapSize", mapSizeX, mapSizeY); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "map", map); - MHQXMLUtility.writeSimpleXMLTag(pw, indent, "light", light); - MHQXMLUtility.writeSimpleXMLTag(pw, indent, "weather", weather); - MHQXMLUtility.writeSimpleXMLTag(pw, indent, "wind", wind); - MHQXMLUtility.writeSimpleXMLTag(pw, indent, "fog", fog); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "light", light.ordinal()); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "weather", weather.ordinal()); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "wind", wind.ordinal()); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "fog", fog.ordinal()); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "temperature", temperature); - MHQXMLUtility.writeSimpleXMLTag(pw, indent, "atmosphere", atmosphere); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "atmosphere", atmosphere.ordinal()); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "gravity", gravity); - MHQXMLUtility.writeSimpleXMLTag(pw, indent, "emi", emi); - MHQXMLUtility.writeSimpleXMLTag(pw, indent, "blowingSand", blowingSand); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "emi", emi.ordinal()); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "blowingSand", blowingSand.ordinal()); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "shiftWindDirection", shiftWindDirection); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "shiftWindStrength", shiftWindStrength); - MHQXMLUtility.writeSimpleXMLTag(pw, indent, "maxWindStrength", maxWindStrength); - MHQXMLUtility.writeSimpleXMLTag(pw, indent, "minWindStrength", minWindStrength); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "maxWindStrength", maxWindStrength.ordinal()); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "minWindStrength", minWindStrength.ordinal()); return indent; } @@ -955,31 +957,33 @@ public static Scenario generateInstanceFromXML(Node wn, Campaign c, Version vers } else if (wn2.getNodeName().equalsIgnoreCase("start")) { retVal.start = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("light")) { - retVal.light = Integer.parseInt(wn2.getTextContent()); + retVal.light = Light.getLight(Integer.parseInt(wn2.getTextContent())); } else if (wn2.getNodeName().equalsIgnoreCase("weather")) { - retVal.weather = Integer.parseInt(wn2.getTextContent()); + retVal.weather = Weather.getWeather(Integer.parseInt(wn2.getTextContent())); } else if (wn2.getNodeName().equalsIgnoreCase("wind")) { - retVal.wind = Integer.parseInt(wn2.getTextContent()); + retVal.wind = Wind.getWind(Integer.parseInt(wn2.getTextContent())); } else if (wn2.getNodeName().equalsIgnoreCase("fog")) { - retVal.fog = Integer.parseInt(wn2.getTextContent()); + retVal.fog = Fog.getFog(Integer.parseInt(wn2.getTextContent())); } else if (wn2.getNodeName().equalsIgnoreCase("atmosphere")) { - retVal.atmosphere = Integer.parseInt(wn2.getTextContent()); + retVal.atmosphere = Atmosphere.getAtmosphere(Integer.parseInt(wn2.getTextContent())); } else if (wn2.getNodeName().equalsIgnoreCase("temperature")) { retVal.temperature = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("gravity")) { retVal.gravity = Float.parseFloat(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("emi")) { - retVal.emi = Boolean.parseBoolean(wn2.getTextContent()); + EMI emi = Boolean.parseBoolean(wn2.getTextContent()) ? EMI.EMI : EMI.EMI_NONE; + retVal.emi = emi; } else if (wn2.getNodeName().equalsIgnoreCase("blowingSand")) { - retVal.blowingSand = Boolean.parseBoolean(wn2.getTextContent()); + BlowingSand blowingSand = Boolean.parseBoolean(wn2.getTextContent()) ? BlowingSand.BLOWING_SAND : BlowingSand.BLOWING_SAND_NONE; + retVal.blowingSand = blowingSand; } else if (wn2.getNodeName().equalsIgnoreCase("shiftWindDirection")) { retVal.shiftWindDirection = Boolean.parseBoolean(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("shiftWindStrength")) { retVal.shiftWindStrength = Boolean.parseBoolean(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("maxWindStrength")) { - retVal.maxWindStrength = Integer.parseInt(wn2.getTextContent()); + retVal.maxWindStrength = Wind.getWind(Integer.parseInt(wn2.getTextContent())); } else if (wn2.getNodeName().equalsIgnoreCase("minWindStrength")) { - retVal.minWindStrength = Integer.parseInt(wn2.getTextContent()); + retVal.minWindStrength = Wind.getWind(Integer.parseInt(wn2.getTextContent())); } } diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/AceDuelBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/AceDuelBuiltInScenario.java index 3f4f08bd1c..c9e5f54bea 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/AceDuelBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/AceDuelBuiltInScenario.java @@ -25,6 +25,10 @@ import megamek.common.EntityWeightClass; import megamek.common.PlanetaryConditions; import megamek.common.UnitType; +import megamek.common.enums.Fog; +import megamek.common.enums.Light; +import megamek.common.enums.Weather; +import megamek.common.enums.Wind; import mekhq.campaign.Campaign; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.mission.AtBScenario; @@ -57,14 +61,14 @@ public String getResourceKey() { @Override public void setLightConditions() { - setLight(PlanetaryConditions.L_DAY); + setLight(Light.DAY); } @Override public void setWeather() { - setWeather(PlanetaryConditions.WE_NONE); - setWind(PlanetaryConditions.WI_NONE); - setFog(PlanetaryConditions.FOG_NONE); + setWeather(Weather.CLEAR); + setWind(Wind.CALM); + setFog(Fog.FOG_NONE); } @Override diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/OfficerDuelBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/OfficerDuelBuiltInScenario.java index 2d742fc12c..93fba7cd3b 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/OfficerDuelBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/OfficerDuelBuiltInScenario.java @@ -25,6 +25,10 @@ import megamek.common.EntityWeightClass; import megamek.common.PlanetaryConditions; import megamek.common.UnitType; +import megamek.common.enums.Fog; +import megamek.common.enums.Light; +import megamek.common.enums.Weather; +import megamek.common.enums.Wind; import mekhq.campaign.Campaign; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.mission.AtBScenario; @@ -58,14 +62,14 @@ public String getResourceKey() { @Override public void setLightConditions() { - setLight(PlanetaryConditions.L_DAY); + setLight(Light.DAY); } @Override public void setWeather() { - setWeather(PlanetaryConditions.WE_NONE); - setWind(PlanetaryConditions.WI_NONE); - setFog(PlanetaryConditions.FOG_NONE); + setWeather(Weather.CLEAR); + setWind(Wind.CALM); + setFog(Fog.FOG_NONE); } @Override diff --git a/MekHQ/src/mekhq/campaign/universe/Planet.java b/MekHQ/src/mekhq/campaign/universe/Planet.java index f77dda2983..4fb52cdc71 100644 --- a/MekHQ/src/mekhq/campaign/universe/Planet.java +++ b/MekHQ/src/mekhq/campaign/universe/Planet.java @@ -649,8 +649,8 @@ public Integer getPressure(LocalDate when) { } public String getPressureName(LocalDate when) { - Integer currentPressure = getPressure(when); - return null != currentPressure ? PlanetaryConditions.getAtmosphereDisplayableName(currentPressure) : "unknown"; + megamek.common.enums.Atmosphere currentPressure = megamek.common.enums.Atmosphere.getAtmosphere(getPressure(when)); + return null != currentPressure ? currentPressure.toString() : "unknown"; } public Atmosphere getAtmosphere(LocalDate when) { diff --git a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java index 8ce1bbe3cc..2f8954baec 100644 --- a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java @@ -26,6 +26,7 @@ import megamek.common.IStartingPositions; import megamek.common.PlanetaryConditions; import megamek.common.annotations.Nullable; +import megamek.common.enums.Atmosphere; import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.force.ForceStub; @@ -558,7 +559,7 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB chkReroll[REROLL_LIGHT].addItemListener(checkBoxListener); } - lblLightDesc.setText(PlanetaryConditions.getLightDisplayableName(scenario.getLight())); + lblLightDesc.setText(scenario.getLight().toString()); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = y++; panStats.add(lblLightDesc, gridBagConstraints); @@ -581,7 +582,7 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB chkReroll[REROLL_WEATHER].addItemListener(checkBoxListener); } - lblWeatherDesc.setText(PlanetaryConditions.getWeatherDisplayableName(scenario.getWeather())); + lblWeatherDesc.setText(scenario.getWeather().toString()); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = y++; panStats.add(lblWeatherDesc, gridBagConstraints); @@ -594,7 +595,7 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB gridBagConstraints.gridwidth = 1; panStats.add(lblWind, gridBagConstraints); - lblWindDesc.setText(PlanetaryConditions.getWindDisplayableName(scenario.getWind())); + lblWindDesc.setText(scenario.getWind().toString()); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = y++; panStats.add(lblWindDesc, gridBagConstraints); @@ -607,7 +608,7 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB gridBagConstraints.gridwidth = 1; panStats.add(lblFog, gridBagConstraints); - lblFogDesc.setText(PlanetaryConditions.getFogDisplayableName(scenario.getFog())); + lblFogDesc.setText(scenario.getFog().toString()); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = y++; panStats.add(lblFogDesc, gridBagConstraints); @@ -620,7 +621,7 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB gridBagConstraints.gridwidth = 1; panStats.add(lblBlowingSand, gridBagConstraints); - String blowingSandDesc = PlanetaryConditions.getSandBlowingDisplayableValue(scenario.getBlowingSand()); + String blowingSandDesc = scenario.getBlowingSand().toString(); lblBlowingSandDesc.setText(blowingSandDesc); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = y++; @@ -634,7 +635,7 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB gridBagConstraints.gridwidth = 1; panStats.add(lblEMI, gridBagConstraints); - String emiDesc = PlanetaryConditions.getEMIDisplayableValue(scenario.getEMI()); + String emiDesc = scenario.getEMI().toString(); lblEMIDesc.setText(emiDesc); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = y++; @@ -648,7 +649,7 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB gridBagConstraints.gridwidth = 1; panStats.add(lblTemp, gridBagConstraints); - lblTempDesc.setText(PlanetaryConditions.getTemperatureDisplayableName(scenario.getTemperature())); + lblTempDesc.setText(PlanetaryConditions.getTemperatureDisplayableName(scenario.getModifiedTemperature())); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = y++; panStats.add(lblTempDesc, gridBagConstraints); @@ -674,12 +675,12 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB gridBagConstraints.gridwidth = 1; panStats.add(lblAtmosphere, gridBagConstraints); - lblAtmosphereDesc.setText(PlanetaryConditions.getAtmosphereDisplayableName(scenario.getAtmosphere())); + lblAtmosphereDesc.setText(scenario.getAtmosphere().toString()); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = y++; panStats.add(lblAtmosphereDesc, gridBagConstraints); - lblAtmosphere.setVisible(scenario.getAtmosphere() != PlanetaryConditions.ATMO_STANDARD); - lblAtmosphereDesc.setVisible(scenario.getAtmosphere() != PlanetaryConditions.ATMO_STANDARD); + lblAtmosphere.setVisible(scenario.getAtmosphere() != Atmosphere.STANDARD); + lblAtmosphereDesc.setVisible(scenario.getAtmosphere() != Atmosphere.STANDARD); return y; } @@ -817,18 +818,19 @@ private void rerollBattleConditions() { scenario.setLightConditions(); scenario.useReroll(); chkReroll[REROLL_LIGHT].setSelected(false); - lblLightDesc.setText(PlanetaryConditions.getLightDisplayableName(scenario.getLight())); + lblLightDesc.setText(scenario.getLight().toString()); } if (chkReroll[REROLL_WEATHER] != null && chkReroll[REROLL_WEATHER].isSelected()) { scenario.setWeather(); scenario.useReroll(); chkReroll[REROLL_WEATHER].setSelected(false); - lblWeatherDesc.setText(PlanetaryConditions.getWeatherDisplayableName(scenario.getWeather())); - lblWindDesc.setText(PlanetaryConditions.getWindDisplayableName(scenario.getWind())); - lblFogDesc.setText(PlanetaryConditions.getFogDisplayableName(scenario.getFog())); - String blowingSandDesc = PlanetaryConditions.getSandBlowingDisplayableValue(scenario.getBlowingSand()); + lblWeatherDesc.setText(scenario.getWeather().toString()); + lblWindDesc.setText(scenario.getWind().toString()); + lblFogDesc.setText(scenario.getFog().toString()); + lblTempDesc.setText(PlanetaryConditions.getTemperatureDisplayableName(scenario.getModifiedTemperature())); + String blowingSandDesc = scenario.getBlowingSand().toString(); lblBlowingSandDesc.setText(blowingSandDesc); - String emiDesc = PlanetaryConditions.getEMIDisplayableValue(scenario.getEMI()); + String emiDesc = scenario.getEMI().toString(); lblEMIDesc.setText(emiDesc); } btnReroll.setText(scenario.getRerollsRemaining() + diff --git a/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java index aa43f3c2b3..1b9e2e004a 100644 --- a/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java @@ -22,6 +22,7 @@ import megamek.common.PlanetaryConditions; import megamek.common.annotations.Nullable; +import megamek.common.enums.Atmosphere; import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.force.ForceStub; @@ -424,7 +425,7 @@ private void fillMapData() { leftGbc.gridy++; pnlMap.add(lblLight, leftGbc); - JLabel lblLightDesc = new JLabel(PlanetaryConditions.getLightDisplayableName(scenario.getLight())); + JLabel lblLightDesc = new JLabel(scenario.getLight().toString()); rightGbc.gridy++; pnlMap.add(lblLightDesc, rightGbc); @@ -432,7 +433,7 @@ private void fillMapData() { leftGbc.gridy++; pnlMap.add(lblWeather, leftGbc); - JLabel lblWeatherDesc = new JLabel(PlanetaryConditions.getWeatherDisplayableName(scenario.getWeather())); + JLabel lblWeatherDesc = new JLabel(scenario.getWeather().toString()); rightGbc.gridy++; pnlMap.add(lblWeatherDesc, rightGbc); @@ -440,7 +441,7 @@ private void fillMapData() { leftGbc.gridy++; pnlMap.add(lblWind, leftGbc); - JLabel lblWindDesc = new JLabel(PlanetaryConditions.getWindDisplayableName(scenario.getWind())); + JLabel lblWindDesc = new JLabel(scenario.getWind().toString()); rightGbc.gridy++; pnlMap.add(lblWindDesc, rightGbc); @@ -448,7 +449,7 @@ private void fillMapData() { leftGbc.gridy++; pnlMap.add(lblFog, leftGbc); - JLabel lblFogDesc = new JLabel(PlanetaryConditions.getFogDisplayableName(scenario.getFog())); + JLabel lblFogDesc = new JLabel(scenario.getFog().toString()); rightGbc.gridy++; pnlMap.add(lblFogDesc, rightGbc); @@ -456,7 +457,7 @@ private void fillMapData() { leftGbc.gridy++; pnlMap.add(lblBlowingSand, leftGbc); - String blowingSandDesc = PlanetaryConditions.getSandBlowingDisplayableValue(scenario.getBlowingSand()); + String blowingSandDesc = scenario.getBlowingSand().toString(); JLabel lblBlowingSandDesc = new JLabel(blowingSandDesc); rightGbc.gridy++; pnlMap.add(lblBlowingSandDesc, rightGbc); @@ -465,7 +466,7 @@ private void fillMapData() { leftGbc.gridy++; pnlMap.add(lblEMI, leftGbc); - String emiDesc = PlanetaryConditions.getEMIDisplayableValue(scenario.getEMI()); + String emiDesc = scenario.getEMI().toString(); JLabel lblEMIDesc = new JLabel(emiDesc); rightGbc.gridy++; pnlMap.add(lblEMIDesc, rightGbc); @@ -474,7 +475,7 @@ private void fillMapData() { leftGbc.gridy++; pnlMap.add(lblTemperature, leftGbc); - JLabel lblTemperatureDesc = new JLabel(PlanetaryConditions.getTemperatureDisplayableName(scenario.getTemperature())); + JLabel lblTemperatureDesc = new JLabel(PlanetaryConditions.getTemperatureDisplayableName(scenario.getModifiedTemperature())); rightGbc.gridy++; pnlMap.add(lblTemperatureDesc, rightGbc); @@ -489,21 +490,21 @@ private void fillMapData() { } - if (scenario.getAtmosphere() != PlanetaryConditions.ATMO_STANDARD) { + if (scenario.getAtmosphere() != Atmosphere.STANDARD) { JLabel lblAtmosphere = new JLabel(resourceMap.getString("lblAtmosphere.text")); leftGbc.gridy++; pnlMap.add(lblAtmosphere, leftGbc); - JLabel lblAtmosphereDesc = new JLabel(PlanetaryConditions.getAtmosphereDisplayableName(scenario.getAtmosphere())); + JLabel lblAtmosphereDesc = new JLabel(scenario.getAtmosphere().toString()); rightGbc.gridy++; pnlMap.add(lblAtmosphereDesc, rightGbc); } ArrayList otherConditions = new ArrayList<>(); - if (scenario.usesEMI()) { + if (scenario.getEMI().isEMI()) { otherConditions.add(resourceMap.getString("emi.text")); } - if (scenario.usesBlowingSand()) { + if (scenario.getBlowingSand().isBlowingSand()) { otherConditions.add(resourceMap.getString("sand.text")); } if (!otherConditions.isEmpty()) {