From 042caf8f5326df9f886d5862756fc314039abb06 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 9 Feb 2024 18:53:06 -0500 Subject: [PATCH 01/38] lower the pitch black light condition chance --- MekHQ/src/mekhq/campaign/mission/AtBScenario.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 750a0e52dd..01fa1e0f0d 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -303,14 +303,14 @@ public void setTerrain() { public void setLightConditions() { setLight(PlanetaryConditions.L_DAY); - int roll = Compute.randomInt(10) + 1; - if (roll < 6) { + int roll = Compute.randomInt(1000) + 1; + if (roll < 601) { setLight(PlanetaryConditions.L_DAY); - } else if (roll < 8) { + } else if (roll < 801) { setLight(PlanetaryConditions.L_DUSK); - } else if (roll == 8) { + } else if (roll < 901) { setLight(PlanetaryConditions.L_FULL_MOON); - } else if (roll == 9) { + } else if (roll < 1000) { setLight(PlanetaryConditions.L_MOONLESS); } else { setLight(PlanetaryConditions.L_PITCH_BLACK); From cdcd74b4130ca5e29243a6577c07022f48a8bf95 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Feb 2024 06:53:05 -0500 Subject: [PATCH 02/38] add common function to set light --- .../mission/AtBDynamicScenarioFactory.java | 17 +--------------- .../mekhq/campaign/mission/AtBScenario.java | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index 08ed2829fd..313db58a89 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -708,22 +708,7 @@ private static void scaleObjectiveTimeLimits(AtBDynamicScenario scenario, Campai * @param scenario The scenario for which to set lighting conditions. */ private static void setLightConditions(AtBDynamicScenario scenario) { - int roll = Compute.randomInt(10) + 1; - int light; - - if (roll < 6) { - light = PlanetaryConditions.L_DAY; - } else if (roll < 8) { - light = PlanetaryConditions.L_DUSK; - } else if (roll == 8) { - light = PlanetaryConditions.L_FULL_MOON; - } else if (roll == 9) { - light = PlanetaryConditions.L_MOONLESS; - } else { - light = PlanetaryConditions.L_PITCH_BLACK; - } - - scenario.setLight(light); + scenario.setLight(AtBScenario.setLightCond()); } /** diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 01fa1e0f0d..da9ec2b936 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -300,21 +300,27 @@ public void setTerrain() { setTerrainType(terrainChart[Compute.d6(2) - 2]); } - public void setLightConditions() { - setLight(PlanetaryConditions.L_DAY); + public static int setLightCond() { + int light; int roll = Compute.randomInt(1000) + 1; if (roll < 601) { - setLight(PlanetaryConditions.L_DAY); + light = PlanetaryConditions.L_DAY; } else if (roll < 801) { - setLight(PlanetaryConditions.L_DUSK); + light = PlanetaryConditions.L_DUSK; } else if (roll < 901) { - setLight(PlanetaryConditions.L_FULL_MOON); + light = PlanetaryConditions.L_FULL_MOON; } else if (roll < 1000) { - setLight(PlanetaryConditions.L_MOONLESS); + light = PlanetaryConditions.L_MOONLESS; } else { - setLight(PlanetaryConditions.L_PITCH_BLACK); + light = PlanetaryConditions.L_PITCH_BLACK; } + + return light; + } + + public void setLightConditions() { + setLight(setLightCond()); } public void setWeather() { From 661e8ff6c2aed57e6f8677ed426c4b5bf0e3c37b Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Feb 2024 07:50:45 -0500 Subject: [PATCH 03/38] update weather percentages, allow overlaps --- .../mission/AtBDynamicScenarioFactory.java | 59 +------- .../mekhq/campaign/mission/AtBScenario.java | 132 ++++++++++-------- 2 files changed, 81 insertions(+), 110 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index 313db58a89..51a4b03891 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -708,7 +708,7 @@ private static void scaleObjectiveTimeLimits(AtBDynamicScenario scenario, Campai * @param scenario The scenario for which to set lighting conditions. */ private static void setLightConditions(AtBDynamicScenario scenario) { - scenario.setLight(AtBScenario.setLightCond()); + scenario.setLight(AtBScenario.rollLightConditon()); } /** @@ -717,66 +717,15 @@ private static void setLightConditions(AtBDynamicScenario scenario) { * @param scenario The scenario for which to set weather conditions. */ private static void setWeather(AtBDynamicScenario scenario) { - int weather = PlanetaryConditions.WE_NONE; - int wind = PlanetaryConditions.WI_NONE; - int fog = PlanetaryConditions.FOG_NONE; - // weather is irrelevant in these situations. if (scenario.getTerrainType() == AtBScenario.TER_SPACE || scenario.getTerrainType() == AtBScenario.TER_LOW_ATMO) { return; } - int roll = Compute.randomInt(10) + 1; - int r2 = Compute.d6(); - if (roll < 6) { - return; - } else if (roll == 6) { - if (r2 < 4) { - weather = PlanetaryConditions.WE_LIGHT_RAIN; - } else if (r2 < 6) { - weather = PlanetaryConditions.WE_MOD_RAIN; - } else { - weather = PlanetaryConditions.WE_HEAVY_RAIN; - } - } else if (roll == 7) { - if (r2 < 4) { - weather = PlanetaryConditions.WE_LIGHT_SNOW; - } else if (r2 < 6) { - weather = PlanetaryConditions.WE_MOD_SNOW; - } else { - weather = PlanetaryConditions.WE_HEAVY_SNOW; - } - } else if (roll == 8) { - if (r2 < 4) { - wind = PlanetaryConditions.WI_LIGHT_GALE; - } else if (r2 < 6) { - wind = PlanetaryConditions.WI_MOD_GALE; - } else { - wind = PlanetaryConditions.WI_STRONG_GALE; - } - } else if (roll == 9) { - if (r2 == 1) { - wind = PlanetaryConditions.WI_STORM; - } else if (r2 == 2) { - weather = PlanetaryConditions.WE_DOWNPOUR; - } else if (r2 == 3) { - weather = PlanetaryConditions.WE_SLEET; - } else if (r2 == 4) { - weather = PlanetaryConditions.WE_ICE_STORM; - } else if (r2 == 5) { - // tornadoes are classified as wind rather than weather. - wind = PlanetaryConditions.WI_TORNADO_F13; - } else if (r2 == 6) { - wind = PlanetaryConditions.WI_TORNADO_F4; - } - } else { - if (r2 < 5) { - fog = PlanetaryConditions.FOG_LIGHT; - } else { - fog = PlanetaryConditions.FOG_HEAVY; - } - } + int weather = AtBScenario.rollWeatherCondition(); + int wind = AtBScenario.rollWindCondition(); + int fog = AtBScenario.rollFogCondition(); if (!WeatherRestriction.IsWeatherRestricted(weather, scenario.getAtmosphere(), scenario.getTemperature())) { scenario.setWeather(weather); diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index da9ec2b936..cf23ed8f2e 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -300,7 +300,7 @@ public void setTerrain() { setTerrainType(terrainChart[Compute.d6(2) - 2]); } - public static int setLightCond() { + public static int rollLightConditon() { int light; int roll = Compute.randomInt(1000) + 1; @@ -320,63 +320,85 @@ public static int setLightCond() { } public void setLightConditions() { - setLight(setLightCond()); + setLight(rollLightConditon()); + } + + public static int rollWindCondition() { + int wind; + + int roll = Compute.randomInt(100) + 1; + + if (roll < 61) { + wind = PlanetaryConditions.WI_NONE; + } else if (roll < 80) { + wind = PlanetaryConditions.WI_LIGHT_GALE; + } else if (roll < 90) { + wind = PlanetaryConditions.WI_MOD_GALE; + } else if (roll < 94) { + wind = PlanetaryConditions.WI_STRONG_GALE; + } else if (roll < 97) { + wind = PlanetaryConditions.WI_STORM; + } else if (roll < 99) { + wind = PlanetaryConditions.WI_TORNADO_F13; + } else { + wind = PlanetaryConditions.WI_TORNADO_F4; + } + + return wind; + } + + public static int rollWeatherCondition() { + int weather; + + int roll = Compute.randomInt(100) + 1; + + if (roll < 50) { + weather = PlanetaryConditions.WE_NONE; + } else if (roll < 60) { + weather = PlanetaryConditions.WE_LIGHT_RAIN; + } else if (roll < 68) { + weather = PlanetaryConditions.WE_MOD_RAIN; + } else if (roll < 74) { + weather = PlanetaryConditions.WE_HEAVY_RAIN; + } else if (roll < 76) { + weather = PlanetaryConditions.WE_GUSTING_RAIN; + } else if (roll < 78) { + weather = PlanetaryConditions.WE_DOWNPOUR; + } else if (roll < 82) { + weather = PlanetaryConditions.WE_LIGHT_SNOW; + } else if (roll < 90) { + weather = PlanetaryConditions.WE_MOD_SNOW; + } else if (roll < 94) { + weather = PlanetaryConditions.WE_HEAVY_SNOW; + } else if (roll < 98) { + weather = PlanetaryConditions.WE_SLEET; + } else { + weather = PlanetaryConditions.WE_ICE_STORM; + } + + return weather; } - public void setWeather() { - setWeather(PlanetaryConditions.WE_NONE); - setWind(PlanetaryConditions.WI_NONE); - setFog(PlanetaryConditions.FOG_NONE); - - int roll = Compute.randomInt(10) + 1; - int r2 = Compute.d6(); - if (roll == 6) { - if (r2 < 4) { - setWeather(PlanetaryConditions.WE_LIGHT_RAIN); - } else if (r2 < 6) { - setWeather(PlanetaryConditions.WE_MOD_RAIN); - } else { - setWeather(PlanetaryConditions.WE_HEAVY_RAIN); - } - } else if (roll == 7) { - if (r2 < 4) { - setWeather(PlanetaryConditions.WE_LIGHT_SNOW); - } else if (r2 < 6) { - setWeather(PlanetaryConditions.WE_MOD_SNOW); - } else { - setWeather(PlanetaryConditions.WE_HEAVY_SNOW); - } - } else if (roll == 8) { - if (r2 < 4) { - setWind(PlanetaryConditions.WI_LIGHT_GALE); - } else if (r2 < 6) { - setWind(PlanetaryConditions.WI_MOD_GALE); - } else { - setWind(PlanetaryConditions.WI_STRONG_GALE); - } - } else if (roll == 9) { - if (r2 == 1) { - setWind(PlanetaryConditions.WI_STORM); - } else if (r2 == 2) { - setWeather(PlanetaryConditions.WE_DOWNPOUR); - } else if (r2 == 3) { - setWeather(PlanetaryConditions.WE_SLEET); - } else if (r2 == 4) { - setWeather(PlanetaryConditions.WE_ICE_STORM); - } else if (r2 == 5) { - // tornadoes are classified as wind rather than weather. - setWind(PlanetaryConditions.WI_TORNADO_F13); - } else if (r2 == 6) { - setWind(PlanetaryConditions.WI_TORNADO_F4); - } - } else if (roll > 9) { - if (r2 < 5) { - setFog(PlanetaryConditions.FOG_LIGHT); - } else { - setFog(PlanetaryConditions.FOG_HEAVY); - } + public static int rollFogCondition() { + int fog; + + int roll = Compute.randomInt(100) + 1; + + if (roll < 80) { + fog = PlanetaryConditions.FOG_NONE; + } else if (roll < 90) { + fog = PlanetaryConditions.FOG_LIGHT; + } else { + fog = PlanetaryConditions.FOG_HEAVY; } - // roll < 6 can be ignored, as it would just return nothing + + return fog; + } + + public void setWeather() { + setWeather(rollWeatherCondition()); + setWind(rollWindCondition()); + setFog(rollFogCondition()); } public void setPlanetaryConditions(Mission mission, Campaign campaign) { From 4ba64aadb8437d1400ff9c53d8bb9d20e3c5553e Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Feb 2024 08:00:18 -0500 Subject: [PATCH 04/38] check restrictions --- .../mekhq/campaign/mission/AtBScenario.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index cf23ed8f2e..705b7434bb 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -396,9 +396,21 @@ public static int rollFogCondition() { } public void setWeather() { - setWeather(rollWeatherCondition()); - setWind(rollWindCondition()); - setFog(rollFogCondition()); + int weather = AtBScenario.rollWeatherCondition(); + int wind = AtBScenario.rollWindCondition(); + int fog = AtBScenario.rollFogCondition(); + + if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { + setWeather(weather); + } + + if (!WeatherRestriction.IsWindRestricted(wind, getAtmosphere(), getTemperature())) { + setWind(wind); + } + + if (!WeatherRestriction.IsFogRestricted(fog, getAtmosphere(), getTemperature())) { + setFog(fog); + } } public void setPlanetaryConditions(Mission mission, Campaign campaign) { From ac377269f9b5b8f39af3fcfcad9503b5c7d0c0fe Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Feb 2024 08:11:06 -0500 Subject: [PATCH 05/38] if restricted set to none --- MekHQ/src/mekhq/campaign/mission/AtBScenario.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 705b7434bb..989fdf3b25 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -402,14 +402,21 @@ public void setWeather() { if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { setWeather(weather); + } else { + setWeather(PlanetaryConditions.WE_NONE); } + if (!WeatherRestriction.IsWindRestricted(wind, getAtmosphere(), getTemperature())) { setWind(wind); + } else { + setWind(PlanetaryConditions.WI_NONE); } if (!WeatherRestriction.IsFogRestricted(fog, getAtmosphere(), getTemperature())) { setFog(fog); + } else { + setFog(PlanetaryConditions.FOG_NONE); } } From b6e1204f10169aa22ce5e0e142902e519cde38f2 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Feb 2024 08:22:09 -0500 Subject: [PATCH 06/38] code cleanup --- .../mission/AtBDynamicScenarioFactory.java | 16 +--------------- .../src/mekhq/campaign/mission/AtBScenario.java | 12 ++++++------ 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index 51a4b03891..01a9be2fe4 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -723,21 +723,7 @@ private static void setWeather(AtBDynamicScenario scenario) { return; } - int weather = AtBScenario.rollWeatherCondition(); - int wind = AtBScenario.rollWindCondition(); - int fog = AtBScenario.rollFogCondition(); - - if (!WeatherRestriction.IsWeatherRestricted(weather, scenario.getAtmosphere(), scenario.getTemperature())) { - scenario.setWeather(weather); - } - - if (!WeatherRestriction.IsWindRestricted(wind, scenario.getAtmosphere(), scenario.getTemperature())) { - scenario.setWind(wind); - } - - if (!WeatherRestriction.IsFogRestricted(fog, scenario.getAtmosphere(), scenario.getTemperature())) { - scenario.setFog(fog); - } + scenario.setWeather(); } /** diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 989fdf3b25..81a53821b1 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -323,7 +323,7 @@ public void setLightConditions() { setLight(rollLightConditon()); } - public static int rollWindCondition() { + private int rollWindCondition() { int wind; int roll = Compute.randomInt(100) + 1; @@ -347,7 +347,7 @@ public static int rollWindCondition() { return wind; } - public static int rollWeatherCondition() { + private int rollWeatherCondition() { int weather; int roll = Compute.randomInt(100) + 1; @@ -379,7 +379,7 @@ public static int rollWeatherCondition() { return weather; } - public static int rollFogCondition() { + private int rollFogCondition() { int fog; int roll = Compute.randomInt(100) + 1; @@ -396,9 +396,9 @@ public static int rollFogCondition() { } public void setWeather() { - int weather = AtBScenario.rollWeatherCondition(); - int wind = AtBScenario.rollWindCondition(); - int fog = AtBScenario.rollFogCondition(); + int weather = rollWeatherCondition(); + int wind = rollWindCondition(); + int fog = rollFogCondition(); if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { setWeather(weather); From c37f84bd311df2d6a6f21f89827ad4a31a8560da Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Feb 2024 08:27:19 -0500 Subject: [PATCH 07/38] code cleanup --- MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index 01a9be2fe4..a5f2bea7df 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -708,7 +708,7 @@ private static void scaleObjectiveTimeLimits(AtBDynamicScenario scenario, Campai * @param scenario The scenario for which to set lighting conditions. */ private static void setLightConditions(AtBDynamicScenario scenario) { - scenario.setLight(AtBScenario.rollLightConditon()); + scenario.setLightConditions(); } /** From 7b907adad37af0a4b6422d26bf0870a4197eeff4 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Feb 2024 08:39:16 -0500 Subject: [PATCH 08/38] code cleanup --- MekHQ/src/mekhq/campaign/mission/AtBScenario.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 81a53821b1..f8a21cff39 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -300,7 +300,7 @@ public void setTerrain() { setTerrainType(terrainChart[Compute.d6(2) - 2]); } - public static int rollLightConditon() { + private int rollLightCondition() { int light; int roll = Compute.randomInt(1000) + 1; @@ -320,7 +320,7 @@ public static int rollLightConditon() { } public void setLightConditions() { - setLight(rollLightConditon()); + setLight(rollLightCondition()); } private int rollWindCondition() { From 83ceb2c53b61541859b89d3926839c008e02b716 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Feb 2024 10:50:17 -0500 Subject: [PATCH 09/38] set weather by terrain type --- .../resources/AtBScenarioViewPanel.properties | 1 + .../resources/ScenarioViewPanel.properties | 1 + .../mekhq/campaign/mission/AtBScenario.java | 143 +++++++++++++++++- .../src/mekhq/campaign/mission/Scenario.java | 3 + .../mekhq/gui/view/AtBScenarioViewPanel.java | 16 ++ .../src/mekhq/gui/view/ScenarioViewPanel.java | 9 ++ 6 files changed, 170 insertions(+), 3 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/AtBScenarioViewPanel.properties b/MekHQ/resources/mekhq/resources/AtBScenarioViewPanel.properties index 7a076da401..4d6c1a2590 100644 --- a/MekHQ/resources/mekhq/resources/AtBScenarioViewPanel.properties +++ b/MekHQ/resources/mekhq/resources/AtBScenarioViewPanel.properties @@ -8,6 +8,7 @@ lblLight.text=Light: lblWeather.text=Weather: lblWind.text=Wind: lblFog.text=Fog: +lblBlowingSand.text=Blowing Sand: lblAtmosphere.text=Atmosphere: lblGravity.text=Gravity: lblPlayerStart.text=Player Start: diff --git a/MekHQ/resources/mekhq/resources/ScenarioViewPanel.properties b/MekHQ/resources/mekhq/resources/ScenarioViewPanel.properties index 24b08e653f..8d7fbf73ec 100644 --- a/MekHQ/resources/mekhq/resources/ScenarioViewPanel.properties +++ b/MekHQ/resources/mekhq/resources/ScenarioViewPanel.properties @@ -15,6 +15,7 @@ lblLight.text=Light: lblWeather.text=Weather: lblWind.text=Wind: lblFog.text=Fog: +lblBlowingSand.text=Blowing Sand: lblAtmosphere.text=Atmosphere: lblGravity.text=Gravity: lblTemperature.text=Temperature: diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index f8a21cff39..36772403fd 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -347,7 +347,7 @@ private int rollWindCondition() { return wind; } - private int rollWeatherCondition() { + private int rollWeatherStandardCondition() { int weather; int roll = Compute.randomInt(100) + 1; @@ -379,6 +379,102 @@ private int rollWeatherCondition() { return weather; } + private int rollWeatherWetCondition() { + int weather; + + int roll = Compute.randomInt(100) + 1; + + if (roll < 20) { + weather = PlanetaryConditions.WE_NONE; + } else if (roll < 40) { + weather = PlanetaryConditions.WE_LIGHT_RAIN; + } else if (roll < 50) { + weather = PlanetaryConditions.WE_MOD_RAIN; + } else if (roll < 60) { + weather = PlanetaryConditions.WE_HEAVY_RAIN; + } else if (roll < 70) { + weather = PlanetaryConditions.WE_GUSTING_RAIN; + } else if (roll < 76) { + weather = PlanetaryConditions.WE_DOWNPOUR; + } else if (roll < 82) { + weather = PlanetaryConditions.WE_LIGHT_SNOW; + } else if (roll < 90) { + weather = PlanetaryConditions.WE_MOD_SNOW; + } else if (roll < 94) { + weather = PlanetaryConditions.WE_HEAVY_SNOW; + } else if (roll < 98) { + weather = PlanetaryConditions.WE_SLEET; + } else { + weather = PlanetaryConditions.WE_ICE_STORM; + } + + return weather; + } + + private int rollWeatherSnowyCondition() { + int weather; + + int roll = Compute.randomInt(100) + 1; + + if (roll < 20) { + weather = PlanetaryConditions.WE_NONE; + } else if (roll < 40) { + weather = PlanetaryConditions.WE_LIGHT_RAIN; + } else if (roll < 46) { + weather = PlanetaryConditions.WE_MOD_RAIN; + } else if (roll < 52) { + weather = PlanetaryConditions.WE_HEAVY_RAIN; + } else if (roll < 56) { + weather = PlanetaryConditions.WE_GUSTING_RAIN; + } else if (roll < 60) { + weather = PlanetaryConditions.WE_DOWNPOUR; + } else if (roll < 64) { + weather = PlanetaryConditions.WE_LIGHT_SNOW; + } else if (roll < 76) { + weather = PlanetaryConditions.WE_MOD_SNOW; + } else if (roll < 90) { + weather = PlanetaryConditions.WE_HEAVY_SNOW; + } else if (roll < 96) { + weather = PlanetaryConditions.WE_SLEET; + } else { + weather = PlanetaryConditions.WE_ICE_STORM; + } + + return weather; + } + + private int rollWeatherDryCondition() { + int weather; + + int roll = Compute.randomInt(100) + 1; + + if (roll < 20) { + weather = PlanetaryConditions.WE_NONE; + } else if (roll < 80) { + weather = PlanetaryConditions.WE_LIGHT_RAIN; + } else if (roll < 86) { + weather = PlanetaryConditions.WE_MOD_RAIN; + } else if (roll < 90) { + weather = PlanetaryConditions.WE_HEAVY_RAIN; + } else if (roll < 92) { + weather = PlanetaryConditions.WE_GUSTING_RAIN; + } else if (roll < 93) { + weather = PlanetaryConditions.WE_DOWNPOUR; + } else if (roll < 94) { + weather = PlanetaryConditions.WE_LIGHT_SNOW; + } else if (roll < 97) { + weather = PlanetaryConditions.WE_MOD_SNOW; + } else if (roll < 98) { + weather = PlanetaryConditions.WE_HEAVY_SNOW; + } else if (roll < 99) { + weather = PlanetaryConditions.WE_SLEET; + } else { + weather = PlanetaryConditions.WE_ICE_STORM; + } + + return weather; + } + private int rollFogCondition() { int fog; @@ -395,10 +491,51 @@ private int rollFogCondition() { return fog; } + private boolean rollBlowingSand() { + boolean blowingSand = false; + + int roll = Compute.randomInt(100) + 1; + + if (roll < 60) { + blowingSand = true; + } + + return blowingSand; + } + public void setWeather() { - int weather = rollWeatherCondition(); + int weather = PlanetaryConditions.WE_NONE; + int fog = PlanetaryConditions.FOG_NONE; + + if (getTerrainType() == TER_LIGHTURBAN + || getTerrainType() == TER_FLATLANDS + || getTerrainType() == TER_WOODED + || getTerrainType() == TER_HEAVYURBAN) { + weather = rollWeatherStandardCondition(); + fog = rollFogCondition(); + setBlowingSand(false); + } else if (getTerrainType() == TER_COASTAL + || getTerrainType() == TER_WETLANDS) { + weather = rollWeatherWetCondition(); + fog = rollFogCondition(); + setBlowingSand(false); + } else if (getTerrainType() == TER_HILLS + || getTerrainType() == TER_MOUNTAINS) { + weather = rollWeatherSnowyCondition(); + fog = rollFogCondition(); + setBlowingSand(false); + } else if (getTerrainType() == TER_BADLANDS) { + weather = rollWeatherDryCondition(); + if (weather == PlanetaryConditions.WE_NONE && rollBlowingSand()) { + setBlowingSand(true); + } + } else { + weather = rollWeatherStandardCondition(); + fog = rollFogCondition(); + setBlowingSand(false); + } + int wind = rollWindCondition(); - int fog = rollFogCondition(); if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { setWeather(weather); diff --git a/MekHQ/src/mekhq/campaign/mission/Scenario.java b/MekHQ/src/mekhq/campaign/mission/Scenario.java index d7101704de..0a4c78e248 100644 --- a/MekHQ/src/mekhq/campaign/mission/Scenario.java +++ b/MekHQ/src/mekhq/campaign/mission/Scenario.java @@ -361,6 +361,9 @@ public boolean usesBlowingSand() { public void setBlowingSand(boolean blow) { this.blowingSand = blow; } + public boolean getBlowingSand() { + return blowingSand; + } public boolean canWindShiftDirection() { return shiftWindDirection; } diff --git a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java index 3d328f2d35..beeab6e6a7 100644 --- a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java @@ -79,6 +79,8 @@ public class AtBScenarioViewPanel extends JScrollablePanel { private JLabel lblWindDesc = new JLabel(); private JLabel lblFog = new JLabel(); private JLabel lblFogDesc = new JLabel(); + private JLabel lblBlowingSand = new JLabel(); + private JLabel lblBlowingSandDesc = new JLabel(); private JLabel lblTemp = new JLabel(); @@ -598,6 +600,20 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB lblFog.setVisible(campaign.getCampaignOptions().isUseWeatherConditions()); lblFogDesc.setVisible(campaign.getCampaignOptions().isUseWeatherConditions()); + lblBlowingSand.setText(resourceMap.getString("lblBlowingSand.text")); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = y; + gridBagConstraints.gridwidth = 1; + panStats.add(lblBlowingSand, gridBagConstraints); + + String blowingSandDesc = scenario.getBlowingSand() ? PlanetaryConditions.MSG_NAME_BLOWINGSAND_TRUE : PlanetaryConditions.MSG_NAME_BLOWINGSAND_FALSE; + lblBlowingSandDesc.setText(blowingSandDesc); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = y++; + panStats.add(lblBlowingSandDesc, gridBagConstraints); + lblBlowingSand.setVisible(campaign.getCampaignOptions().isUseWeatherConditions()); + lblBlowingSandDesc.setVisible(campaign.getCampaignOptions().isUseWeatherConditions()); + lblTemp.setText(resourceMap.getString("lblTemperature.text")); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = y; diff --git a/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java index a1e3411fc3..19745a6c6c 100644 --- a/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java @@ -452,6 +452,15 @@ private void fillMapData() { rightGbc.gridy++; pnlMap.add(lblFogDesc, rightGbc); + JLabel lblBlowingSand = new JLabel(resourceMap.getString("lblFog.text")); + leftGbc.gridy++; + pnlMap.add(lblBlowingSand, leftGbc); + + String blowingSandDesc = scenario.getBlowingSand() ? PlanetaryConditions.MSG_NAME_BLOWINGSAND_TRUE : PlanetaryConditions.MSG_NAME_BLOWINGSAND_FALSE; + JLabel lblBlowingSandDesc = new JLabel(blowingSandDesc); + rightGbc.gridy++; + pnlMap.add(lblBlowingSandDesc, rightGbc); + JLabel lblTemperature = new JLabel(resourceMap.getString("lblTemperature.text")); leftGbc.gridy++; pnlMap.add(lblTemperature, leftGbc); From 8cb333aadae811fca47637a294cdf7aca8e8613c Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Feb 2024 11:23:37 -0500 Subject: [PATCH 10/38] update percentages --- MekHQ/src/mekhq/campaign/mission/AtBScenario.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 36772403fd..9b7a0b3065 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -416,7 +416,7 @@ private int rollWeatherSnowyCondition() { int roll = Compute.randomInt(100) + 1; - if (roll < 20) { + if (roll < 30) { weather = PlanetaryConditions.WE_NONE; } else if (roll < 40) { weather = PlanetaryConditions.WE_LIGHT_RAIN; @@ -448,9 +448,9 @@ private int rollWeatherDryCondition() { int roll = Compute.randomInt(100) + 1; - if (roll < 20) { + if (roll < 78) { weather = PlanetaryConditions.WE_NONE; - } else if (roll < 80) { + } else if (roll < 82) { weather = PlanetaryConditions.WE_LIGHT_RAIN; } else if (roll < 86) { weather = PlanetaryConditions.WE_MOD_RAIN; From cd6b05ff000722328a28967c0dbfe890af0d510c Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Feb 2024 11:54:33 -0500 Subject: [PATCH 11/38] if extreme heat check blowing sand --- MekHQ/src/mekhq/campaign/mission/AtBScenario.java | 12 +++++++++++- MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java | 13 +++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 9b7a0b3065..7300e18e60 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -513,7 +513,15 @@ public void setWeather() { || getTerrainType() == TER_HEAVYURBAN) { weather = rollWeatherStandardCondition(); fog = rollFogCondition(); - setBlowingSand(false); + int temp = getTemperature(); + if (weather == PlanetaryConditions.WE_NONE + && fog == PlanetaryConditions.FOG_NONE + && PlanetaryConditions.isExtremeTemperature(temp) && (temp > 0) + && rollBlowingSand()) { + setBlowingSand(true); + } else { + setBlowingSand(false); + } } else if (getTerrainType() == TER_COASTAL || getTerrainType() == TER_WETLANDS) { weather = rollWeatherWetCondition(); @@ -528,6 +536,8 @@ public void setWeather() { weather = rollWeatherDryCondition(); if (weather == PlanetaryConditions.WE_NONE && rollBlowingSand()) { setBlowingSand(true); + } else { + setBlowingSand(false); } } else { weather = rollWeatherStandardCondition(); diff --git a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java index beeab6e6a7..798cb50f75 100644 --- a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java @@ -480,6 +480,17 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB chkReroll[REROLL_TERRAIN].addItemListener(checkBoxListener); } + lblTerrainDesc.setText(AtBScenario.terrainTypes[scenario.getTerrainType()]); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = y++; + panStats.add(lblTerrainDesc, gridBagConstraints); + } else { + lblTerrain.setText(resourceMap.getString("lblTerrain.text")); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = y; + gridBagConstraints.gridwidth = 1; + panStats.add(lblTerrain, gridBagConstraints); + lblTerrainDesc.setText(AtBScenario.terrainTypes[scenario.getTerrainType()]); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = y++; @@ -798,6 +809,8 @@ private void rerollBattleConditions() { lblWeatherDesc.setText(PlanetaryConditions.getWeatherDisplayableName(scenario.getWeather())); lblWindDesc.setText(PlanetaryConditions.getWindDisplayableName(scenario.getWind())); lblFogDesc.setText(PlanetaryConditions.getFogDisplayableName(scenario.getFog())); + String blowingSandDesc = scenario.getBlowingSand() ? PlanetaryConditions.MSG_NAME_BLOWINGSAND_TRUE : PlanetaryConditions.MSG_NAME_BLOWINGSAND_FALSE; + lblBlowingSandDesc.setText(blowingSandDesc); } btnReroll.setText(scenario.getRerollsRemaining() + " Reroll" + ((scenario.getRerollsRemaining() == 1)?"":"s") + From 7440d9f9c284a5d33d1b736f12a768c000cde0e6 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Feb 2024 13:11:55 -0500 Subject: [PATCH 12/38] foggier, extreme cold --- .../mekhq/campaign/mission/AtBScenario.java | 99 ++++++++++++------- 1 file changed, 62 insertions(+), 37 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 7300e18e60..bbda6d8143 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -475,7 +475,7 @@ private int rollWeatherDryCondition() { return weather; } - private int rollFogCondition() { + private int rollFoggyCondition() { int fog; int roll = Compute.randomInt(100) + 1; @@ -491,6 +491,22 @@ private int rollFogCondition() { return fog; } + private int rollFoggierCondition() { + int fog; + + int roll = Compute.randomInt(100) + 1; + + if (roll < 60) { + fog = PlanetaryConditions.FOG_NONE; + } else if (roll < 80) { + fog = PlanetaryConditions.FOG_LIGHT; + } else { + fog = PlanetaryConditions.FOG_HEAVY; + } + + return fog; + } + private boolean rollBlowingSand() { boolean blowingSand = false; @@ -506,45 +522,54 @@ private boolean rollBlowingSand() { public void setWeather() { int weather = PlanetaryConditions.WE_NONE; int fog = PlanetaryConditions.FOG_NONE; + boolean blowingSand = false; + int temp = getTemperature(); + boolean extremeHeat = PlanetaryConditions.isExtremeTemperature(temp) && (temp > 0); + boolean extremeCold = PlanetaryConditions.isExtremeTemperature(temp) && (temp < 0); + + switch (getTerrainType()) { + case TER_HILLS: + case TER_LIGHTURBAN: + case TER_FLATLANDS: + case TER_WOODED: + case TER_HEAVYURBAN: + if (extremeCold) { + weather = rollWeatherSnowyCondition(); + fog = rollFoggyCondition(); - if (getTerrainType() == TER_LIGHTURBAN - || getTerrainType() == TER_FLATLANDS - || getTerrainType() == TER_WOODED - || getTerrainType() == TER_HEAVYURBAN) { - weather = rollWeatherStandardCondition(); - fog = rollFogCondition(); - int temp = getTemperature(); - if (weather == PlanetaryConditions.WE_NONE - && fog == PlanetaryConditions.FOG_NONE - && PlanetaryConditions.isExtremeTemperature(temp) && (temp > 0) - && rollBlowingSand()) { - setBlowingSand(true); - } else { - setBlowingSand(false); - } - } else if (getTerrainType() == TER_COASTAL - || getTerrainType() == TER_WETLANDS) { - weather = rollWeatherWetCondition(); - fog = rollFogCondition(); - setBlowingSand(false); - } else if (getTerrainType() == TER_HILLS - || getTerrainType() == TER_MOUNTAINS) { - weather = rollWeatherSnowyCondition(); - fog = rollFogCondition(); - setBlowingSand(false); - } else if (getTerrainType() == TER_BADLANDS) { - weather = rollWeatherDryCondition(); - if (weather == PlanetaryConditions.WE_NONE && rollBlowingSand()) { - setBlowingSand(true); - } else { - setBlowingSand(false); - } - } else { - weather = rollWeatherStandardCondition(); - fog = rollFogCondition(); - setBlowingSand(false); + } else { + weather = rollWeatherStandardCondition(); + fog = rollFoggyCondition(); + if (weather == PlanetaryConditions.WE_NONE + && fog == PlanetaryConditions.FOG_NONE + && extremeHeat + && rollBlowingSand()) { + blowingSand = true; + } + } + break; + case TER_COASTAL: + case TER_WETLANDS: + weather = rollWeatherWetCondition(); + fog = rollFoggierCondition(); + break; + case TER_MOUNTAINS: + weather = rollWeatherSnowyCondition(); + fog = rollFoggyCondition(); + break; + case TER_BADLANDS: + weather = rollWeatherDryCondition(); + if (weather == PlanetaryConditions.WE_NONE + & rollBlowingSand()) { + blowingSand = true; + } + break; + default: + weather = rollWeatherStandardCondition(); + fog = rollFoggyCondition(); } + setBlowingSand(blowingSand); int wind = rollWindCondition(); if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { From 00a08fb72321eba3f0d022dcae8bb970ecd17a97 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Feb 2024 16:22:47 -0500 Subject: [PATCH 13/38] lower chance ranges --- .../mekhq/campaign/mission/AtBScenario.java | 159 ++++++++++-------- 1 file changed, 89 insertions(+), 70 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index bbda6d8143..b23f97814e 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -328,7 +328,7 @@ private int rollWindCondition() { int roll = Compute.randomInt(100) + 1; - if (roll < 61) { + if (roll < 70) { wind = PlanetaryConditions.WI_NONE; } else if (roll < 80) { wind = PlanetaryConditions.WI_LIGHT_GALE; @@ -344,7 +344,11 @@ private int rollWindCondition() { wind = PlanetaryConditions.WI_TORNADO_F4; } - return wind; + if (!WeatherRestriction.IsWindRestricted(wind, getAtmosphere(), getTemperature())) { + return wind; + } else { + return PlanetaryConditions.WI_NONE; + } } private int rollWeatherStandardCondition() { @@ -352,31 +356,35 @@ private int rollWeatherStandardCondition() { int roll = Compute.randomInt(100) + 1; - if (roll < 50) { + if (roll < 70) { weather = PlanetaryConditions.WE_NONE; - } else if (roll < 60) { + } else if (roll < 77) { weather = PlanetaryConditions.WE_LIGHT_RAIN; - } else if (roll < 68) { + } else if (roll < 81) { weather = PlanetaryConditions.WE_MOD_RAIN; - } else if (roll < 74) { + } else if (roll < 85) { weather = PlanetaryConditions.WE_HEAVY_RAIN; - } else if (roll < 76) { + } else if (roll < 87) { weather = PlanetaryConditions.WE_GUSTING_RAIN; - } else if (roll < 78) { + } else if (roll < 88) { weather = PlanetaryConditions.WE_DOWNPOUR; - } else if (roll < 82) { + } else if (roll < 94) { weather = PlanetaryConditions.WE_LIGHT_SNOW; - } else if (roll < 90) { + } else if (roll < 96) { weather = PlanetaryConditions.WE_MOD_SNOW; - } else if (roll < 94) { + } else if (roll < 97) { weather = PlanetaryConditions.WE_HEAVY_SNOW; - } else if (roll < 98) { + } else if (roll < 99) { weather = PlanetaryConditions.WE_SLEET; } else { weather = PlanetaryConditions.WE_ICE_STORM; } - return weather; + if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { + return weather; + } else { + return PlanetaryConditions.WE_NONE; + } } private int rollWeatherWetCondition() { @@ -384,31 +392,35 @@ private int rollWeatherWetCondition() { int roll = Compute.randomInt(100) + 1; - if (roll < 20) { + if (roll < 48) { weather = PlanetaryConditions.WE_NONE; - } else if (roll < 40) { + } else if (roll < 60) { weather = PlanetaryConditions.WE_LIGHT_RAIN; - } else if (roll < 50) { + } else if (roll < 70) { weather = PlanetaryConditions.WE_MOD_RAIN; - } else if (roll < 60) { + } else if (roll < 78) { weather = PlanetaryConditions.WE_HEAVY_RAIN; - } else if (roll < 70) { + } else if (roll < 84) { weather = PlanetaryConditions.WE_GUSTING_RAIN; - } else if (roll < 76) { + } else if (roll < 88) { weather = PlanetaryConditions.WE_DOWNPOUR; - } else if (roll < 82) { + } else if (roll < 94) { weather = PlanetaryConditions.WE_LIGHT_SNOW; - } else if (roll < 90) { + } else if (roll < 96) { weather = PlanetaryConditions.WE_MOD_SNOW; - } else if (roll < 94) { + } else if (roll < 97) { weather = PlanetaryConditions.WE_HEAVY_SNOW; - } else if (roll < 98) { + } else if (roll < 99) { weather = PlanetaryConditions.WE_SLEET; } else { weather = PlanetaryConditions.WE_ICE_STORM; } - return weather; + if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { + return weather; + } else { + return PlanetaryConditions.WE_NONE; + } } private int rollWeatherSnowyCondition() { @@ -416,31 +428,35 @@ private int rollWeatherSnowyCondition() { int roll = Compute.randomInt(100) + 1; - if (roll < 30) { + if (roll < 40) { weather = PlanetaryConditions.WE_NONE; - } else if (roll < 40) { + } else if (roll < 47) { weather = PlanetaryConditions.WE_LIGHT_RAIN; - } else if (roll < 46) { + } else if (roll < 51) { weather = PlanetaryConditions.WE_MOD_RAIN; - } else if (roll < 52) { + } else if (roll < 55) { weather = PlanetaryConditions.WE_HEAVY_RAIN; - } else if (roll < 56) { + } else if (roll < 57) { weather = PlanetaryConditions.WE_GUSTING_RAIN; - } else if (roll < 60) { + } else if (roll < 58) { weather = PlanetaryConditions.WE_DOWNPOUR; - } else if (roll < 64) { + } else if (roll < 70) { weather = PlanetaryConditions.WE_LIGHT_SNOW; - } else if (roll < 76) { + } else if (roll < 80) { weather = PlanetaryConditions.WE_MOD_SNOW; - } else if (roll < 90) { + } else if (roll < 88) { weather = PlanetaryConditions.WE_HEAVY_SNOW; - } else if (roll < 96) { + } else if (roll < 94) { weather = PlanetaryConditions.WE_SLEET; } else { weather = PlanetaryConditions.WE_ICE_STORM; } - return weather; + if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { + return weather; + } else { + return PlanetaryConditions.WE_NONE; + } } private int rollWeatherDryCondition() { @@ -448,19 +464,19 @@ private int rollWeatherDryCondition() { int roll = Compute.randomInt(100) + 1; - if (roll < 78) { + if (roll < 84) { weather = PlanetaryConditions.WE_NONE; - } else if (roll < 82) { + } else if (roll < 88) { weather = PlanetaryConditions.WE_LIGHT_RAIN; - } else if (roll < 86) { - weather = PlanetaryConditions.WE_MOD_RAIN; } else if (roll < 90) { - weather = PlanetaryConditions.WE_HEAVY_RAIN; + weather = PlanetaryConditions.WE_MOD_RAIN; } else if (roll < 92) { - weather = PlanetaryConditions.WE_GUSTING_RAIN; + weather = PlanetaryConditions.WE_HEAVY_RAIN; } else if (roll < 93) { - weather = PlanetaryConditions.WE_DOWNPOUR; + weather = PlanetaryConditions.WE_GUSTING_RAIN; } else if (roll < 94) { + weather = PlanetaryConditions.WE_DOWNPOUR; + } else if (roll < 95) { weather = PlanetaryConditions.WE_LIGHT_SNOW; } else if (roll < 97) { weather = PlanetaryConditions.WE_MOD_SNOW; @@ -472,7 +488,11 @@ private int rollWeatherDryCondition() { weather = PlanetaryConditions.WE_ICE_STORM; } - return weather; + if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { + return weather; + } else { + return PlanetaryConditions.WE_NONE; + } } private int rollFoggyCondition() { @@ -480,15 +500,19 @@ private int rollFoggyCondition() { int roll = Compute.randomInt(100) + 1; - if (roll < 80) { + if (roll < 90) { fog = PlanetaryConditions.FOG_NONE; - } else if (roll < 90) { + } else if (roll < 96) { fog = PlanetaryConditions.FOG_LIGHT; } else { fog = PlanetaryConditions.FOG_HEAVY; } - return fog; + if (!WeatherRestriction.IsFogRestricted(fog, getAtmosphere(), getTemperature())) { + return fog; + } else { + return PlanetaryConditions.FOG_NONE; + } } private int rollFoggierCondition() { @@ -504,7 +528,11 @@ private int rollFoggierCondition() { fog = PlanetaryConditions.FOG_HEAVY; } - return fog; + if (!WeatherRestriction.IsFogRestricted(fog, getAtmosphere(), getTemperature())) { + return fog; + } else { + return PlanetaryConditions.FOG_NONE; + } } private boolean rollBlowingSand() { @@ -512,7 +540,7 @@ private boolean rollBlowingSand() { int roll = Compute.randomInt(100) + 1; - if (roll < 60) { + if (roll < 50) { blowingSand = true; } @@ -550,8 +578,14 @@ && rollBlowingSand()) { break; case TER_COASTAL: case TER_WETLANDS: - weather = rollWeatherWetCondition(); - fog = rollFoggierCondition(); + if (extremeCold) { + weather = rollWeatherSnowyCondition(); + fog = rollFoggierCondition(); + + } else { + weather = rollWeatherWetCondition(); + fog = rollFoggierCondition(); + } break; case TER_MOUNTAINS: weather = rollWeatherSnowyCondition(); @@ -560,7 +594,7 @@ && rollBlowingSand()) { case TER_BADLANDS: weather = rollWeatherDryCondition(); if (weather == PlanetaryConditions.WE_NONE - & rollBlowingSand()) { + && rollBlowingSand()) { blowingSand = true; } break; @@ -569,27 +603,12 @@ & rollBlowingSand()) { fog = rollFoggyCondition(); } - setBlowingSand(blowingSand); int wind = rollWindCondition(); - if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { - setWeather(weather); - } else { - setWeather(PlanetaryConditions.WE_NONE); - } - - - if (!WeatherRestriction.IsWindRestricted(wind, getAtmosphere(), getTemperature())) { - setWind(wind); - } else { - setWind(PlanetaryConditions.WI_NONE); - } - - if (!WeatherRestriction.IsFogRestricted(fog, getAtmosphere(), getTemperature())) { - setFog(fog); - } else { - setFog(PlanetaryConditions.FOG_NONE); - } + setWeather(weather); + setWind(wind); + setFog(fog); + setBlowingSand(blowingSand); } public void setPlanetaryConditions(Mission mission, Campaign campaign) { From 5d4b1802c15daec6a91caed749d4617fbab8bece Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 10 Feb 2024 17:00:36 -0500 Subject: [PATCH 14/38] if blowing sand, set wind to moderate gale --- .../mekhq/campaign/mission/AtBScenario.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index b23f97814e..b4bdc8df83 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -551,9 +551,11 @@ public void setWeather() { int weather = PlanetaryConditions.WE_NONE; int fog = PlanetaryConditions.FOG_NONE; boolean blowingSand = false; - int temp = getTemperature(); - boolean extremeHeat = PlanetaryConditions.isExtremeTemperature(temp) && (temp > 0); - boolean extremeCold = PlanetaryConditions.isExtremeTemperature(temp) && (temp < 0); + boolean extremeHeat = PlanetaryConditions.isExtremeTemperature(getTemperature()) && (getTemperature() > 0); + boolean extremeCold = PlanetaryConditions.isExtremeTemperature(getTemperature()) && (getTemperature() < 0); + boolean moderateGaleRestricted = WeatherRestriction.IsWindRestricted(PlanetaryConditions.WI_MOD_GALE, getAtmosphere(), getTemperature()); + + int wind = rollWindCondition(); switch (getTerrainType()) { case TER_HILLS: @@ -571,6 +573,7 @@ public void setWeather() { if (weather == PlanetaryConditions.WE_NONE && fog == PlanetaryConditions.FOG_NONE && extremeHeat + && !moderateGaleRestricted && rollBlowingSand()) { blowingSand = true; } @@ -594,6 +597,7 @@ && rollBlowingSand()) { case TER_BADLANDS: weather = rollWeatherDryCondition(); if (weather == PlanetaryConditions.WE_NONE + && !moderateGaleRestricted && rollBlowingSand()) { blowingSand = true; } @@ -603,10 +607,12 @@ && rollBlowingSand()) { fog = rollFoggyCondition(); } - int wind = rollWindCondition(); - setWeather(weather); - setWind(wind); + if (blowingSand && wind < PlanetaryConditions.WI_MOD_GALE) { + setWind(PlanetaryConditions.WI_MOD_GALE); + } else { + setWind(wind); + } setFog(fog); setBlowingSand(blowingSand); } From d83056ee73911b187c57f44fc654bdd5883f93ca Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 11 Feb 2024 07:45:15 -0500 Subject: [PATCH 15/38] add rollCondition and pass in the odds needed --- .../mekhq/campaign/mission/AtBScenario.java | 212 +++--------------- 1 file changed, 37 insertions(+), 175 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index b4bdc8df83..2b573bbf4c 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -54,6 +54,7 @@ import java.text.ParseException; import java.time.LocalDate; import java.util.*; +import java.util.stream.IntStream; /** * @author Neoancient @@ -300,23 +301,28 @@ public void setTerrain() { setTerrainType(terrainChart[Compute.d6(2) - 2]); } - private int rollLightCondition() { - int light; - - int roll = Compute.randomInt(1000) + 1; - if (roll < 601) { - light = PlanetaryConditions.L_DAY; - } else if (roll < 801) { - light = PlanetaryConditions.L_DUSK; - } else if (roll < 901) { - light = PlanetaryConditions.L_FULL_MOON; - } else if (roll < 1000) { - light = PlanetaryConditions.L_MOONLESS; - } else { - light = PlanetaryConditions.L_PITCH_BLACK; + private int rollCondition(int[] odds) { + int condition = 0; + int sum = IntStream.of(odds).sum(); + int rollingSum = 0; + int roll = Compute.randomInt(sum); + + for (int i = 0; i < odds.length; i++) { + if (odds[i] > 0) { + rollingSum += odds[i]; + if (roll < rollingSum) { + condition = i; + break; + } + } } - return light; + return condition; + } + + private int rollLightCondition() { + int[] odds = new int[]{600,200,100,99,1}; + return rollCondition(odds); } public void setLightConditions() { @@ -324,25 +330,8 @@ public void setLightConditions() { } private int rollWindCondition() { - int wind; - - int roll = Compute.randomInt(100) + 1; - - if (roll < 70) { - wind = PlanetaryConditions.WI_NONE; - } else if (roll < 80) { - wind = PlanetaryConditions.WI_LIGHT_GALE; - } else if (roll < 90) { - wind = PlanetaryConditions.WI_MOD_GALE; - } else if (roll < 94) { - wind = PlanetaryConditions.WI_STRONG_GALE; - } else if (roll < 97) { - wind = PlanetaryConditions.WI_STORM; - } else if (roll < 99) { - wind = PlanetaryConditions.WI_TORNADO_F13; - } else { - wind = PlanetaryConditions.WI_TORNADO_F4; - } + int[] odds = new int[]{70,10,10,4,3,2,1}; + int wind = rollCondition(odds); if (!WeatherRestriction.IsWindRestricted(wind, getAtmosphere(), getTemperature())) { return wind; @@ -352,33 +341,8 @@ private int rollWindCondition() { } private int rollWeatherStandardCondition() { - int weather; - - int roll = Compute.randomInt(100) + 1; - - if (roll < 70) { - weather = PlanetaryConditions.WE_NONE; - } else if (roll < 77) { - weather = PlanetaryConditions.WE_LIGHT_RAIN; - } else if (roll < 81) { - weather = PlanetaryConditions.WE_MOD_RAIN; - } else if (roll < 85) { - weather = PlanetaryConditions.WE_HEAVY_RAIN; - } else if (roll < 87) { - weather = PlanetaryConditions.WE_GUSTING_RAIN; - } else if (roll < 88) { - weather = PlanetaryConditions.WE_DOWNPOUR; - } else if (roll < 94) { - weather = PlanetaryConditions.WE_LIGHT_SNOW; - } else if (roll < 96) { - weather = PlanetaryConditions.WE_MOD_SNOW; - } else if (roll < 97) { - weather = PlanetaryConditions.WE_HEAVY_SNOW; - } else if (roll < 99) { - weather = PlanetaryConditions.WE_SLEET; - } else { - weather = PlanetaryConditions.WE_ICE_STORM; - } + int[] odds = new int[]{70,7,4,4,2,1,6,2,1,2,1}; + int weather = rollCondition(odds); if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { return weather; @@ -388,33 +352,8 @@ private int rollWeatherStandardCondition() { } private int rollWeatherWetCondition() { - int weather; - - int roll = Compute.randomInt(100) + 1; - - if (roll < 48) { - weather = PlanetaryConditions.WE_NONE; - } else if (roll < 60) { - weather = PlanetaryConditions.WE_LIGHT_RAIN; - } else if (roll < 70) { - weather = PlanetaryConditions.WE_MOD_RAIN; - } else if (roll < 78) { - weather = PlanetaryConditions.WE_HEAVY_RAIN; - } else if (roll < 84) { - weather = PlanetaryConditions.WE_GUSTING_RAIN; - } else if (roll < 88) { - weather = PlanetaryConditions.WE_DOWNPOUR; - } else if (roll < 94) { - weather = PlanetaryConditions.WE_LIGHT_SNOW; - } else if (roll < 96) { - weather = PlanetaryConditions.WE_MOD_SNOW; - } else if (roll < 97) { - weather = PlanetaryConditions.WE_HEAVY_SNOW; - } else if (roll < 99) { - weather = PlanetaryConditions.WE_SLEET; - } else { - weather = PlanetaryConditions.WE_ICE_STORM; - } + int[] odds = new int[]{48,12,10,8,6,4,6,2,1,2,1}; + int weather = rollCondition(odds); if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { return weather; @@ -424,33 +363,8 @@ private int rollWeatherWetCondition() { } private int rollWeatherSnowyCondition() { - int weather; - - int roll = Compute.randomInt(100) + 1; - - if (roll < 40) { - weather = PlanetaryConditions.WE_NONE; - } else if (roll < 47) { - weather = PlanetaryConditions.WE_LIGHT_RAIN; - } else if (roll < 51) { - weather = PlanetaryConditions.WE_MOD_RAIN; - } else if (roll < 55) { - weather = PlanetaryConditions.WE_HEAVY_RAIN; - } else if (roll < 57) { - weather = PlanetaryConditions.WE_GUSTING_RAIN; - } else if (roll < 58) { - weather = PlanetaryConditions.WE_DOWNPOUR; - } else if (roll < 70) { - weather = PlanetaryConditions.WE_LIGHT_SNOW; - } else if (roll < 80) { - weather = PlanetaryConditions.WE_MOD_SNOW; - } else if (roll < 88) { - weather = PlanetaryConditions.WE_HEAVY_SNOW; - } else if (roll < 94) { - weather = PlanetaryConditions.WE_SLEET; - } else { - weather = PlanetaryConditions.WE_ICE_STORM; - } + int[] odds = new int[]{40,7,4,4,2,1,12,10,8,6,6}; + int weather = rollCondition(odds); if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { return weather; @@ -460,33 +374,8 @@ private int rollWeatherSnowyCondition() { } private int rollWeatherDryCondition() { - int weather; - - int roll = Compute.randomInt(100) + 1; - - if (roll < 84) { - weather = PlanetaryConditions.WE_NONE; - } else if (roll < 88) { - weather = PlanetaryConditions.WE_LIGHT_RAIN; - } else if (roll < 90) { - weather = PlanetaryConditions.WE_MOD_RAIN; - } else if (roll < 92) { - weather = PlanetaryConditions.WE_HEAVY_RAIN; - } else if (roll < 93) { - weather = PlanetaryConditions.WE_GUSTING_RAIN; - } else if (roll < 94) { - weather = PlanetaryConditions.WE_DOWNPOUR; - } else if (roll < 95) { - weather = PlanetaryConditions.WE_LIGHT_SNOW; - } else if (roll < 97) { - weather = PlanetaryConditions.WE_MOD_SNOW; - } else if (roll < 98) { - weather = PlanetaryConditions.WE_HEAVY_SNOW; - } else if (roll < 99) { - weather = PlanetaryConditions.WE_SLEET; - } else { - weather = PlanetaryConditions.WE_ICE_STORM; - } + int[] odds = new int[]{88,2,1,1,1,1,2,1,1,1,1}; + int weather = rollCondition(odds); if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { return weather; @@ -496,17 +385,8 @@ private int rollWeatherDryCondition() { } private int rollFoggyCondition() { - int fog; - - int roll = Compute.randomInt(100) + 1; - - if (roll < 90) { - fog = PlanetaryConditions.FOG_NONE; - } else if (roll < 96) { - fog = PlanetaryConditions.FOG_LIGHT; - } else { - fog = PlanetaryConditions.FOG_HEAVY; - } + int[] odds = new int[]{90,5,5}; + int fog = rollCondition(odds); if (!WeatherRestriction.IsFogRestricted(fog, getAtmosphere(), getTemperature())) { return fog; @@ -516,17 +396,8 @@ private int rollFoggyCondition() { } private int rollFoggierCondition() { - int fog; - - int roll = Compute.randomInt(100) + 1; - - if (roll < 60) { - fog = PlanetaryConditions.FOG_NONE; - } else if (roll < 80) { - fog = PlanetaryConditions.FOG_LIGHT; - } else { - fog = PlanetaryConditions.FOG_HEAVY; - } + int[] odds = new int[]{60,20,20}; + int fog = rollCondition(odds); if (!WeatherRestriction.IsFogRestricted(fog, getAtmosphere(), getTemperature())) { return fog; @@ -536,15 +407,8 @@ private int rollFoggierCondition() { } private boolean rollBlowingSand() { - boolean blowingSand = false; - - int roll = Compute.randomInt(100) + 1; - - if (roll < 50) { - blowingSand = true; - } - - return blowingSand; + int[] odds = new int[]{60,40}; + return rollCondition(odds) == 1; } public void setWeather() { @@ -566,7 +430,6 @@ public void setWeather() { if (extremeCold) { weather = rollWeatherSnowyCondition(); fog = rollFoggyCondition(); - } else { weather = rollWeatherStandardCondition(); fog = rollFoggyCondition(); @@ -584,7 +447,6 @@ && rollBlowingSand()) { if (extremeCold) { weather = rollWeatherSnowyCondition(); fog = rollFoggierCondition(); - } else { weather = rollWeatherWetCondition(); fog = rollFoggierCondition(); From 342a2531cc79a42ca370eb0745bc14bec63fed89 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 11 Feb 2024 09:03:17 -0500 Subject: [PATCH 16/38] pass blowing sand and EMI to game when starting --- MekHQ/src/mekhq/AtBGameThread.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MekHQ/src/mekhq/AtBGameThread.java b/MekHQ/src/mekhq/AtBGameThread.java index 4ffeb07fab..6e72516aee 100644 --- a/MekHQ/src/mekhq/AtBGameThread.java +++ b/MekHQ/src/mekhq/AtBGameThread.java @@ -158,6 +158,8 @@ public void run() { planetaryConditions.setFog(scenario.getFog()); planetaryConditions.setAtmosphere(scenario.getAtmosphere()); planetaryConditions.setGravity(scenario.getGravity()); + planetaryConditions.setEMI(scenario.usesEMI()); + planetaryConditions.setBlowingSand(scenario.usesBlowingSand()); planetaryConditions.setTemperature(scenario.getTemperature()); client.sendPlanetaryConditions(planetaryConditions); Thread.sleep(MekHQ.getMHQOptions().getStartGameDelay()); From d4f99c2dded72376ba043631fd484caaaf559c49 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 11 Feb 2024 20:07:24 -0500 Subject: [PATCH 17/38] check that values returned are valid --- .../mekhq/campaign/mission/AtBScenario.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 2b573bbf4c..dd8e7cc307 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -322,7 +322,13 @@ private int rollCondition(int[] odds) { private int rollLightCondition() { int[] odds = new int[]{600,200,100,99,1}; - return rollCondition(odds); + int light = rollCondition(odds); + + if (light < PlanetaryConditions.L_DAY || light > PlanetaryConditions.L_PITCH_BLACK) { + return PlanetaryConditions.L_DAY; + } + + return light; } public void setLightConditions() { @@ -333,6 +339,10 @@ private int rollWindCondition() { int[] odds = new int[]{70,10,10,4,3,2,1}; int wind = rollCondition(odds); + if (wind < PlanetaryConditions.WI_NONE || wind > PlanetaryConditions.WI_TORNADO_F4) { + return PlanetaryConditions.WI_NONE; + } + if (!WeatherRestriction.IsWindRestricted(wind, getAtmosphere(), getTemperature())) { return wind; } else { @@ -344,6 +354,10 @@ private int rollWeatherStandardCondition() { int[] odds = new int[]{70,7,4,4,2,1,6,2,1,2,1}; int weather = rollCondition(odds); + if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { + return PlanetaryConditions.WE_NONE; + } + if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { return weather; } else { @@ -355,6 +369,10 @@ private int rollWeatherWetCondition() { int[] odds = new int[]{48,12,10,8,6,4,6,2,1,2,1}; int weather = rollCondition(odds); + if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { + return PlanetaryConditions.WE_NONE; + } + if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { return weather; } else { @@ -366,6 +384,10 @@ private int rollWeatherSnowyCondition() { int[] odds = new int[]{40,7,4,4,2,1,12,10,8,6,6}; int weather = rollCondition(odds); + if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { + return PlanetaryConditions.WE_NONE; + } + if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { return weather; } else { @@ -377,6 +399,10 @@ private int rollWeatherDryCondition() { int[] odds = new int[]{88,2,1,1,1,1,2,1,1,1,1}; int weather = rollCondition(odds); + if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { + return PlanetaryConditions.WE_NONE; + } + if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { return weather; } else { @@ -388,6 +414,10 @@ private int rollFoggyCondition() { int[] odds = new int[]{90,5,5}; int fog = rollCondition(odds); + if (fog < PlanetaryConditions.FOG_NONE || fog > PlanetaryConditions.FOG_HEAVY) { + return PlanetaryConditions.FOG_NONE; + } + if (!WeatherRestriction.IsFogRestricted(fog, getAtmosphere(), getTemperature())) { return fog; } else { @@ -399,6 +429,10 @@ private int rollFoggierCondition() { int[] odds = new int[]{60,20,20}; int fog = rollCondition(odds); + if (fog < PlanetaryConditions.FOG_NONE || fog > PlanetaryConditions.FOG_HEAVY) { + return PlanetaryConditions.FOG_NONE; + } + if (!WeatherRestriction.IsFogRestricted(fog, getAtmosphere(), getTemperature())) { return fog; } else { From e6c916b479e8cd1a9c0e0c09f687a33c91243caf Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 12 Feb 2024 18:10:53 -0500 Subject: [PATCH 18/38] move restricted check into rollBlowingSand() --- MekHQ/src/mekhq/campaign/mission/AtBScenario.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index dd8e7cc307..ea6566aae6 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -442,7 +442,8 @@ private int rollFoggierCondition() { private boolean rollBlowingSand() { int[] odds = new int[]{60,40}; - return rollCondition(odds) == 1; + boolean moderateGaleRestricted = WeatherRestriction.IsWindRestricted(PlanetaryConditions.WI_MOD_GALE, getAtmosphere(), getTemperature()); + return !moderateGaleRestricted && rollCondition(odds) == 1; } public void setWeather() { @@ -451,7 +452,6 @@ public void setWeather() { boolean blowingSand = false; boolean extremeHeat = PlanetaryConditions.isExtremeTemperature(getTemperature()) && (getTemperature() > 0); boolean extremeCold = PlanetaryConditions.isExtremeTemperature(getTemperature()) && (getTemperature() < 0); - boolean moderateGaleRestricted = WeatherRestriction.IsWindRestricted(PlanetaryConditions.WI_MOD_GALE, getAtmosphere(), getTemperature()); int wind = rollWindCondition(); @@ -470,7 +470,6 @@ public void setWeather() { if (weather == PlanetaryConditions.WE_NONE && fog == PlanetaryConditions.FOG_NONE && extremeHeat - && !moderateGaleRestricted && rollBlowingSand()) { blowingSand = true; } @@ -493,7 +492,6 @@ && rollBlowingSand()) { case TER_BADLANDS: weather = rollWeatherDryCondition(); if (weather == PlanetaryConditions.WE_NONE - && !moderateGaleRestricted && rollBlowingSand()) { blowingSand = true; } From 3e1203012878fc7301068ad795db33580eac6a8c Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 12 Feb 2024 18:46:45 -0500 Subject: [PATCH 19/38] correct miss chance --- MekHQ/src/mekhq/campaign/mission/AtBScenario.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index ea6566aae6..8a0fc1621b 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -351,7 +351,7 @@ private int rollWindCondition() { } private int rollWeatherStandardCondition() { - int[] odds = new int[]{70,7,4,4,2,1,6,2,1,2,1}; + int[] odds = new int[]{69,7,4,4,2,1,6,2,1,2,1,1}; int weather = rollCondition(odds); if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { @@ -366,7 +366,7 @@ private int rollWeatherStandardCondition() { } private int rollWeatherWetCondition() { - int[] odds = new int[]{48,12,10,8,6,4,6,2,1,2,1}; + int[] odds = new int[]{47,12,10,8,6,4,6,2,1,2,1,1}; int weather = rollCondition(odds); if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { @@ -381,7 +381,7 @@ private int rollWeatherWetCondition() { } private int rollWeatherSnowyCondition() { - int[] odds = new int[]{40,7,4,4,2,1,12,10,8,6,6}; + int[] odds = new int[]{41,6,3,3,1,1,12,10,8,6,6,3}; int weather = rollCondition(odds); if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { @@ -396,7 +396,7 @@ private int rollWeatherSnowyCondition() { } private int rollWeatherDryCondition() { - int[] odds = new int[]{88,2,1,1,1,1,2,1,1,1,1}; + int[] odds = new int[]{87,2,1,1,1,1,2,1,1,1,1,1}; int weather = rollCondition(odds); if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { From 87266530e5963f31deb182a4cc90d200d6a7e075 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 12 Feb 2024 18:52:48 -0500 Subject: [PATCH 20/38] correct miss chance --- MekHQ/src/mekhq/campaign/mission/AtBScenario.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 8a0fc1621b..2d5a8b3319 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -351,7 +351,7 @@ private int rollWindCondition() { } private int rollWeatherStandardCondition() { - int[] odds = new int[]{69,7,4,4,2,1,6,2,1,2,1,1}; + int[] odds = new int[]{69,7,4,4,2,1,6,2,1,1,2,1}; int weather = rollCondition(odds); if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { @@ -366,7 +366,7 @@ private int rollWeatherStandardCondition() { } private int rollWeatherWetCondition() { - int[] odds = new int[]{47,12,10,8,6,4,6,2,1,2,1,1}; + int[] odds = new int[]{47,12,10,8,6,4,6,2,1,1,2,1}; int weather = rollCondition(odds); if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { From 7c46fc9533a17eafb3a17118437fb9c0d3b96219 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 12 Feb 2024 21:04:26 -0500 Subject: [PATCH 21/38] remove tempature logic to make converting to a config file simpler in the future --- .../mekhq/campaign/mission/AtBScenario.java | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 2d5a8b3319..731bb2445a 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -440,7 +440,13 @@ private int rollFoggierCondition() { } } - private boolean rollBlowingSand() { + private boolean rollBlowingSandCondition() { + int[] odds = new int[]{60,40}; + boolean moderateGaleRestricted = WeatherRestriction.IsWindRestricted(PlanetaryConditions.WI_MOD_GALE, getAtmosphere(), getTemperature()); + return !moderateGaleRestricted && rollCondition(odds) == 1; + } + + private boolean rollBlowingSandHeavyCondition() { int[] odds = new int[]{60,40}; boolean moderateGaleRestricted = WeatherRestriction.IsWindRestricted(PlanetaryConditions.WI_MOD_GALE, getAtmosphere(), getTemperature()); return !moderateGaleRestricted && rollCondition(odds) == 1; @@ -450,8 +456,6 @@ public void setWeather() { int weather = PlanetaryConditions.WE_NONE; int fog = PlanetaryConditions.FOG_NONE; boolean blowingSand = false; - boolean extremeHeat = PlanetaryConditions.isExtremeTemperature(getTemperature()) && (getTemperature() > 0); - boolean extremeCold = PlanetaryConditions.isExtremeTemperature(getTemperature()) && (getTemperature() < 0); int wind = rollWindCondition(); @@ -461,29 +465,18 @@ public void setWeather() { case TER_FLATLANDS: case TER_WOODED: case TER_HEAVYURBAN: - if (extremeCold) { - weather = rollWeatherSnowyCondition(); - fog = rollFoggyCondition(); - } else { - weather = rollWeatherStandardCondition(); - fog = rollFoggyCondition(); - if (weather == PlanetaryConditions.WE_NONE - && fog == PlanetaryConditions.FOG_NONE - && extremeHeat - && rollBlowingSand()) { - blowingSand = true; - } + weather = rollWeatherStandardCondition(); + fog = rollFoggyCondition(); + if (weather == PlanetaryConditions.WE_NONE + && fog == PlanetaryConditions.FOG_NONE + && rollBlowingSandCondition()) { + blowingSand = true; } break; case TER_COASTAL: case TER_WETLANDS: - if (extremeCold) { - weather = rollWeatherSnowyCondition(); - fog = rollFoggierCondition(); - } else { - weather = rollWeatherWetCondition(); - fog = rollFoggierCondition(); - } + weather = rollWeatherWetCondition(); + fog = rollFoggierCondition(); break; case TER_MOUNTAINS: weather = rollWeatherSnowyCondition(); @@ -492,7 +485,7 @@ && rollBlowingSand()) { case TER_BADLANDS: weather = rollWeatherDryCondition(); if (weather == PlanetaryConditions.WE_NONE - && rollBlowingSand()) { + && rollBlowingSandHeavyCondition()) { blowingSand = true; } break; From d27a234203cc73de110c10afcdf81a574104dbdc Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 13 Feb 2024 19:13:57 -0500 Subject: [PATCH 22/38] use map type to determine odds --- .../mekhq/campaign/mission/AtBScenario.java | 361 ++++++++++++------ .../stratcon/StratconRulesManager.java | 1 + .../mekhq/gui/view/AtBScenarioViewPanel.java | 11 - 3 files changed, 251 insertions(+), 122 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 731bb2445a..6c91d3d074 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -321,7 +321,58 @@ private int rollCondition(int[] odds) { } private int rollLightCondition() { - int[] odds = new int[]{600,200,100,99,1}; + int[] odds; + + switch (getMap()) { + case "City-dense": + case "City-high": + case "Cliffs": + case "Cliffs-lake": + case "Dust-bowl": + case "Fortress-city": + case "Heavy-craters": + case "Hills": + case "Hills-craters": + case "Lake-high": + case "Lake-marsh": + case "Light-craters": + case "Mountain-high": + case "Mountain-lake": + case "Mountain-medium": + case "Muddy-swamp": + case "River-huge": + case "River-wetlands": + case "Rocky-valley": + case "Rubble-mountain": + case "Rubble-river": + case "Sandy-hills": + case "Sandy-river": + case "Sandy-valley": + case "Savannah": + case "Seaport": + case "Some-trees": + case "Swamp": + case "Town-concrete": + case "Town-farming": + case "Town-generic": + case "Town-hills": + case "Town-mining": + case "Town-mountain": + case "Town-ruin": + case "Town-wooded": + case "Wooded-hills": + case "Wooded-lake": + case "Wooded-swamp": + case "Wooded-valley": + case "Woods-deep": + case "Woods-medium": + case "Woods-river": + odds = new int[]{600,200,100,99,1}; + break; + default: + return PlanetaryConditions.L_DAY; + } + int light = rollCondition(odds); if (light < PlanetaryConditions.L_DAY || light > PlanetaryConditions.L_PITCH_BLACK) { @@ -336,7 +387,60 @@ public void setLightConditions() { } private int rollWindCondition() { - int[] odds = new int[]{70,10,10,4,3,2,1}; + int[] odds; + + switch (getMap()) { + case "City-dense": + case "City-high": + case "Fortress-city": + case "Hills": + case "Lake-marsh": + case "Mountain-medium": + case "Muddy-swamp": + case "River-wetlands": + case "Sandy-hills": + case "Sandy-valley": + case "Some-trees": + case "Swamp": + case "Town-concrete": + case "Town-farming": + case "Town-generic": + case "Town-hills": + case "Town-mining": + case "Town-mountain": + case "Town-ruin": + case "Town-wooded": + case "Wooded-hills": + case "Wooded-lake": + case "Wooded-swamp": + case "Wooded-valley": + case "Woods-deep": + case "Woods-medium": + case "Woods-river": + odds = new int[]{70,10,10,4,3,2,1}; + break; + case "Cliffs": + case "Cliffs-lake": + case "Dust-bowl": + case "Heavy-craters": + case "Hills-craters": + case "Lake-high": + case "Light-craters": + case "Mountain-high": + case "Mountain-lake": + case "River-huge": + case "Rocky-valley": + case "Rubble-mountain": + case "Rubble-river": + case "Sandy-river": + case "Savannah": + case "Seaport": + odds = new int[]{50,15,15,9,5,4,2}; + break; + default: + return PlanetaryConditions.WI_NONE; + } + int wind = rollCondition(odds); if (wind < PlanetaryConditions.WI_NONE || wind > PlanetaryConditions.WI_TORNADO_F4) { @@ -350,38 +454,65 @@ private int rollWindCondition() { } } - private int rollWeatherStandardCondition() { - int[] odds = new int[]{69,7,4,4,2,1,6,2,1,1,2,1}; - int weather = rollCondition(odds); - - if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { - return PlanetaryConditions.WE_NONE; - } - - if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { - return weather; - } else { - return PlanetaryConditions.WE_NONE; - } - } - - private int rollWeatherWetCondition() { - int[] odds = new int[]{47,12,10,8,6,4,6,2,1,1,2,1}; - int weather = rollCondition(odds); - - if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { - return PlanetaryConditions.WE_NONE; - } - - if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { - return weather; - } else { - return PlanetaryConditions.WE_NONE; + private int rollWeatherCondition() { + int[] odds; + + switch (getMap()) { + case "City-dense": + case "City-high": + case "Fortress-city": + case "Hills": + case "Sandy-hills": + case "Sandy-valley": + case "Savannah": + case "Some-trees": + case "Town-concrete": + case "Town-farming": + case "Town-generic": + case "Town-hills": + case "Town-ruin": + case "Town-wooded": + case "Wooded-hills": + case "Wooded-valley": + case "Woods-deep": + case "Woods-medium": + odds = new int[]{69,7,4,4,2,1,6,2,1,1,2,1}; + break; + case "Cliffs-lake": + case "Lake-marsh": + case "Lake-high": + case "Muddy-swamp": + case "River-huge": + case "River-wetlands": + case "Rubble-river": + case "Sandy-river": + case "Seaport": + case "Swamp": + case "Wooded-lake": + case "Woods-river": + case "Wooded-swamp": + odds = new int[]{47,12,10,8,6,4,6,2,1,1,2,1}; + break; + case "Mountain-high": + case "Mountain-lake": + case "Mountain-medium": + case "Town-mining": + case "Town-mountain": + odds = new int[]{41,6,3,3,1,1,12,10,8,6,6,3}; + break; + case "Cliffs": + case "Dust-bowl": + case "Heavy-craters": + case "Hills-craters": + case "Light-craters": + case "Rocky-valley": + case "Rubble-mountain": + odds = new int[]{87,2,1,1,1,1,2,1,1,1,1,1}; + break; + default: + return PlanetaryConditions.WE_NONE; } - } - private int rollWeatherSnowyCondition() { - int[] odds = new int[]{41,6,3,3,1,1,12,10,8,6,6,3}; int weather = rollCondition(odds); if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { @@ -395,23 +526,54 @@ private int rollWeatherSnowyCondition() { } } - private int rollWeatherDryCondition() { - int[] odds = new int[]{87,2,1,1,1,1,2,1,1,1,1,1}; - int weather = rollCondition(odds); - - if (weather < PlanetaryConditions.WE_NONE || weather > PlanetaryConditions.WE_ICE_STORM) { - return PlanetaryConditions.WE_NONE; - } - - if (!WeatherRestriction.IsWeatherRestricted(weather, getAtmosphere(), getTemperature())) { - return weather; - } else { - return PlanetaryConditions.WE_NONE; + private int rollFogCondition() { + int[] odds; + + switch (getMap()) { + case "City-dense": + case "City-high": + case "Fortress-city": + case "Hills": + case "Mountain-high": + case "Mountain-medium": + case "Sandy-hills": + case "Sandy-valley": + case "Savannah": + case "Some-trees": + case "Town-concrete": + case "Town-farming": + case "Town-generic": + case "Town-hills": + case "Town-mining": + case "Town-mountain": + case "Town-ruin": + case "Town-wooded": + case "Wooded-hills": + case "Wooded-valley": + case "Woods-deep": + case "Woods-medium": + odds = new int[]{90,5,5}; + break; + case "Cliffs-lake": + case "Lake-marsh": + case "Lake-high": + case "Mountain-lake": + case "Muddy-swamp": + case "River-huge": + case "River-wetlands": + case "Rubble-river": + case "Sandy-river": + case "Seaport": + case "Swamp": + case "Wooded-lake": + case "Woods-river": + case "Wooded-swamp": + odds = new int[]{60,20,20}; + break; + default: + return PlanetaryConditions.FOG_NONE; } - } - private int rollFoggyCondition() { - int[] odds = new int[]{90,5,5}; int fog = rollCondition(odds); if (fog < PlanetaryConditions.FOG_NONE || fog > PlanetaryConditions.FOG_HEAVY) { @@ -425,81 +587,58 @@ private int rollFoggyCondition() { } } - private int rollFoggierCondition() { - int[] odds = new int[]{60,20,20}; - int fog = rollCondition(odds); + private boolean rollBlowingSandCondition(int wind, int weather, int fog) { + int[] odds; + boolean moderateGaleRestricted = WeatherRestriction.IsWindRestricted(PlanetaryConditions.WI_MOD_GALE, getAtmosphere(), getTemperature()); - if (fog < PlanetaryConditions.FOG_NONE || fog > PlanetaryConditions.FOG_HEAVY) { - return PlanetaryConditions.FOG_NONE; + if (weather != PlanetaryConditions.WE_NONE + && fog != PlanetaryConditions.FOG_NONE + && wind < PlanetaryConditions.WI_MOD_GALE + && !moderateGaleRestricted) { + return false; } - if (!WeatherRestriction.IsFogRestricted(fog, getAtmosphere(), getTemperature())) { - return fog; - } else { - return PlanetaryConditions.FOG_NONE; + switch (getMap()) { + case "City-dense": + case "City-high": + case "Fortress-city": + case "Hills": + case "Sandy-hills": + case "Sandy-valley": + case "Savannah": + case "Town-concrete": + case "Town-farming": + case "Town-generic": + case "Town-hills": + case "Town-mining": + case "Town-mountain": + case "Town-ruin": + odds = new int[]{90,10}; + break; + case "Cliffs": + case "Dust-bowl": + case "Heavy-craters": + case "Hills-craters": + case "Light-craters": + case "Rocky-valley": + case "Rubble-mountain": + odds = new int[]{40,60}; + break; + default: + return false; } - } - - private boolean rollBlowingSandCondition() { - int[] odds = new int[]{60,40}; - boolean moderateGaleRestricted = WeatherRestriction.IsWindRestricted(PlanetaryConditions.WI_MOD_GALE, getAtmosphere(), getTemperature()); - return !moderateGaleRestricted && rollCondition(odds) == 1; - } - private boolean rollBlowingSandHeavyCondition() { - int[] odds = new int[]{60,40}; - boolean moderateGaleRestricted = WeatherRestriction.IsWindRestricted(PlanetaryConditions.WI_MOD_GALE, getAtmosphere(), getTemperature()); - return !moderateGaleRestricted && rollCondition(odds) == 1; + return rollCondition(odds) == 1; } public void setWeather() { - int weather = PlanetaryConditions.WE_NONE; - int fog = PlanetaryConditions.FOG_NONE; - boolean blowingSand = false; - int wind = rollWindCondition(); + int weather = rollWeatherCondition(); + int fog = rollFogCondition(); + boolean blowingSand = rollBlowingSandCondition(wind, weather, fog); - switch (getTerrainType()) { - case TER_HILLS: - case TER_LIGHTURBAN: - case TER_FLATLANDS: - case TER_WOODED: - case TER_HEAVYURBAN: - weather = rollWeatherStandardCondition(); - fog = rollFoggyCondition(); - if (weather == PlanetaryConditions.WE_NONE - && fog == PlanetaryConditions.FOG_NONE - && rollBlowingSandCondition()) { - blowingSand = true; - } - break; - case TER_COASTAL: - case TER_WETLANDS: - weather = rollWeatherWetCondition(); - fog = rollFoggierCondition(); - break; - case TER_MOUNTAINS: - weather = rollWeatherSnowyCondition(); - fog = rollFoggyCondition(); - break; - case TER_BADLANDS: - weather = rollWeatherDryCondition(); - if (weather == PlanetaryConditions.WE_NONE - && rollBlowingSandHeavyCondition()) { - blowingSand = true; - } - break; - default: - weather = rollWeatherStandardCondition(); - fog = rollFoggyCondition(); - } - + setWind(wind); setWeather(weather); - if (blowingSand && wind < PlanetaryConditions.WI_MOD_GALE) { - setWind(PlanetaryConditions.WI_MOD_GALE); - } else { - setWind(wind); - } setFog(fog); setBlowingSand(blowingSand); } diff --git a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java index 0fa29f5fda..993b596625 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java +++ b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java @@ -230,6 +230,7 @@ public static void setScenarioParametersFromBiome(StratconTrackState track, Stra if (backingScenario.getTerrainType() != Scenario.TER_SPACE) { var mapTypeList = mapTypes.get(terrainType).mapTypes; backingScenario.setMap(mapTypeList.get(Compute.randomInt(mapTypeList.size()))); + backingScenario.setWeather(); } } diff --git a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java index 798cb50f75..5e946a4a2f 100644 --- a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java @@ -480,17 +480,6 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB chkReroll[REROLL_TERRAIN].addItemListener(checkBoxListener); } - lblTerrainDesc.setText(AtBScenario.terrainTypes[scenario.getTerrainType()]); - gridBagConstraints.gridx = 2; - gridBagConstraints.gridy = y++; - panStats.add(lblTerrainDesc, gridBagConstraints); - } else { - lblTerrain.setText(resourceMap.getString("lblTerrain.text")); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = y; - gridBagConstraints.gridwidth = 1; - panStats.add(lblTerrain, gridBagConstraints); - lblTerrainDesc.setText(AtBScenario.terrainTypes[scenario.getTerrainType()]); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = y++; From dfd043342659ec88547a4bc23ae174d68db8eff4 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 13 Feb 2024 19:24:42 -0500 Subject: [PATCH 23/38] add dark group --- MekHQ/src/mekhq/campaign/mission/AtBScenario.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 6c91d3d074..963b1f12a4 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -326,16 +326,12 @@ private int rollLightCondition() { switch (getMap()) { case "City-dense": case "City-high": - case "Cliffs": case "Cliffs-lake": case "Dust-bowl": case "Fortress-city": - case "Heavy-craters": case "Hills": - case "Hills-craters": case "Lake-high": case "Lake-marsh": - case "Light-craters": case "Mountain-high": case "Mountain-lake": case "Mountain-medium": @@ -369,6 +365,12 @@ private int rollLightCondition() { case "Woods-river": odds = new int[]{600,200,100,99,1}; break; + case "Cliffs": + case "Heavy-craters": + case "Hills-craters": + case "Light-craters": + odds = new int[]{50,20,10,10,10}; + break; default: return PlanetaryConditions.L_DAY; } From 2463b905a230c31b81022124d96db960ce43cdfc Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Wed, 14 Feb 2024 17:38:01 -0500 Subject: [PATCH 24/38] code cleanup --- .../mission/AtBDynamicScenarioFactory.java | 6 ---- .../mekhq/campaign/mission/AtBScenario.java | 35 ++++++++++++++----- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index a5f2bea7df..d40571fe41 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -717,12 +717,6 @@ private static void setLightConditions(AtBDynamicScenario scenario) { * @param scenario The scenario for which to set weather conditions. */ private static void setWeather(AtBDynamicScenario scenario) { - // weather is irrelevant in these situations. - if (scenario.getTerrainType() == AtBScenario.TER_SPACE || - scenario.getTerrainType() == AtBScenario.TER_LOW_ATMO) { - return; - } - scenario.setWeather(); } diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 963b1f12a4..49293456bf 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -363,12 +363,14 @@ private int rollLightCondition() { case "Woods-deep": case "Woods-medium": case "Woods-river": + // standard odds = new int[]{600,200,100,99,1}; break; case "Cliffs": case "Heavy-craters": case "Hills-craters": case "Light-craters": + // dark odds = new int[]{50,20,10,10,10}; break; default: @@ -384,10 +386,6 @@ private int rollLightCondition() { return light; } - public void setLightConditions() { - setLight(rollLightCondition()); - } - private int rollWindCondition() { int[] odds; @@ -419,6 +417,7 @@ private int rollWindCondition() { case "Woods-deep": case "Woods-medium": case "Woods-river": + // standard odds = new int[]{70,10,10,4,3,2,1}; break; case "Cliffs": @@ -437,6 +436,7 @@ private int rollWindCondition() { case "Sandy-river": case "Savannah": case "Seaport": + // high odds = new int[]{50,15,15,9,5,4,2}; break; default: @@ -478,11 +478,12 @@ private int rollWeatherCondition() { case "Wooded-valley": case "Woods-deep": case "Woods-medium": + // standard odds = new int[]{69,7,4,4,2,1,6,2,1,1,2,1}; break; case "Cliffs-lake": - case "Lake-marsh": case "Lake-high": + case "Lake-marsh": case "Muddy-swamp": case "River-huge": case "River-wetlands": @@ -491,8 +492,9 @@ private int rollWeatherCondition() { case "Seaport": case "Swamp": case "Wooded-lake": - case "Woods-river": case "Wooded-swamp": + case "Woods-river": + // wet odds = new int[]{47,12,10,8,6,4,6,2,1,1,2,1}; break; case "Mountain-high": @@ -500,6 +502,7 @@ private int rollWeatherCondition() { case "Mountain-medium": case "Town-mining": case "Town-mountain": + // snowy odds = new int[]{41,6,3,3,1,1,12,10,8,6,6,3}; break; case "Cliffs": @@ -509,6 +512,7 @@ private int rollWeatherCondition() { case "Light-craters": case "Rocky-valley": case "Rubble-mountain": + // dry odds = new int[]{87,2,1,1,1,1,2,1,1,1,1,1}; break; default: @@ -554,11 +558,12 @@ private int rollFogCondition() { case "Wooded-valley": case "Woods-deep": case "Woods-medium": + // standard odds = new int[]{90,5,5}; break; case "Cliffs-lake": - case "Lake-marsh": case "Lake-high": + case "Lake-marsh": case "Mountain-lake": case "Muddy-swamp": case "River-huge": @@ -568,8 +573,9 @@ private int rollFogCondition() { case "Seaport": case "Swamp": case "Wooded-lake": - case "Woods-river": case "Wooded-swamp": + case "Woods-river": + // heavy odds = new int[]{60,20,20}; break; default: @@ -606,6 +612,7 @@ private boolean rollBlowingSandCondition(int wind, int weather, int fog) { case "Fortress-city": case "Hills": case "Sandy-hills": + case "Sandy-river": case "Sandy-valley": case "Savannah": case "Town-concrete": @@ -615,6 +622,7 @@ private boolean rollBlowingSandCondition(int wind, int weather, int fog) { case "Town-mining": case "Town-mountain": case "Town-ruin": + // standard odds = new int[]{90,10}; break; case "Cliffs": @@ -624,6 +632,7 @@ private boolean rollBlowingSandCondition(int wind, int weather, int fog) { case "Light-craters": case "Rocky-valley": case "Rubble-mountain": + // heavy odds = new int[]{40,60}; break; default: @@ -633,7 +642,17 @@ private boolean rollBlowingSandCondition(int wind, int weather, int fog) { return rollCondition(odds) == 1; } + public void setLightConditions() { + setLight(rollLightCondition()); + } + public void setWeather() { + // weather is irrelevant in these situations. + if (getTerrainType() == AtBScenario.TER_SPACE || + getTerrainType() == AtBScenario.TER_LOW_ATMO) { + return; + } + int wind = rollWindCondition(); int weather = rollWeatherCondition(); int fog = rollFogCondition(); From 65103dcaa5caa2b9956ca07d84bc8faf8927f0b6 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Wed, 14 Feb 2024 19:34:59 -0500 Subject: [PATCH 25/38] add emi, set odds when fixed map --- .../resources/AtBScenarioViewPanel.properties | 1 + .../resources/ScenarioViewPanel.properties | 1 + .../mekhq/campaign/mission/AtBScenario.java | 102 +++++++++++++++++- .../src/mekhq/campaign/mission/Scenario.java | 5 + .../mekhq/gui/view/AtBScenarioViewPanel.java | 18 ++++ .../src/mekhq/gui/view/ScenarioViewPanel.java | 11 +- 6 files changed, 132 insertions(+), 6 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/AtBScenarioViewPanel.properties b/MekHQ/resources/mekhq/resources/AtBScenarioViewPanel.properties index 4d6c1a2590..56a7d315a4 100644 --- a/MekHQ/resources/mekhq/resources/AtBScenarioViewPanel.properties +++ b/MekHQ/resources/mekhq/resources/AtBScenarioViewPanel.properties @@ -9,6 +9,7 @@ lblWeather.text=Weather: lblWind.text=Wind: lblFog.text=Fog: lblBlowingSand.text=Blowing Sand: +lblEMI.text=EMI: lblAtmosphere.text=Atmosphere: lblGravity.text=Gravity: lblPlayerStart.text=Player Start: diff --git a/MekHQ/resources/mekhq/resources/ScenarioViewPanel.properties b/MekHQ/resources/mekhq/resources/ScenarioViewPanel.properties index 8d7fbf73ec..62b0e06693 100644 --- a/MekHQ/resources/mekhq/resources/ScenarioViewPanel.properties +++ b/MekHQ/resources/mekhq/resources/ScenarioViewPanel.properties @@ -16,6 +16,7 @@ lblWeather.text=Weather: lblWind.text=Wind: lblFog.text=Fog: lblBlowingSand.text=Blowing Sand: +lblEMI.text=EMI: lblAtmosphere.text=Atmosphere: lblGravity.text=Gravity: lblTemperature.text=Temperature: diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 49293456bf..425287eb16 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -374,7 +374,12 @@ private int rollLightCondition() { odds = new int[]{50,20,10,10,10}; break; default: - return PlanetaryConditions.L_DAY; + if (isUsingFixedMap()) { + // fixed + odds = new int[]{600, 200, 100, 99, 1}; + } else { + return PlanetaryConditions.L_DAY; + } } int light = rollCondition(odds); @@ -440,7 +445,12 @@ private int rollWindCondition() { odds = new int[]{50,15,15,9,5,4,2}; break; default: - return PlanetaryConditions.WI_NONE; + if (isUsingFixedMap()) { + // fixed + odds = new int[]{70,10,10,4,3,2,1}; + } else { + return PlanetaryConditions.WI_NONE; + } } int wind = rollCondition(odds); @@ -516,7 +526,12 @@ private int rollWeatherCondition() { odds = new int[]{87,2,1,1,1,1,2,1,1,1,1,1}; break; default: - return PlanetaryConditions.WE_NONE; + if (isUsingFixedMap()) { + // fixed + odds = new int[]{69,7,4,4,2,1,6,2,1,1,2,1}; + } else { + return PlanetaryConditions.WE_NONE; + } } int weather = rollCondition(odds); @@ -579,7 +594,12 @@ private int rollFogCondition() { odds = new int[]{60,20,20}; break; default: - return PlanetaryConditions.FOG_NONE; + if (isUsingFixedMap()) { + // fixed + odds = new int[]{90,5,5}; + } else { + return PlanetaryConditions.FOG_NONE; + } } int fog = rollCondition(odds); @@ -636,7 +656,77 @@ private boolean rollBlowingSandCondition(int wind, int weather, int fog) { odds = new int[]{40,60}; break; default: - return false; + if (isUsingFixedMap()) { + // fixed + odds = new int[]{90,10}; + } else { + return false; + } + } + + return rollCondition(odds) == 1; + } + + private boolean rollEMICondition() { + int[] odds; + + switch (getMap()) { + case "City-dense": + case "City-high": + case "Fortress-city": + case "Hills": + case "Lake-high": + case "Lake-marsh": + case "Muddy-swamp": + case "River-huge": + case "River-wetlands": + case "Sandy-hills": + case "Sandy-river": + case "Sandy-valley": + case "Savannah": + case "Seaport": + case "Some-trees": + case "Swamp": + case "Town-concrete": + case "Town-farming": + case "Town-generic": + case "Town-hills": + case "Town-wooded": + case "Wooded-hills": + case "Wooded-lake": + case "Wooded-swamp": + case "Wooded-valley": + case "Woods-deep": + case "Woods-medium": + case "Woods-river": + // standard + odds = new int[]{999,1}; + break; + case "Cliffs": + case "Cliffs-lake": + case "Dust-bowl": + case "Heavy-craters": + case "Hills-craters": + case "Light-craters": + case "Mountain-high": + case "Mountain-lake": + case "Mountain-medium": + case "Rocky-valley": + case "Rubble-mountain": + case "Rubble-river": + case "Town-mining": + case "Town-mountain": + case "Town-ruin": + // heavy + odds = new int[]{90,10}; + break; + default: + if (isUsingFixedMap()) { + // fixed + odds = new int[]{999,1}; + } else { + return false; + } } return rollCondition(odds) == 1; @@ -657,11 +747,13 @@ public void setWeather() { int weather = rollWeatherCondition(); int fog = rollFogCondition(); boolean blowingSand = rollBlowingSandCondition(wind, weather, fog); + boolean emi = rollEMICondition(); setWind(wind); setWeather(weather); setFog(fog); setBlowingSand(blowingSand); + setEMI(emi); } public void setPlanetaryConditions(Mission mission, Campaign campaign) { diff --git a/MekHQ/src/mekhq/campaign/mission/Scenario.java b/MekHQ/src/mekhq/campaign/mission/Scenario.java index 0a4c78e248..0280b11961 100644 --- a/MekHQ/src/mekhq/campaign/mission/Scenario.java +++ b/MekHQ/src/mekhq/campaign/mission/Scenario.java @@ -354,6 +354,10 @@ public void setEMI(boolean emi) { this.emi = emi; } + public boolean getEMI() { + return emi; + } + public boolean usesBlowingSand() { return blowingSand; } @@ -361,6 +365,7 @@ public boolean usesBlowingSand() { public void setBlowingSand(boolean blow) { this.blowingSand = blow; } + public boolean getBlowingSand() { return blowingSand; } diff --git a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java index 5e946a4a2f..634b8d8ba4 100644 --- a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java @@ -81,6 +81,8 @@ public class AtBScenarioViewPanel extends JScrollablePanel { private JLabel lblFogDesc = new JLabel(); private JLabel lblBlowingSand = new JLabel(); private JLabel lblBlowingSandDesc = new JLabel(); + private JLabel lblEMI = new JLabel(); + private JLabel lblEMIDesc = new JLabel(); private JLabel lblTemp = new JLabel(); @@ -614,6 +616,20 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB lblBlowingSand.setVisible(campaign.getCampaignOptions().isUseWeatherConditions()); lblBlowingSandDesc.setVisible(campaign.getCampaignOptions().isUseWeatherConditions()); + lblEMI.setText(resourceMap.getString("lblEMI.text")); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = y; + gridBagConstraints.gridwidth = 1; + panStats.add(lblEMI, gridBagConstraints); + + String emiDesc = scenario.getEMI() ? PlanetaryConditions.MSG_NAME_EMI_TRUE : PlanetaryConditions.MSG_NAME_EMI_FALSE; + lblEMIDesc.setText(emiDesc); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = y++; + panStats.add(lblEMIDesc, gridBagConstraints); + lblEMI.setVisible(campaign.getCampaignOptions().isUseWeatherConditions()); + lblEMIDesc.setVisible(campaign.getCampaignOptions().isUseWeatherConditions()); + lblTemp.setText(resourceMap.getString("lblTemperature.text")); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = y; @@ -800,6 +816,8 @@ private void rerollBattleConditions() { lblFogDesc.setText(PlanetaryConditions.getFogDisplayableName(scenario.getFog())); String blowingSandDesc = scenario.getBlowingSand() ? PlanetaryConditions.MSG_NAME_BLOWINGSAND_TRUE : PlanetaryConditions.MSG_NAME_BLOWINGSAND_FALSE; lblBlowingSandDesc.setText(blowingSandDesc); + String emiDesc = scenario.getEMI() ? PlanetaryConditions.MSG_NAME_EMI_TRUE : PlanetaryConditions.MSG_NAME_EMI_FALSE; + lblEMIDesc.setText(emiDesc); } btnReroll.setText(scenario.getRerollsRemaining() + " Reroll" + ((scenario.getRerollsRemaining() == 1)?"":"s") + diff --git a/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java index 19745a6c6c..5bcc9fbd54 100644 --- a/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java @@ -452,7 +452,7 @@ private void fillMapData() { rightGbc.gridy++; pnlMap.add(lblFogDesc, rightGbc); - JLabel lblBlowingSand = new JLabel(resourceMap.getString("lblFog.text")); + JLabel lblBlowingSand = new JLabel(resourceMap.getString("lblBlowingSand.text")); leftGbc.gridy++; pnlMap.add(lblBlowingSand, leftGbc); @@ -461,6 +461,15 @@ private void fillMapData() { rightGbc.gridy++; pnlMap.add(lblBlowingSandDesc, rightGbc); + JLabel lblEMI = new JLabel(resourceMap.getString("lblEMI.text")); + leftGbc.gridy++; + pnlMap.add(lblEMI, leftGbc); + + String emiDesc = scenario.getEMI() ? PlanetaryConditions.MSG_NAME_EMI_TRUE : PlanetaryConditions.MSG_NAME_EMI_FALSE; + JLabel lblEMIDesc = new JLabel(emiDesc); + rightGbc.gridy++; + pnlMap.add(lblEMIDesc, rightGbc); + JLabel lblTemperature = new JLabel(resourceMap.getString("lblTemperature.text")); leftGbc.gridy++; pnlMap.add(lblTemperature, leftGbc); From 083e9f60d01e7a3d756d86a1239373d22888a977 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Wed, 14 Feb 2024 20:09:01 -0500 Subject: [PATCH 26/38] code cleanup --- .../mekhq/campaign/mission/AtBScenario.java | 76 +++++++------------ 1 file changed, 28 insertions(+), 48 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 425287eb16..a1fdcbac63 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -322,8 +322,10 @@ private int rollCondition(int[] odds) { private int rollLightCondition() { int[] odds; + String mapType = isUsingFixedMap() ? "Fixed" : getMap(); - switch (getMap()) { + switch (mapType) { + case "Fixed": case "City-dense": case "City-high": case "Cliffs-lake": @@ -374,12 +376,7 @@ private int rollLightCondition() { odds = new int[]{50,20,10,10,10}; break; default: - if (isUsingFixedMap()) { - // fixed - odds = new int[]{600, 200, 100, 99, 1}; - } else { - return PlanetaryConditions.L_DAY; - } + return PlanetaryConditions.L_DAY; } int light = rollCondition(odds); @@ -393,8 +390,10 @@ private int rollLightCondition() { private int rollWindCondition() { int[] odds; + String mapType = isUsingFixedMap() ? "Fixed" : getMap(); - switch (getMap()) { + switch (mapType) { + case "Fixed": case "City-dense": case "City-high": case "Fortress-city": @@ -445,12 +444,7 @@ private int rollWindCondition() { odds = new int[]{50,15,15,9,5,4,2}; break; default: - if (isUsingFixedMap()) { - // fixed - odds = new int[]{70,10,10,4,3,2,1}; - } else { - return PlanetaryConditions.WI_NONE; - } + return PlanetaryConditions.WI_NONE; } int wind = rollCondition(odds); @@ -468,8 +462,10 @@ private int rollWindCondition() { private int rollWeatherCondition() { int[] odds; + String mapType = isUsingFixedMap() ? "Fixed" : getMap(); - switch (getMap()) { + switch (mapType) { + case "Fixed": case "City-dense": case "City-high": case "Fortress-city": @@ -526,12 +522,7 @@ private int rollWeatherCondition() { odds = new int[]{87,2,1,1,1,1,2,1,1,1,1,1}; break; default: - if (isUsingFixedMap()) { - // fixed - odds = new int[]{69,7,4,4,2,1,6,2,1,1,2,1}; - } else { - return PlanetaryConditions.WE_NONE; - } + return PlanetaryConditions.WE_NONE; } int weather = rollCondition(odds); @@ -549,8 +540,10 @@ private int rollWeatherCondition() { private int rollFogCondition() { int[] odds; + String mapType = isUsingFixedMap() ? "Fixed" : getMap(); - switch (getMap()) { + switch (mapType) { + case "Fixed": case "City-dense": case "City-high": case "Fortress-city": @@ -594,12 +587,7 @@ private int rollFogCondition() { odds = new int[]{60,20,20}; break; default: - if (isUsingFixedMap()) { - // fixed - odds = new int[]{90,5,5}; - } else { - return PlanetaryConditions.FOG_NONE; - } + return PlanetaryConditions.FOG_NONE; } int fog = rollCondition(odds); @@ -616,17 +604,17 @@ private int rollFogCondition() { } private boolean rollBlowingSandCondition(int wind, int weather, int fog) { - int[] odds; - boolean moderateGaleRestricted = WeatherRestriction.IsWindRestricted(PlanetaryConditions.WI_MOD_GALE, getAtmosphere(), getTemperature()); - if (weather != PlanetaryConditions.WE_NONE && fog != PlanetaryConditions.FOG_NONE - && wind < PlanetaryConditions.WI_MOD_GALE - && !moderateGaleRestricted) { + && wind < PlanetaryConditions.WI_MOD_GALE) { return false; } - switch (getMap()) { + int[] odds; + String mapType = isUsingFixedMap() ? "Fixed" : getMap(); + + switch (mapType) { + case "Fixed": case "City-dense": case "City-high": case "Fortress-city": @@ -656,12 +644,7 @@ private boolean rollBlowingSandCondition(int wind, int weather, int fog) { odds = new int[]{40,60}; break; default: - if (isUsingFixedMap()) { - // fixed - odds = new int[]{90,10}; - } else { - return false; - } + return false; } return rollCondition(odds) == 1; @@ -669,8 +652,10 @@ private boolean rollBlowingSandCondition(int wind, int weather, int fog) { private boolean rollEMICondition() { int[] odds; + String mapType = isUsingFixedMap() ? "Fixed" : getMap(); - switch (getMap()) { + switch (mapType) { + case "Fixed": case "City-dense": case "City-high": case "Fortress-city": @@ -717,16 +702,11 @@ private boolean rollEMICondition() { case "Town-mining": case "Town-mountain": case "Town-ruin": - // heavy + // high odds = new int[]{90,10}; break; default: - if (isUsingFixedMap()) { - // fixed - odds = new int[]{999,1}; - } else { - return false; - } + return false; } return rollCondition(odds) == 1; From c3a13c0fda7cdaaaa2e232c1b38cf04a3257a830 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Thu, 15 Feb 2024 19:31:29 -0500 Subject: [PATCH 27/38] use displayable value functions --- MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java | 8 ++++---- MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java index 634b8d8ba4..80fb17fe8e 100644 --- a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java @@ -608,7 +608,7 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB gridBagConstraints.gridwidth = 1; panStats.add(lblBlowingSand, gridBagConstraints); - String blowingSandDesc = scenario.getBlowingSand() ? PlanetaryConditions.MSG_NAME_BLOWINGSAND_TRUE : PlanetaryConditions.MSG_NAME_BLOWINGSAND_FALSE; + String blowingSandDesc = PlanetaryConditions.getSandBlowingDisplayableValue(scenario.getBlowingSand()); lblBlowingSandDesc.setText(blowingSandDesc); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = y++; @@ -622,7 +622,7 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB gridBagConstraints.gridwidth = 1; panStats.add(lblEMI, gridBagConstraints); - String emiDesc = scenario.getEMI() ? PlanetaryConditions.MSG_NAME_EMI_TRUE : PlanetaryConditions.MSG_NAME_EMI_FALSE; + String emiDesc = PlanetaryConditions.getEMIDisplayableValue(scenario.getEMI()); lblEMIDesc.setText(emiDesc); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = y++; @@ -814,9 +814,9 @@ private void rerollBattleConditions() { lblWeatherDesc.setText(PlanetaryConditions.getWeatherDisplayableName(scenario.getWeather())); lblWindDesc.setText(PlanetaryConditions.getWindDisplayableName(scenario.getWind())); lblFogDesc.setText(PlanetaryConditions.getFogDisplayableName(scenario.getFog())); - String blowingSandDesc = scenario.getBlowingSand() ? PlanetaryConditions.MSG_NAME_BLOWINGSAND_TRUE : PlanetaryConditions.MSG_NAME_BLOWINGSAND_FALSE; + String blowingSandDesc = PlanetaryConditions.getSandBlowingDisplayableValue(scenario.getBlowingSand()); lblBlowingSandDesc.setText(blowingSandDesc); - String emiDesc = scenario.getEMI() ? PlanetaryConditions.MSG_NAME_EMI_TRUE : PlanetaryConditions.MSG_NAME_EMI_FALSE; + String emiDesc = PlanetaryConditions.getEMIDisplayableValue(scenario.getEMI()); 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 5bcc9fbd54..fd5c72ff75 100644 --- a/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java @@ -456,7 +456,7 @@ private void fillMapData() { leftGbc.gridy++; pnlMap.add(lblBlowingSand, leftGbc); - String blowingSandDesc = scenario.getBlowingSand() ? PlanetaryConditions.MSG_NAME_BLOWINGSAND_TRUE : PlanetaryConditions.MSG_NAME_BLOWINGSAND_FALSE; + String blowingSandDesc = PlanetaryConditions.getSandBlowingDisplayableValue(scenario.getBlowingSand()); JLabel lblBlowingSandDesc = new JLabel(blowingSandDesc); rightGbc.gridy++; pnlMap.add(lblBlowingSandDesc, rightGbc); @@ -465,7 +465,7 @@ private void fillMapData() { leftGbc.gridy++; pnlMap.add(lblEMI, leftGbc); - String emiDesc = scenario.getEMI() ? PlanetaryConditions.MSG_NAME_EMI_TRUE : PlanetaryConditions.MSG_NAME_EMI_FALSE; + String emiDesc = PlanetaryConditions.getEMIDisplayableValue(scenario.getEMI()); JLabel lblEMIDesc = new JLabel(emiDesc); rightGbc.gridy++; pnlMap.add(lblEMIDesc, rightGbc); From 38b838f15f7d3da645830b9d4b13e8b16b1810f1 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 18 Feb 2024 11:14:19 -0500 Subject: [PATCH 28/38] use config file to determine terrain, switch back to terran to determine weather --- .../scenariotemplates/Allied Facility.xml | 5 +- .../scenariotemplates/Hostile Facility.xml | 5 +- .../scenariotemplates/Irregular Forces.xml | 5 +- .../scenariotemplates/LegacyAtB/AceDuel.xml | 2 +- .../LegacyAtB/AlliedTraitors.xml | 2 +- .../LegacyAtB/OfficerDuel.xml | 2 +- MekHQ/src/mekhq/AtBGameThread.java | 10 +- MekHQ/src/mekhq/GameThread.java | 6 +- .../campaign/mission/AtBDynamicScenario.java | 8 +- .../mission/AtBDynamicScenarioFactory.java | 49 ++- .../mekhq/campaign/mission/AtBScenario.java | 389 +++++++----------- .../src/mekhq/campaign/mission/Scenario.java | 62 +-- .../mission/ScenarioMapParameters.java | 12 +- .../atb/scenario/AceDuelBuiltInScenario.java | 2 +- .../scenario/AllyRescueBuiltInScenario.java | 11 +- .../atb/scenario/AmbushBuiltInScenario.java | 2 +- .../scenario/BaseAttackBuiltInScenario.java | 5 +- .../scenario/ConvoyAttackBuiltInScenario.java | 2 +- .../scenario/ConvoyRescueBuiltInScenario.java | 2 +- .../scenario/HideAndSeekBuiltInScenario.java | 15 +- .../scenario/OfficerDuelBuiltInScenario.java | 2 +- .../atb/scenario/ProbeBuiltInScenario.java | 12 +- .../StarLeagueCache1BuiltInScenario.java | 5 +- .../stratcon/StratconRulesManager.java | 27 +- .../dialog/ScenarioTemplateEditorDialog.java | 17 +- .../mekhq/gui/view/AtBScenarioViewPanel.java | 20 +- .../src/mekhq/gui/view/ScenarioViewPanel.java | 8 +- 27 files changed, 341 insertions(+), 346 deletions(-) diff --git a/MekHQ/data/scenariotemplates/Allied Facility.xml b/MekHQ/data/scenariotemplates/Allied Facility.xml index 9c3c99217d..c8fd4ecceb 100644 --- a/MekHQ/data/scenariotemplates/Allied Facility.xml +++ b/MekHQ/data/scenariotemplates/Allied Facility.xml @@ -7,8 +7,9 @@ true - 3 - 6 + ColdFacility + HotFacility + TemperateFacility false 0 diff --git a/MekHQ/data/scenariotemplates/Hostile Facility.xml b/MekHQ/data/scenariotemplates/Hostile Facility.xml index e71839ee79..6b7983b8b0 100644 --- a/MekHQ/data/scenariotemplates/Hostile Facility.xml +++ b/MekHQ/data/scenariotemplates/Hostile Facility.xml @@ -6,8 +6,9 @@ true - 3 - 6 + ColdFacility + HotFacility + TemperateFacility false 0 diff --git a/MekHQ/data/scenariotemplates/Irregular Forces.xml b/MekHQ/data/scenariotemplates/Irregular Forces.xml index d2c852c642..27e6cbccf6 100644 --- a/MekHQ/data/scenariotemplates/Irregular Forces.xml +++ b/MekHQ/data/scenariotemplates/Irregular Forces.xml @@ -7,8 +7,9 @@ false - 3 - 6 + ColdUrban + HotUrban + Urban false 0 diff --git a/MekHQ/data/scenariotemplates/LegacyAtB/AceDuel.xml b/MekHQ/data/scenariotemplates/LegacyAtB/AceDuel.xml index ad554ec734..6694f08f64 100644 --- a/MekHQ/data/scenariotemplates/LegacyAtB/AceDuel.xml +++ b/MekHQ/data/scenariotemplates/LegacyAtB/AceDuel.xml @@ -7,7 +7,7 @@ false - 1 + Hills false 0 diff --git a/MekHQ/data/scenariotemplates/LegacyAtB/AlliedTraitors.xml b/MekHQ/data/scenariotemplates/LegacyAtB/AlliedTraitors.xml index 24b8f58df0..8fa0379f57 100644 --- a/MekHQ/data/scenariotemplates/LegacyAtB/AlliedTraitors.xml +++ b/MekHQ/data/scenariotemplates/LegacyAtB/AlliedTraitors.xml @@ -7,7 +7,7 @@ false - 1 + Hills false 0 diff --git a/MekHQ/data/scenariotemplates/LegacyAtB/OfficerDuel.xml b/MekHQ/data/scenariotemplates/LegacyAtB/OfficerDuel.xml index b517932d26..1a2c760bb5 100644 --- a/MekHQ/data/scenariotemplates/LegacyAtB/OfficerDuel.xml +++ b/MekHQ/data/scenariotemplates/LegacyAtB/OfficerDuel.xml @@ -7,7 +7,7 @@ false - 1 + Hills false 0 diff --git a/MekHQ/src/mekhq/AtBGameThread.java b/MekHQ/src/mekhq/AtBGameThread.java index 6e72516aee..85375bcd86 100644 --- a/MekHQ/src/mekhq/AtBGameThread.java +++ b/MekHQ/src/mekhq/AtBGameThread.java @@ -121,13 +121,15 @@ public void run() { mapSettings.getBoardsSelectedVector().clear(); // if the scenario is taking place in space, do space settings instead - if (scenario.getTerrainType() == Scenario.TER_SPACE) { + if (scenario.getBoardType() == Scenario.T_SPACE) { mapSettings.setMedium(MapSettings.MEDIUM_SPACE); mapSettings.getBoardsSelectedVector().add(MapSettings.BOARD_GENERATED); } else if (scenario.isUsingFixedMap()) { - mapSettings.getBoardsSelectedVector().add(scenario.getMap().replace(".board", "")); // TODO : remove inline file type + String board = scenario.getMap().replace(".board", ""); // TODO : remove inline file type + board = board.replace("\\", "/"); + mapSettings.getBoardsSelectedVector().add(board); - if (scenario.getTerrainType() == Scenario.TER_LOW_ATMO) { + if (scenario.getBoardType() == Scenario.T_ATMOSPHERE) { mapSettings.setMedium(MapSettings.MEDIUM_ATMOSPHERE); } } else { @@ -138,7 +140,7 @@ public void run() { LogManager.getLogger().error("Could not load map file data/mapgen/" + scenario.getMap() + ".xml", ex); // TODO : Remove inline file path } - if (scenario.getTerrainType() == Scenario.TER_LOW_ATMO) { + if (scenario.getBoardType() == Scenario.T_ATMOSPHERE) { mapSettings.setMedium(MapSettings.MEDIUM_ATMOSPHERE); } diff --git a/MekHQ/src/mekhq/GameThread.java b/MekHQ/src/mekhq/GameThread.java index fcd5adbaee..3f77352c01 100644 --- a/MekHQ/src/mekhq/GameThread.java +++ b/MekHQ/src/mekhq/GameThread.java @@ -137,13 +137,13 @@ public void run() { mapSettings.getBoardsSelectedVector().clear(); // if the scenario is taking place in space, do space settings instead - if (scenario.getTerrainType() == Scenario.TER_SPACE) { + if (scenario.getBoardType() == Scenario.T_SPACE) { mapSettings.setMedium(MapSettings.MEDIUM_SPACE); mapSettings.getBoardsSelectedVector().add(MapSettings.BOARD_GENERATED); } else if (scenario.isUsingFixedMap()) { mapSettings.getBoardsSelectedVector().add(scenario.getMap().replace(".board", "")); - if (scenario.getTerrainType() == Scenario.TER_LOW_ATMO) { + if (scenario.getBoardType() == Scenario.T_ATMOSPHERE) { mapSettings.setMedium(MapSettings.MEDIUM_ATMOSPHERE); } } else { @@ -154,7 +154,7 @@ public void run() { LogManager.getLogger().error("Could not load map file data/mapgen/" + scenario.getMap() + ".xml", ex); // TODO : remove inline file path } - if (scenario.getTerrainType() == Scenario.TER_LOW_ATMO) { + if (scenario.getBoardType() == Scenario.T_ATMOSPHERE) { mapSettings.setMedium(MapSettings.MEDIUM_ATMOSPHERE); } diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java index aa223af402..98f3103a50 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java @@ -19,9 +19,11 @@ package mekhq.campaign.mission; import megamek.Version; +import megamek.common.Compute; import megamek.common.Entity; import megamek.common.annotations.Nullable; import megamek.common.enums.SkillLevel; +import mekhq.campaign.stratcon.StratconBiomeManifest; import mekhq.utilities.MHQXMLUtility; import mekhq.campaign.Campaign; import mekhq.campaign.force.Lance; @@ -38,6 +40,7 @@ import java.io.PrintWriter; import java.text.ParseException; import java.util.*; +import java.util.stream.Collectors; /** * Data structure intended to hold data relevant to AtB Dynamic Scenarios (AtB 3.0) @@ -564,11 +567,6 @@ protected void loadFieldsFromXmlNode(final Node wn, final Version version, final super.loadFieldsFromXmlNode(wn, version, campaign); } - @Override - public void setTerrain() { - AtBDynamicScenarioFactory.setTerrain(this); - } - @Override public void refresh(Campaign campaign) { diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index d40571fe41..f2cb43a049 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -52,6 +52,9 @@ import mekhq.campaign.personnel.Bloodname; import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.Phenotype; +import mekhq.campaign.stratcon.StratconBiome; +import mekhq.campaign.stratcon.StratconBiomeManifest; +import mekhq.campaign.stratcon.StratconContractInitializer; import mekhq.campaign.unit.Unit; import mekhq.campaign.universe.*; import mekhq.campaign.universe.Faction.Tag; @@ -465,7 +468,7 @@ public static int generateForce(AtBDynamicScenario scenario, AtBContract contrac } setStartingAltitude(generatedLance, forceTemplate.getStartingAltitude()); - correctNonAeroFlyerBehavior(generatedLance, scenario.getTerrainType()); + correctNonAeroFlyerBehavior(generatedLance, scenario.getBoardType()); // if force contributes to map size, increment the generated "lance" count if (forceTemplate.getContributesToMapSize()) { @@ -726,26 +729,40 @@ private static void setWeather(AtBDynamicScenario scenario) { * @param scenario The scenario to work on. */ public static void setTerrain(AtBDynamicScenario scenario) { - int terrainIndex; - // if we are allowing all terrain types, then pick one from the list // otherwise, pick one from the allowed ones if (scenario.getTemplate().mapParameters.getMapLocation() == ScenarioMapParameters.MapLocation.AllGroundTerrain) { - terrainIndex = Compute.randomInt(AtBScenario.terrainTypes.length); - scenario.setTerrainType(terrainIndex); + scenario.setBoardType(AtBScenario.T_GROUND); + StratconBiomeManifest biomeManifest = StratconBiomeManifest.getInstance(); + int kelvinTemp = scenario.getTemperature() + StratconContractInitializer.ZERO_CELSIUS_IN_KELVIN; + List allowedTerrain = biomeManifest.getTempMap(StratconBiomeManifest.TERRAN_BIOME) + .floorEntry(kelvinTemp).getValue().allowedTerrainTypes; + + int terrainIndex = Compute.randomInt(allowedTerrain.size()); + scenario.setTerrainType(allowedTerrain.get(terrainIndex)); scenario.setMapFile(); } else if (scenario.getTemplate().mapParameters.getMapLocation() == ScenarioMapParameters.MapLocation.Space) { - scenario.setTerrainType(AtBScenario.TER_SPACE); + scenario.setBoardType(AtBScenario.T_SPACE); + scenario.setTerrainType("Space"); } else if (scenario.getTemplate().mapParameters.getMapLocation() == ScenarioMapParameters.MapLocation.LowAtmosphere) { + scenario.setBoardType(AtBScenario.T_ATMOSPHERE); // low atmosphere actually makes use of the terrain, so we generate some here as well - terrainIndex = Compute.randomInt(AtBScenario.terrainTypes.length); - scenario.setTerrainType(terrainIndex); + scenario.setTerrain(); scenario.setMapFile(); - - // but then we set the terrain to low atmosphere - scenario.setTerrainType(AtBScenario.TER_LOW_ATMO); } else { - terrainIndex = Compute.randomInt(scenario.getTemplate().mapParameters.allowedTerrainTypes.size()); + StratconBiomeManifest biomeManifest = StratconBiomeManifest.getInstance(); + int kelvinTemp = scenario.getTemperature() + StratconContractInitializer.ZERO_CELSIUS_IN_KELVIN; + List allowedFacility = biomeManifest.getTempMap(StratconBiomeManifest.TERRAN_FACILITY_BIOME) + .floorEntry(kelvinTemp).getValue().allowedTerrainTypes; + List allowedTerrain = biomeManifest.getTempMap(StratconBiomeManifest.TERRAN_BIOME) + .floorEntry(kelvinTemp).getValue().allowedTerrainTypes; + List allowedTemplate = scenario.getTemplate().mapParameters.allowedTerrainTypes; + // try to filter on temp + allowedTerrain.addAll(allowedFacility); + allowedTemplate.retainAll(allowedTerrain); + allowedTemplate = allowedTemplate.size() > 0 ? allowedTemplate : scenario.getTemplate().mapParameters.allowedTerrainTypes; + + int terrainIndex = Compute.randomInt(allowedTemplate.size()); scenario.setTerrainType(scenario.getTemplate().mapParameters.allowedTerrainTypes.get(terrainIndex)); scenario.setMapFile(); } @@ -760,7 +777,7 @@ public static void setTerrain(AtBDynamicScenario scenario) { * @param campaign The current campaign */ private static void setPlanetaryConditions(AtBDynamicScenario scenario, AtBContract mission, Campaign campaign) { - if (scenario.getTerrainType() == AtBScenario.TER_SPACE) { + if (scenario.getBoardType() == AtBScenario.T_SPACE) { return; } @@ -2359,10 +2376,10 @@ private static void setStartingAltitude(List entityList, int startingAlt * This method contains various hacks intended to put "special units" * such as LAMs, VTOLs and WIGEs into a reasonable state that the bot can use */ - private static void correctNonAeroFlyerBehavior(List entityList, int terrainType) { + private static void correctNonAeroFlyerBehavior(List entityList, int boardType) { for (Entity entity : entityList) { - boolean inSpace = terrainType == AtBScenario.TER_SPACE; - boolean inAtmo = terrainType == AtBScenario.TER_LOW_ATMO; + boolean inSpace = boardType == AtBScenario.T_SPACE; + boolean inAtmo = boardType == AtBScenario.T_ATMOSPHERE; // hack for land-air mechs if (entity instanceof LandAirMech) { diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index a1fdcbac63..b11028de38 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -42,6 +42,7 @@ import mekhq.campaign.mission.enums.AtBLanceRole; import mekhq.campaign.personnel.SkillType; import mekhq.campaign.rating.IUnitRating; +import mekhq.campaign.stratcon.StratconBiomeManifest; import mekhq.campaign.unit.Unit; import mekhq.campaign.universe.*; import mekhq.utilities.MHQXMLUtility; @@ -54,6 +55,7 @@ import java.text.ParseException; import java.time.LocalDate; import java.util.*; +import java.util.stream.Collectors; import java.util.stream.IntStream; /** @@ -298,7 +300,9 @@ private void initBattle(Campaign campaign) { } public void setTerrain() { - setTerrainType(terrainChart[Compute.d6(2) - 2]); + Map mapTypes = StratconBiomeManifest.getInstance().getBiomeMapTypes(); + List keys = mapTypes.keySet().stream().sorted().collect(Collectors.toList()); + setTerrainType(keys.get(Compute.randomInt(keys.size()))); } private int rollCondition(int[] odds) { @@ -322,9 +326,9 @@ private int rollCondition(int[] odds) { private int rollLightCondition() { int[] odds; - String mapType = isUsingFixedMap() ? "Fixed" : getMap(); + String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); - switch (mapType) { + switch (terrainType) { case "Fixed": case "City-dense": case "City-high": @@ -390,56 +394,45 @@ private int rollLightCondition() { private int rollWindCondition() { int[] odds; - String mapType = isUsingFixedMap() ? "Fixed" : getMap(); - - switch (mapType) { - case "Fixed": - case "City-dense": - case "City-high": - case "Fortress-city": + String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); + + switch (terrainType) { + case "ColdFacility": + case "ColdForest": + case "ColdHills": + case "ColdMountain": + case "ColdUrban": + case "Forest": + case "FrozenFacility": case "Hills": - case "Lake-marsh": - case "Mountain-medium": - case "Muddy-swamp": - case "River-wetlands": - case "Sandy-hills": - case "Sandy-valley": - case "Some-trees": + case "HotFacility": + case "HotForest": + case "HotHillsDry": + case "HotHillsWet": + case "HotMountainsDry": + case "HotMountainsWet": + case "HotUrban": + case "Jungle": + case "Mountain": + case "Steppe": case "Swamp": - case "Town-concrete": - case "Town-farming": - case "Town-generic": - case "Town-hills": - case "Town-mining": - case "Town-mountain": - case "Town-ruin": - case "Town-wooded": - case "Wooded-hills": - case "Wooded-lake": - case "Wooded-swamp": - case "Wooded-valley": - case "Woods-deep": - case "Woods-medium": - case "Woods-river": + case "TemperateFacility": + case "Urban": // standard odds = new int[]{70,10,10,4,3,2,1}; break; - case "Cliffs": - case "Cliffs-lake": - case "Dust-bowl": - case "Heavy-craters": - case "Hills-craters": - case "Lake-high": - case "Light-craters": - case "Mountain-high": - case "Mountain-lake": - case "River-huge": - case "Rocky-valley": - case "Rubble-mountain": - case "Rubble-river": - case "Sandy-river": + case "ArcticDesert": + case "Badlands": + case "ColdSea": + case "Desert": + case "FrozenSea": + case "Glacier": + case "HotSea": + case "Plains": case "Savannah": - case "Seaport": + case "Sea": + case "SnowField": + case "Tundra": // high odds = new int[]{50,15,15,9,5,4,2}; break; @@ -462,62 +455,50 @@ private int rollWindCondition() { private int rollWeatherCondition() { int[] odds; - String mapType = isUsingFixedMap() ? "Fixed" : getMap(); + String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); - switch (mapType) { - case "Fixed": - case "City-dense": - case "City-high": - case "Fortress-city": + switch (terrainType) { + case "Forest": case "Hills": - case "Sandy-hills": - case "Sandy-valley": + case "HotFacility": + case "HotForest": + case "HotUrban": + case "Mountain": + case "Plains": case "Savannah": - case "Some-trees": - case "Town-concrete": - case "Town-farming": - case "Town-generic": - case "Town-hills": - case "Town-ruin": - case "Town-wooded": - case "Wooded-hills": - case "Wooded-valley": - case "Woods-deep": - case "Woods-medium": + case "Steppe": + case "TemperateFacility": + case "Urban": // standard odds = new int[]{69,7,4,4,2,1,6,2,1,1,2,1}; break; - case "Cliffs-lake": - case "Lake-high": - case "Lake-marsh": - case "Muddy-swamp": - case "River-huge": - case "River-wetlands": - case "Rubble-river": - case "Sandy-river": - case "Seaport": + case "HotHillsWet": + case "HotMountainsWet": + case "HotSea": + case "Jungle": + case "Sea": case "Swamp": - case "Wooded-lake": - case "Wooded-swamp": - case "Woods-river": // wet odds = new int[]{47,12,10,8,6,4,6,2,1,1,2,1}; break; - case "Mountain-high": - case "Mountain-lake": - case "Mountain-medium": - case "Town-mining": - case "Town-mountain": + case "ColdFacility": + case "ColdForest": + case "ColdHills": + case "ColdMountain": + case "ColdSea": + case "ColdUrban": + case "FrozenFacility": + case "FrozenSea": + case "SnowField": + case "Tundra": // snowy odds = new int[]{41,6,3,3,1,1,12,10,8,6,6,3}; break; - case "Cliffs": - case "Dust-bowl": - case "Heavy-craters": - case "Hills-craters": - case "Light-craters": - case "Rocky-valley": - case "Rubble-mountain": + case "ArcticDesert": + case "Badlands": + case "Desert": + case "HotHillsDry": + case "HotMountainsDry": // dry odds = new int[]{87,2,1,1,1,1,2,1,1,1,1,1}; break; @@ -540,49 +521,40 @@ private int rollWeatherCondition() { private int rollFogCondition() { int[] odds; - String mapType = isUsingFixedMap() ? "Fixed" : getMap(); + String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); - switch (mapType) { - case "Fixed": - case "City-dense": - case "City-high": - case "Fortress-city": + switch (terrainType) { + case "Forest": + case "Glacier": case "Hills": - case "Mountain-high": - case "Mountain-medium": - case "Sandy-hills": - case "Sandy-valley": + case "HotFacility": + case "HotForest": + case "HotUrban": + case "Mountain": + case "Plains": case "Savannah": - case "Some-trees": - case "Town-concrete": - case "Town-farming": - case "Town-generic": - case "Town-hills": - case "Town-mining": - case "Town-mountain": - case "Town-ruin": - case "Town-wooded": - case "Wooded-hills": - case "Wooded-valley": - case "Woods-deep": - case "Woods-medium": + case "Steppe": + case "TemperateFacility": + case "Urban": // standard odds = new int[]{90,5,5}; break; - case "Cliffs-lake": - case "Lake-high": - case "Lake-marsh": - case "Mountain-lake": - case "Muddy-swamp": - case "River-huge": - case "River-wetlands": - case "Rubble-river": - case "Sandy-river": - case "Seaport": + case "ColdFacility": + case "ColdForest": + case "ColdHills": + case "ColdMountain": + case "ColdSea": + case "ColdUrban": + case "FrozenFacility": + case "FrozenSea": + case "HotHillsWet": + case "HotMountainsWet": + case "HotSea": + case "Jungle": + case "Sea": + case "SnowField": case "Swamp": - case "Wooded-lake": - case "Wooded-swamp": - case "Woods-river": + case "Tundra": // heavy odds = new int[]{60,20,20}; break; @@ -605,41 +577,42 @@ private int rollFogCondition() { private boolean rollBlowingSandCondition(int wind, int weather, int fog) { if (weather != PlanetaryConditions.WE_NONE - && fog != PlanetaryConditions.FOG_NONE - && wind < PlanetaryConditions.WI_MOD_GALE) { + || fog != PlanetaryConditions.FOG_NONE + || wind < PlanetaryConditions.WI_MOD_GALE) { return false; } int[] odds; - String mapType = isUsingFixedMap() ? "Fixed" : getMap(); - - switch (mapType) { - case "Fixed": - case "City-dense": - case "City-high": - case "Fortress-city": + String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); + + switch (terrainType) { + case "ColdFacility": + case "ColdForest": + case "ColdHills": + case "ColdMountain": + case "ColdUrban": + case "Forest": + case "FrozenFacility": case "Hills": - case "Sandy-hills": - case "Sandy-river": - case "Sandy-valley": - case "Savannah": - case "Town-concrete": - case "Town-farming": - case "Town-generic": - case "Town-hills": - case "Town-mining": - case "Town-mountain": - case "Town-ruin": + case "HotFacility": + case "HotForest": + case "HotHillsWet": + case "HotMountainsWet": + case "HotUrban": + case "Jungle": + case "Mountain": + case "Steppe": + case "Swamp": + case "TemperateFacility": + case "Urban": // standard odds = new int[]{90,10}; break; - case "Cliffs": - case "Dust-bowl": - case "Heavy-craters": - case "Hills-craters": - case "Light-craters": - case "Rocky-valley": - case "Rubble-mountain": + case "ArcticDesert": + case "Badlands": + case "Desert": + case "HotHillsDry": + case "HotMountainsDry": // heavy odds = new int[]{40,60}; break; @@ -652,56 +625,28 @@ private boolean rollBlowingSandCondition(int wind, int weather, int fog) { private boolean rollEMICondition() { int[] odds; - String mapType = isUsingFixedMap() ? "Fixed" : getMap(); + String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); - switch (mapType) { - case "Fixed": - case "City-dense": - case "City-high": - case "Fortress-city": + switch (terrainType) { + case "Forest": case "Hills": - case "Lake-high": - case "Lake-marsh": - case "Muddy-swamp": - case "River-huge": - case "River-wetlands": - case "Sandy-hills": - case "Sandy-river": - case "Sandy-valley": + case "HotFacility": + case "HotForest": + case "HotUrban": + case "Mountain": + case "Plains": case "Savannah": - case "Seaport": - case "Some-trees": - case "Swamp": - case "Town-concrete": - case "Town-farming": - case "Town-generic": - case "Town-hills": - case "Town-wooded": - case "Wooded-hills": - case "Wooded-lake": - case "Wooded-swamp": - case "Wooded-valley": - case "Woods-deep": - case "Woods-medium": - case "Woods-river": + case "Steppe": + case "TemperateFacility": + case "Urban": // standard odds = new int[]{999,1}; break; - case "Cliffs": - case "Cliffs-lake": - case "Dust-bowl": - case "Heavy-craters": - case "Hills-craters": - case "Light-craters": - case "Mountain-high": - case "Mountain-lake": - case "Mountain-medium": - case "Rocky-valley": - case "Rubble-mountain": - case "Rubble-river": - case "Town-mining": - case "Town-mountain": - case "Town-ruin": + case "ArcticDesert": + case "Badlands": + case "Desert": + case "HotHillsDry": + case "HotMountainsDry": // high odds = new int[]{90,10}; break; @@ -718,8 +663,8 @@ public void setLightConditions() { public void setWeather() { // weather is irrelevant in these situations. - if (getTerrainType() == AtBScenario.TER_SPACE || - getTerrainType() == AtBScenario.TER_LOW_ATMO) { + if (getBoardType() == AtBScenario.T_SPACE || + getBoardType() == AtBScenario.T_ATMOSPHERE) { return; } @@ -794,36 +739,19 @@ public int getBaseMapY() { return (5 * getLanceCount()) + getMapSizeY(); } - public void setMapFile() { - final String[][] maps = { - {"Sandy-hills", "Hills-craters", "Hills", - "Wooded-hills", "Cliffs", "Town-hills"}, //hills - {"Sandy-valley", "Rocky-valley", "Light-craters", - "Heavy-craters", "Rubble-mountain", "Cliffs"}, //badlands - {"Muddy-swamp", "Lake-marsh", "Lake-high", - "Wooded-lake", "Swamp", "Wooded-swamp"}, //wetlands - {"Town-mining", "Town-wooded", "Town-generic", - "Town-farming", "Town-ruin", "Town-mountain"}, //light urban - {"Savannah", "Dust-bowl", "Sandy-hills", - "Town-ruin", "Town-generic", "Some-trees"}, //flatlands - {"Some-trees", "Wooded-lake", "Woods-medium", - "Wooded-hills", "Woods-deep", "Wooded-valley"}, //wooded - {"Fortress-city", "Fortress-city", "Town-concrete", - "Town-concrete", "City-high", "City-dense"}, //heavy urban - {"River-huge", "Woods-river", "Sandy-river", - "Rubble-river", "Seaport", "River-wetlands"}, //coastal - {"Mountain-lake", "Cliffs-lake", "Rubble-mountain", - "Cliffs", "Mountain-medium", "Mountain-high"} //mountains - }; - - int actualTerrainType = getTerrainType(); - - // we want to make sure the terrain type we pick is in bounds, - if ((getTerrainType() < 0) || (getTerrainType() >= maps.length)) { - actualTerrainType = Compute.randomInt(maps.length); + public void setMapFile(String terrainType) { + Map biomeMapTypes = StratconBiomeManifest.getInstance().getBiomeMapTypes(); + StratconBiomeManifest.MapTypeList value = biomeMapTypes.get(terrainType); + if (value != null) { + List mapTypeList = value.mapTypes; + setMap(mapTypeList.get(Compute.randomInt(mapTypeList.size()))); + } else { + setMap("Savannah"); } + } - setMap(maps[actualTerrainType][Compute.d6() - 1]); + public void setMapFile() { + setMapFile(getTerrainType()); } public boolean canRerollTerrain() { @@ -1726,8 +1654,7 @@ protected void addAeroReinforcements(Campaign campaign) { en.setDeployRound(deployRound); }); - boolean isAeroMap = getTerrainType() == TER_LOW_ATMO || - getTerrainType() == TER_SPACE; + boolean isAeroMap = getBoardType() == T_SPACE || getBoardType() == T_ATMOSPHERE; AtBDynamicScenarioFactory.populateAeroBombs(aircraft, campaign, !isAeroMap); @@ -1763,8 +1690,8 @@ protected void addScrubReinforcements(Campaign campaign) { boolean spawnBattleArmor = !opForOwnsPlanet && Compute.d6() >= MHQConstants.MAXIMUM_D6_VALUE - campaign.getCampaignOptions().getOpForLocalUnitChance() / 2; - boolean isTurretAppropriateTerrain = (getTerrainType() == TER_HEAVYURBAN) || (getTerrainType() == TER_LIGHTURBAN); - boolean isInfantryAppropriateTerrain = isTurretAppropriateTerrain || (getTerrainType() == TER_WOODED); + boolean isTurretAppropriateTerrain = (getTerrainType().toUpperCase().contains("URBAN")); + boolean isInfantryAppropriateTerrain = isTurretAppropriateTerrain || (getTerrainType().toUpperCase().contains("WOOD")); ArrayList scrubs = new ArrayList<>(); // don't bother spawning turrets if there won't be anything to put them on diff --git a/MekHQ/src/mekhq/campaign/mission/Scenario.java b/MekHQ/src/mekhq/campaign/mission/Scenario.java index 0280b11961..355dd22dd0 100644 --- a/MekHQ/src/mekhq/campaign/mission/Scenario.java +++ b/MekHQ/src/mekhq/campaign/mission/Scenario.java @@ -55,29 +55,12 @@ public class Scenario { //region Variable Declarations public static final int S_DEFAULT_ID = -1; - /** terrain types **/ - public static final int TER_LOW_ATMO = -2; - public static final int TER_SPACE = -1; - public static final int TER_HILLS = 0; - public static final int TER_BADLANDS = 1; - public static final int TER_WETLANDS = 2; - public static final int TER_LIGHTURBAN = 3; - public static final int TER_FLATLANDS = 4; - public static final int TER_WOODED = 5; - public static final int TER_HEAVYURBAN = 6; - public static final int TER_COASTAL = 7; - public static final int TER_MOUNTAINS = 8; - public static final String[] terrainTypes = {"Hills", "Badlands", "Wetlands", - "Light Urban", "Flatlands", "Wooded", "Heavy Urban", "Coastal", - "Mountains" - }; - - - public static final int[] terrainChart = { - TER_HILLS, TER_BADLANDS, TER_WETLANDS, TER_LIGHTURBAN, - TER_HILLS, TER_FLATLANDS, TER_WOODED, TER_HEAVYURBAN, - TER_COASTAL, TER_WOODED, TER_MOUNTAINS - }; + // MapBoardType + public static final int T_GROUND = 0; + public static final int T_ATMOSPHERE = 1; + public static final int T_SPACE = 2; + private static final String[] typeNames = { "Ground", "Low Atmosphere", "Space" }; + private int boardType = T_GROUND; private String name; private String desc; @@ -107,7 +90,7 @@ public class Scenario { private Map externalIDLookup; /** map generation variables **/ - private int terrainType; + private String terrainType; private int mapSizeX; private int mapSizeY; private String map; @@ -131,6 +114,8 @@ public class Scenario { /** player starting position **/ private int start; + private boolean hasTrack; + //Stores combinations of units and the transports they are assigned to private Map> playerTransportLinkages; //endregion Variable Declarations @@ -167,7 +152,7 @@ public Scenario(String n) { shiftWindStrength = false; maxWindStrength = PlanetaryConditions.WI_TORNADO_F4; minWindStrength = PlanetaryConditions.WI_NONE; - + hasTrack = false; } public String getName() { @@ -233,7 +218,7 @@ public void setCloaked(boolean cloaked) { this.cloaked = cloaked; } - public int getTerrainType() { + public String getTerrainType() { return terrainType; } @@ -245,10 +230,18 @@ public void setStart(int start) { this.start = start; } - public void setTerrainType(int terrainType) { + public void setTerrainType(String terrainType) { this.terrainType = terrainType; } + public void setBoardType(int terrainType) { + this.boardType = boardType; + } + + public int getBoardType() { + return boardType; + } + public int getMapSizeX() { return mapSizeX; } @@ -812,6 +805,7 @@ protected int writeToXMLBegin(final PrintWriter pw, int indent) { MHQXMLUtility.writeSimpleXMLTag(pw, indent, "date", date); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "cloaked", isCloaked()); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "terrainType", terrainType); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "hasTrack", hasTrack); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "usingFixedMap", isUsingFixedMap()); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "mapSize", mapSizeX, mapSizeY); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "map", map); @@ -946,8 +940,12 @@ public static Scenario generateInstanceFromXML(Node wn, Campaign c, Version vers retVal.deploymentLimit = ScenarioDeploymentLimit.generateInstanceFromXML(wn2, c, version); } else if (wn2.getNodeName().equalsIgnoreCase("usingFixedMap")) { retVal.setUsingFixedMap(Boolean.parseBoolean(wn2.getTextContent().trim())); + } else if (wn2.getNodeName().equalsIgnoreCase("boardType")) { + retVal.boardType = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("terrainType")) { - retVal.terrainType = Integer.parseInt(wn2.getTextContent()); + retVal.terrainType = wn2.getTextContent(); + } else if (wn2.getNodeName().equalsIgnoreCase("hasTrack")) { + retVal.hasTrack = Boolean.parseBoolean(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("mapSize")) { String[] xy = wn2.getTextContent().split(","); retVal.mapSizeX = Integer.parseInt(xy[0]); @@ -1020,4 +1018,12 @@ public boolean isFriendlyUnit(Entity entity, Campaign campaign) { return getForces(campaign).getUnits().stream(). anyMatch(unitID -> unitID.equals(UUID.fromString(entity.getExternalIdAsString()))); } + + public boolean getHasTrack() { + return hasTrack; + } + + public void setHasTrack(boolean b) { + hasTrack = b; + } } diff --git a/MekHQ/src/mekhq/campaign/mission/ScenarioMapParameters.java b/MekHQ/src/mekhq/campaign/mission/ScenarioMapParameters.java index 5a1ff5acc8..fb090d9db5 100644 --- a/MekHQ/src/mekhq/campaign/mission/ScenarioMapParameters.java +++ b/MekHQ/src/mekhq/campaign/mission/ScenarioMapParameters.java @@ -70,16 +70,10 @@ public ScenarioMapParameters clone() { @XmlElementWrapper(name="allowedTerrainTypes") @XmlElement(name="allowedTerrainType") - public List allowedTerrainTypes = new ArrayList<>(); + public List allowedTerrainTypes = new ArrayList<>(); - public int[] getAllowedTerrainTypeArray() { - int[] retVal = new int[allowedTerrainTypes.size()]; - - for (int x = 0; x < allowedTerrainTypes.size(); x++) { - retVal[x] = allowedTerrainTypes.get(x); - } - - return retVal; + public List getAllowedTerrainType() { + return allowedTerrainTypes; } public int getBaseWidth() { diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/AceDuelBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/AceDuelBuiltInScenario.java index 0571830000..3f4f08bd1c 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/AceDuelBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/AceDuelBuiltInScenario.java @@ -70,7 +70,7 @@ public void setWeather() { @Override public void setMapFile() { setMap("Savannah"); - setTerrainType(TER_FLATLANDS); + setTerrainType("Savannah"); } @Override diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/AllyRescueBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/AllyRescueBuiltInScenario.java index 2f351a3652..9ad20837bc 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/AllyRescueBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/AllyRescueBuiltInScenario.java @@ -18,16 +18,17 @@ */ package mekhq.campaign.mission.atb.scenario; -import megamek.common.Board; -import megamek.common.Entity; -import megamek.common.EntityWeightClass; -import megamek.common.UnitType; +import megamek.common.*; import mekhq.campaign.Campaign; import mekhq.campaign.againstTheBot.AtBStaticWeightGenerator; import mekhq.campaign.mission.*; import mekhq.campaign.mission.ObjectiveEffect.ObjectiveEffectType; import mekhq.campaign.mission.ScenarioObjective.ObjectiveCriterion; import mekhq.campaign.mission.atb.AtBScenarioEnabled; +import mekhq.campaign.stratcon.StratconBiome; +import mekhq.campaign.stratcon.StratconBiomeManifest; +import mekhq.campaign.stratcon.StratconContractInitializer; +import mekhq.campaign.stratcon.StratconFacility; import java.util.ArrayList; import java.util.List; @@ -67,7 +68,7 @@ public int getMapY() { @Override public void setMapFile() { setMap("Ally-rescue"); - setTerrainType(TER_LIGHTURBAN); + setTerrainType("Urban"); } @Override diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/AmbushBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/AmbushBuiltInScenario.java index 74a26d16d8..bcaaa0d9a8 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/AmbushBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/AmbushBuiltInScenario.java @@ -56,7 +56,7 @@ public String getResourceKey() { @Override public void setMapFile() { setMap("Savannah"); - setTerrainType(TER_FLATLANDS); + setTerrainType("Savannah"); } @Override diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/BaseAttackBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/BaseAttackBuiltInScenario.java index 88780f60c2..a1d03cb7a4 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/BaseAttackBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/BaseAttackBuiltInScenario.java @@ -35,6 +35,9 @@ import mekhq.campaign.mission.ScenarioObjective; import mekhq.campaign.mission.ObjectiveEffect.ObjectiveEffectType; import mekhq.campaign.mission.atb.AtBScenarioEnabled; +import mekhq.campaign.stratcon.StratconBiome; +import mekhq.campaign.stratcon.StratconBiomeManifest; +import mekhq.campaign.stratcon.StratconContractInitializer; @AtBScenarioEnabled public class BaseAttackBuiltInScenario extends AtBScenario { @@ -59,7 +62,7 @@ public String getResourceKey() { @Override public void setTerrain() { - setTerrainType((Compute.d6() < 4) ? TER_LIGHTURBAN : TER_HEAVYURBAN); + setTerrainType("Urban"); } @Override diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ConvoyAttackBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ConvoyAttackBuiltInScenario.java index 0dfb4b863e..50fd7f1a0a 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ConvoyAttackBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ConvoyAttackBuiltInScenario.java @@ -68,7 +68,7 @@ public int getMapY() { @Override public void setMapFile() { setMap("Convoy"); - setTerrainType(TER_WOODED); + setTerrainType("Forest"); } @Override diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ConvoyRescueBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ConvoyRescueBuiltInScenario.java index d8e5ccf03a..1baf80ae42 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ConvoyRescueBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ConvoyRescueBuiltInScenario.java @@ -69,7 +69,7 @@ public int getMapY() { @Override public void setMapFile() { setMap("Convoy"); - setTerrainType(TER_WOODED); + setTerrainType("Forest"); } @Override diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/HideAndSeekBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/HideAndSeekBuiltInScenario.java index c0c2ddd5ee..fd053c39ef 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/HideAndSeekBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/HideAndSeekBuiltInScenario.java @@ -28,8 +28,12 @@ import mekhq.campaign.mission.CommonObjectiveFactory; import mekhq.campaign.mission.ScenarioObjective; import mekhq.campaign.mission.atb.AtBScenarioEnabled; +import mekhq.campaign.stratcon.StratconBiomeManifest; import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; @AtBScenarioEnabled public class HideAndSeekBuiltInScenario extends AtBScenario { @@ -50,10 +54,15 @@ public String getResourceKey() { @Override public void setTerrain() { + Map mapTypes = StratconBiomeManifest.getInstance().getBiomeMapTypes(); + List keys = mapTypes.keySet().stream().sorted().collect(Collectors.toList()); do { - setTerrainType(terrainChart[Compute.d6(2) - 2]); - } while ((getTerrainType() == TER_WETLANDS || getTerrainType() == TER_COASTAL - || getTerrainType() == TER_FLATLANDS)); + setTerrainType(keys.get(Compute.randomInt(keys.size()))); + } while (getTerrainType() == "ColdSea" + || getTerrainType() == "FrozenSea" + || getTerrainType() == "HotSea" + || getTerrainType() == "Plains" + || getTerrainType() == "Savannah"); } @Override diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/OfficerDuelBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/OfficerDuelBuiltInScenario.java index f3d979a113..2d742fc12c 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/OfficerDuelBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/OfficerDuelBuiltInScenario.java @@ -71,7 +71,7 @@ public void setWeather() { @Override public void setMapFile() { setMap("Savannah"); - setTerrainType(TER_FLATLANDS); + setTerrainType("Savannah"); } @Override diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ProbeBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ProbeBuiltInScenario.java index 69a2049011..3d6fbf97bf 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ProbeBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ProbeBuiltInScenario.java @@ -19,6 +19,9 @@ package mekhq.campaign.mission.atb.scenario; import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import megamek.common.Compute; import megamek.common.Entity; @@ -29,6 +32,7 @@ import mekhq.campaign.mission.CommonObjectiveFactory; import mekhq.campaign.mission.ScenarioObjective; import mekhq.campaign.mission.atb.AtBScenarioEnabled; +import mekhq.campaign.stratcon.StratconBiomeManifest; @AtBScenarioEnabled public class ProbeBuiltInScenario extends AtBScenario { @@ -49,9 +53,13 @@ public String getResourceKey() { @Override public void setTerrain() { + Map mapTypes = StratconBiomeManifest.getInstance().getBiomeMapTypes(); + List keys = mapTypes.keySet().stream().sorted().collect(Collectors.toList()); do { - setTerrainType(terrainChart[Compute.d6(2) - 2]); - } while (getTerrainType() == TER_HEAVYURBAN); + setTerrainType(keys.get(Compute.randomInt(keys.size()))); + } while (getTerrainType() == "Urban" + || getTerrainType() == "ColdUrban" + || getTerrainType() == "HotUrban"); } @Override diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/StarLeagueCache1BuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/StarLeagueCache1BuiltInScenario.java index b91ce101d8..5de47c42ac 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/StarLeagueCache1BuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/StarLeagueCache1BuiltInScenario.java @@ -26,6 +26,9 @@ import mekhq.campaign.mission.*; import mekhq.campaign.mission.atb.AtBScenarioEnabled; import mekhq.campaign.rating.IUnitRating; +import mekhq.campaign.stratcon.StratconBiome; +import mekhq.campaign.stratcon.StratconBiomeManifest; +import mekhq.campaign.stratcon.StratconContractInitializer; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.Factions; @@ -69,7 +72,7 @@ public int getMapY() { @Override public void setMapFile() { setMap("Brian-cache"); - setTerrainType(TER_LIGHTURBAN); + setTerrainType("Urban"); } @Override diff --git a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java index 993b596625..4ad0af9e06 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java +++ b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java @@ -186,18 +186,13 @@ public static void generateScenariosForTrack(Campaign campaign, AtBContract cont public static void setScenarioParametersFromBiome(StratconTrackState track, StratconScenario scenario) { StratconCoords coords = scenario.getCoords(); AtBDynamicScenario backingScenario = scenario.getBackingScenario(); + StratconBiomeManifest biomeManifest = StratconBiomeManifest.getInstance(); // for non-surface scenarios, we will skip the temperature update - if (backingScenario.getTerrainType() != Scenario.TER_LOW_ATMO && - backingScenario.getTerrainType() != Scenario.TER_SPACE) { + if (backingScenario.getBoardType() != Scenario.T_SPACE && + backingScenario.getBoardType() != Scenario.T_ATMOSPHERE) { backingScenario.setTemperature(track.getTemperature()); } - - // for now, if we're using a fixed map or in a facility, don't replace the scenario - // TODO: facility spaces will always have a relevant biome - if (backingScenario.isUsingFixedMap()) { - return; // for now - } StratconFacility facility = track.getFacility(scenario.getCoords()); String terrainType; @@ -209,7 +204,7 @@ public static void setScenarioParametersFromBiome(StratconTrackState track, Stra // if facility doesn't have a biome temp map or no entry for the current temperature, use the default one if (facility.getBiomes().isEmpty() || (facility.getBiomeTempMap().floorEntry(kelvinTemp) == null)) { - facilityBiome = StratconBiomeManifest.getInstance().getTempMap(StratconBiomeManifest.TERRAN_FACILITY_BIOME) + facilityBiome = biomeManifest.getTempMap(StratconBiomeManifest.TERRAN_FACILITY_BIOME) .floorEntry(kelvinTemp).getValue(); } else { facilityBiome = facility.getBiomeTempMap().floorEntry(kelvinTemp).getValue(); @@ -219,7 +214,7 @@ public static void setScenarioParametersFromBiome(StratconTrackState track, Stra terrainType = track.getTerrainTile(coords); } - var mapTypes = StratconBiomeManifest.getInstance().getBiomeMapTypes(); + var mapTypes = biomeManifest.getBiomeMapTypes(); // don't have a map list for the given terrain, leave it alone if(!mapTypes.containsKey(terrainType)) { @@ -227,10 +222,16 @@ public static void setScenarioParametersFromBiome(StratconTrackState track, Stra } // if we are in space, do not update the map; note that it's ok to do so in low atmo - if (backingScenario.getTerrainType() != Scenario.TER_SPACE) { + if (backingScenario.getBoardType() != Scenario.T_SPACE) { var mapTypeList = mapTypes.get(terrainType).mapTypes; - backingScenario.setMap(mapTypeList.get(Compute.randomInt(mapTypeList.size()))); - backingScenario.setWeather(); + backingScenario.setHasTrack(true); + backingScenario.setTerrainType(terrainType); + // for now, if we're using a fixed map or in a facility, don't replace the scenario + // TODO: facility spaces will always have a relevant biome + if (!backingScenario.isUsingFixedMap()) { + backingScenario.setMap(mapTypeList.get(Compute.randomInt(mapTypeList.size()))); + backingScenario.setWeather(); + } } } diff --git a/MekHQ/src/mekhq/gui/dialog/ScenarioTemplateEditorDialog.java b/MekHQ/src/mekhq/gui/dialog/ScenarioTemplateEditorDialog.java index b508d49aa6..b54e1f19b2 100644 --- a/MekHQ/src/mekhq/gui/dialog/ScenarioTemplateEditorDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/ScenarioTemplateEditorDialog.java @@ -33,6 +33,7 @@ import mekhq.campaign.mission.ScenarioForceTemplate.ForceGenerationMethod; import mekhq.campaign.mission.ScenarioForceTemplate.SynchronizedDeploymentType; import mekhq.campaign.mission.atb.AtBScenarioModifier; +import mekhq.campaign.stratcon.StratconBiomeManifest; import mekhq.gui.FileDialogs; import mekhq.gui.baseComponents.DefaultMHQScrollablePanel; import org.apache.logging.log4j.LogManager; @@ -46,6 +47,7 @@ import java.io.File; import java.util.List; import java.util.*; +import java.util.stream.Collectors; /** * Handles editing, saving and loading of scenario template definitions. @@ -810,11 +812,19 @@ private void setupMapParameters(GridBagConstraints gbc) { localGbc.gridheight = GridBagConstraints.RELATIVE; lstAllowedTerrainTypes = new JList<>(); DefaultListModel terrainTypeModel = new DefaultListModel<>(); - for (String terrainType : AtBScenario.terrainTypes) { + Map mapTypes = StratconBiomeManifest.getInstance().getBiomeMapTypes(); + List keys = mapTypes.keySet().stream().sorted().collect(Collectors.toList()); + List indexes = new ArrayList<>(); + int i = 0; + for (String terrainType : keys) { terrainTypeModel.addElement(terrainType); + if (scenarioTemplate.mapParameters.getAllowedTerrainType().contains(terrainType)) { + indexes.add(i); + } + i++; } lstAllowedTerrainTypes.setModel(terrainTypeModel); - lstAllowedTerrainTypes.setSelectedIndices(scenarioTemplate.mapParameters.getAllowedTerrainTypeArray()); + lstAllowedTerrainTypes.setSelectedIndices(indexes.stream().mapToInt(Integer::intValue).toArray()); mapTypeChangeHandler(); pnlMapParameters.add(lstAllowedTerrainTypes, localGbc); @@ -1336,7 +1346,8 @@ private void saveTemplateButtonHandler() { scenarioTemplate.detailedBriefing = txtLongBriefing.getText(); scenarioTemplate.mapParameters.allowedTerrainTypes.clear(); - for (int terrainType : lstAllowedTerrainTypes.getSelectedIndices()) { + for (int index : lstAllowedTerrainTypes.getSelectedIndices()) { + String terrainType = lstAllowedTerrainTypes.getModel().getElementAt(index); scenarioTemplate.mapParameters.allowedTerrainTypes.add(terrainType); } scenarioTemplate.mapParameters.setBaseHeight(Integer.parseInt(txtBaseHeight.getText())); diff --git a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java index 80fb17fe8e..8ce1bbe3cc 100644 --- a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java @@ -321,9 +321,9 @@ private void fillStats() { panStats.add(lblForceDesc, gridBagConstraints); } - if (scenario.getTerrainType() == Scenario.TER_SPACE) { + if (scenario.getBoardType() == Scenario.T_SPACE) { y = fillSpaceStats(gridBagConstraints, resourceMap, y); - } else if (scenario.getTerrainType() == Scenario.TER_LOW_ATMO) { + } else if (scenario.getBoardType() == Scenario.T_ATMOSPHERE) { y = fillLowAtmoStats(gridBagConstraints, resourceMap, y); } else { y = fillPlanetSideStats(gridBagConstraints, resourceMap, y); @@ -482,7 +482,19 @@ private int fillPlanetSideStats(GridBagConstraints gridBagConstraints, ResourceB chkReroll[REROLL_TERRAIN].addItemListener(checkBoxListener); } - lblTerrainDesc.setText(AtBScenario.terrainTypes[scenario.getTerrainType()]); + lblTerrainDesc.setText(scenario.getTerrainType()); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = y++; + panStats.add(lblTerrainDesc, gridBagConstraints); + } else { + lblTerrain.setText(resourceMap.getString("lblTerrain.text")); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = y; + gridBagConstraints.gridwidth = 1; + panStats.add(lblTerrain, gridBagConstraints); + + String hasTrack = scenario.getHasTrack() ? " \u2606" : ""; + lblTerrainDesc.setText(scenario.getTerrainType() + hasTrack); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = y++; panStats.add(lblTerrainDesc, gridBagConstraints); @@ -786,7 +798,7 @@ private void rerollBattleConditions() { scenario.setMapFile(); scenario.useReroll(); chkReroll[REROLL_TERRAIN].setSelected(false); - lblTerrainDesc.setText(AtBScenario.terrainTypes[scenario.getTerrainType()]); + lblTerrainDesc.setText(scenario.getTerrainType()); lblMapDesc.setText(scenario.getMap()); } if (chkReroll[REROLL_MAP] != null && chkReroll[REROLL_MAP].isSelected()) { diff --git a/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java index fd5c72ff75..aa43f3c2b3 100644 --- a/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java @@ -387,9 +387,9 @@ private void fillMapData() { pnlMap.add(lblTerrain, leftGbc); JLabel lblTerrainDesc = new JLabel(); - if (scenario.getTerrainType() == Scenario.TER_SPACE) { + if (scenario.getBoardType() == Scenario.T_SPACE) { lblTerrainDesc.setText("Space"); - } else if (scenario.getTerrainType() == Scenario.TER_LOW_ATMO) { + } else if (scenario.getBoardType() == Scenario.T_ATMOSPHERE) { lblTerrainDesc.setText("Low Atmosphere"); } else { lblTerrainDesc.setText("Ground"); @@ -397,7 +397,7 @@ private void fillMapData() { rightGbc.gridy++; pnlMap.add(lblTerrainDesc, rightGbc); - if (scenario.getTerrainType() != Scenario.TER_SPACE) { + if (scenario.getBoardType() != Scenario.T_SPACE) { JLabel lblMap = new JLabel(resourceMap.getString("lblMap.text")); leftGbc.gridy++; pnlMap.add(lblMap, leftGbc); @@ -415,7 +415,7 @@ private void fillMapData() { rightGbc.gridy++; pnlMap.add(lblMapSizeDesc, rightGbc); - if (scenario.getTerrainType() == Scenario.TER_SPACE) { + if (scenario.getBoardType() == Scenario.T_SPACE) { // if a space scenario return here as the rest is all planet based information return; } From 130a9f5edffe2560c36c6e84ecae6f0a34012450 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 18 Feb 2024 11:53:33 -0500 Subject: [PATCH 29/38] code cleanup --- MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java | 3 --- .../mekhq/campaign/mission/AtBDynamicScenarioFactory.java | 1 - MekHQ/src/mekhq/campaign/mission/AtBScenario.java | 5 +++-- .../mission/atb/scenario/AllyRescueBuiltInScenario.java | 4 ---- .../mission/atb/scenario/BaseAttackBuiltInScenario.java | 3 --- .../atb/scenario/StarLeagueCache1BuiltInScenario.java | 3 --- MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java | 2 +- 7 files changed, 4 insertions(+), 17 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java index 98f3103a50..204f2731c3 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java @@ -19,11 +19,9 @@ package mekhq.campaign.mission; import megamek.Version; -import megamek.common.Compute; import megamek.common.Entity; import megamek.common.annotations.Nullable; import megamek.common.enums.SkillLevel; -import mekhq.campaign.stratcon.StratconBiomeManifest; import mekhq.utilities.MHQXMLUtility; import mekhq.campaign.Campaign; import mekhq.campaign.force.Lance; @@ -40,7 +38,6 @@ import java.io.PrintWriter; import java.text.ParseException; import java.util.*; -import java.util.stream.Collectors; /** * Data structure intended to hold data relevant to AtB Dynamic Scenarios (AtB 3.0) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index f2cb43a049..ad89c7a74b 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -52,7 +52,6 @@ import mekhq.campaign.personnel.Bloodname; import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.Phenotype; -import mekhq.campaign.stratcon.StratconBiome; import mekhq.campaign.stratcon.StratconBiomeManifest; import mekhq.campaign.stratcon.StratconContractInitializer; import mekhq.campaign.unit.Unit; diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index b11028de38..d294b85180 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -1690,8 +1690,9 @@ protected void addScrubReinforcements(Campaign campaign) { boolean spawnBattleArmor = !opForOwnsPlanet && Compute.d6() >= MHQConstants.MAXIMUM_D6_VALUE - campaign.getCampaignOptions().getOpForLocalUnitChance() / 2; - boolean isTurretAppropriateTerrain = (getTerrainType().toUpperCase().contains("URBAN")); - boolean isInfantryAppropriateTerrain = isTurretAppropriateTerrain || (getTerrainType().toUpperCase().contains("WOOD")); + boolean isTurretAppropriateTerrain = (getTerrainType().toUpperCase().contains("URBAN") + || getTerrainType().toUpperCase().contains("FACILITY")); + boolean isInfantryAppropriateTerrain = isTurretAppropriateTerrain || (getTerrainType().toUpperCase().contains("FOREST")); ArrayList scrubs = new ArrayList<>(); // don't bother spawning turrets if there won't be anything to put them on diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/AllyRescueBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/AllyRescueBuiltInScenario.java index 9ad20837bc..9f0dac76a4 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/AllyRescueBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/AllyRescueBuiltInScenario.java @@ -25,10 +25,6 @@ import mekhq.campaign.mission.ObjectiveEffect.ObjectiveEffectType; import mekhq.campaign.mission.ScenarioObjective.ObjectiveCriterion; import mekhq.campaign.mission.atb.AtBScenarioEnabled; -import mekhq.campaign.stratcon.StratconBiome; -import mekhq.campaign.stratcon.StratconBiomeManifest; -import mekhq.campaign.stratcon.StratconContractInitializer; -import mekhq.campaign.stratcon.StratconFacility; import java.util.ArrayList; import java.util.List; diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/BaseAttackBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/BaseAttackBuiltInScenario.java index a1d03cb7a4..2392acdfaa 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/BaseAttackBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/BaseAttackBuiltInScenario.java @@ -35,9 +35,6 @@ import mekhq.campaign.mission.ScenarioObjective; import mekhq.campaign.mission.ObjectiveEffect.ObjectiveEffectType; import mekhq.campaign.mission.atb.AtBScenarioEnabled; -import mekhq.campaign.stratcon.StratconBiome; -import mekhq.campaign.stratcon.StratconBiomeManifest; -import mekhq.campaign.stratcon.StratconContractInitializer; @AtBScenarioEnabled public class BaseAttackBuiltInScenario extends AtBScenario { diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/StarLeagueCache1BuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/StarLeagueCache1BuiltInScenario.java index 5de47c42ac..84a4fd9009 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/StarLeagueCache1BuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/StarLeagueCache1BuiltInScenario.java @@ -26,9 +26,6 @@ import mekhq.campaign.mission.*; import mekhq.campaign.mission.atb.AtBScenarioEnabled; import mekhq.campaign.rating.IUnitRating; -import mekhq.campaign.stratcon.StratconBiome; -import mekhq.campaign.stratcon.StratconBiomeManifest; -import mekhq.campaign.stratcon.StratconContractInitializer; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.Factions; diff --git a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java index 4ad0af9e06..256c47ac9b 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java +++ b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java @@ -230,8 +230,8 @@ public static void setScenarioParametersFromBiome(StratconTrackState track, Stra // TODO: facility spaces will always have a relevant biome if (!backingScenario.isUsingFixedMap()) { backingScenario.setMap(mapTypeList.get(Compute.randomInt(mapTypeList.size()))); - backingScenario.setWeather(); } + backingScenario.setWeather(); } } From aeedb6ef73c6249bc874371c38a36e8b3b0911e1 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 18 Feb 2024 13:00:13 -0500 Subject: [PATCH 30/38] fix paht --- MekHQ/src/mekhq/GameThread.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MekHQ/src/mekhq/GameThread.java b/MekHQ/src/mekhq/GameThread.java index 3f77352c01..72404cf2ac 100644 --- a/MekHQ/src/mekhq/GameThread.java +++ b/MekHQ/src/mekhq/GameThread.java @@ -141,7 +141,9 @@ public void run() { mapSettings.setMedium(MapSettings.MEDIUM_SPACE); mapSettings.getBoardsSelectedVector().add(MapSettings.BOARD_GENERATED); } else if (scenario.isUsingFixedMap()) { - mapSettings.getBoardsSelectedVector().add(scenario.getMap().replace(".board", "")); + String board = scenario.getMap().replace(".board", ""); // TODO : remove inline file type + board = board.replace("\\", "/"); + mapSettings.getBoardsSelectedVector().add(board); if (scenario.getBoardType() == Scenario.T_ATMOSPHERE) { mapSettings.setMedium(MapSettings.MEDIUM_ATMOSPHERE); From b3c5705927c06518e3697ce8586e9f8c4c4fd737 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 24 Feb 2024 11:00:24 -0500 Subject: [PATCH 31/38] fix warnings --- MekHQ/src/mekhq/campaign/mission/Scenario.java | 2 +- .../atb/scenario/HideAndSeekBuiltInScenario.java | 10 +++++----- .../mission/atb/scenario/ProbeBuiltInScenario.java | 4 +--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/Scenario.java b/MekHQ/src/mekhq/campaign/mission/Scenario.java index 355dd22dd0..58196a1e51 100644 --- a/MekHQ/src/mekhq/campaign/mission/Scenario.java +++ b/MekHQ/src/mekhq/campaign/mission/Scenario.java @@ -234,7 +234,7 @@ public void setTerrainType(String terrainType) { this.terrainType = terrainType; } - public void setBoardType(int terrainType) { + public void setBoardType(int boardType) { this.boardType = boardType; } diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/HideAndSeekBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/HideAndSeekBuiltInScenario.java index fd053c39ef..e2ec8b5666 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/HideAndSeekBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/HideAndSeekBuiltInScenario.java @@ -58,11 +58,11 @@ public void setTerrain() { List keys = mapTypes.keySet().stream().sorted().collect(Collectors.toList()); do { setTerrainType(keys.get(Compute.randomInt(keys.size()))); - } while (getTerrainType() == "ColdSea" - || getTerrainType() == "FrozenSea" - || getTerrainType() == "HotSea" - || getTerrainType() == "Plains" - || getTerrainType() == "Savannah"); + } while (getTerrainType().equals("ColdSea") + || getTerrainType().equals("FrozenSea") + || getTerrainType().equals("HotSea") + || getTerrainType().equals("Plains") + || getTerrainType().equals("Savannah")); } @Override diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ProbeBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ProbeBuiltInScenario.java index 3d6fbf97bf..3ac9604387 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ProbeBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ProbeBuiltInScenario.java @@ -57,9 +57,7 @@ public void setTerrain() { List keys = mapTypes.keySet().stream().sorted().collect(Collectors.toList()); do { setTerrainType(keys.get(Compute.randomInt(keys.size()))); - } while (getTerrainType() == "Urban" - || getTerrainType() == "ColdUrban" - || getTerrainType() == "HotUrban"); + } while (getTerrainType().toUpperCase().contains("URBAN")); } @Override From 4116c0e36bef5a4e5911bb65097dfb357b7fea40 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 24 Feb 2024 12:03:26 -0500 Subject: [PATCH 32/38] fix light case. fix heavy templates --- .../Allied Facility - Heavy.xml | 5 +- .../Hostile Facility - Heavy.xml | 5 +- .../Irregular Forces - Heavy.xml | 5 +- .../mekhq/campaign/mission/AtBScenario.java | 71 ++++++++----------- 4 files changed, 39 insertions(+), 47 deletions(-) diff --git a/MekHQ/data/scenariotemplates/Allied Facility - Heavy.xml b/MekHQ/data/scenariotemplates/Allied Facility - Heavy.xml index a69d63ba9d..b6c89abb1b 100644 --- a/MekHQ/data/scenariotemplates/Allied Facility - Heavy.xml +++ b/MekHQ/data/scenariotemplates/Allied Facility - Heavy.xml @@ -7,8 +7,9 @@ true - 3 - 6 + ColdFacility + HotFacility + TemperateFacility false 0 diff --git a/MekHQ/data/scenariotemplates/Hostile Facility - Heavy.xml b/MekHQ/data/scenariotemplates/Hostile Facility - Heavy.xml index 6c051dfe51..536dae4e4b 100644 --- a/MekHQ/data/scenariotemplates/Hostile Facility - Heavy.xml +++ b/MekHQ/data/scenariotemplates/Hostile Facility - Heavy.xml @@ -6,8 +6,9 @@ true - 3 - 6 + ColdFacility + HotFacility + TemperateFacility false 0 diff --git a/MekHQ/data/scenariotemplates/Irregular Forces - Heavy.xml b/MekHQ/data/scenariotemplates/Irregular Forces - Heavy.xml index ae3263445f..826c54e21f 100644 --- a/MekHQ/data/scenariotemplates/Irregular Forces - Heavy.xml +++ b/MekHQ/data/scenariotemplates/Irregular Forces - Heavy.xml @@ -7,8 +7,9 @@ false - 3 - 6 + ColdUrban + HotUrban + Urban false 0 diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index d294b85180..ba6cee2006 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -329,53 +329,42 @@ private int rollLightCondition() { String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); switch (terrainType) { - case "Fixed": - case "City-dense": - case "City-high": - case "Cliffs-lake": - case "Dust-bowl": - case "Fortress-city": + case "ArcticDesert": + case "Badlands": + case "ColdFacility": + case "ColdForest": + case "ColdHills": + case "ColdSea": + case "ColdUrban": + case "Desert": + case "Forest": + case "FrozenFacility": + case "FrozenSea": case "Hills": - case "Lake-high": - case "Lake-marsh": - case "Mountain-high": - case "Mountain-lake": - case "Mountain-medium": - case "Muddy-swamp": - case "River-huge": - case "River-wetlands": - case "Rocky-valley": - case "Rubble-mountain": - case "Rubble-river": - case "Sandy-hills": - case "Sandy-river": - case "Sandy-valley": + case "HotFacility": + case "HotForest": + case "HotHillsDry": + case "HotHillsWet": + case "HotSea": + case "HotUrban": + case "Jungle": + case "Plains": case "Savannah": - case "Seaport": - case "Some-trees": + case "Sea": + case "SnowField": + case "Steppe": case "Swamp": - case "Town-concrete": - case "Town-farming": - case "Town-generic": - case "Town-hills": - case "Town-mining": - case "Town-mountain": - case "Town-ruin": - case "Town-wooded": - case "Wooded-hills": - case "Wooded-lake": - case "Wooded-swamp": - case "Wooded-valley": - case "Woods-deep": - case "Woods-medium": - case "Woods-river": + case "TemperateFacility": + case "Tundra": + case "Urban": // standard odds = new int[]{600,200,100,99,1}; break; - case "Cliffs": - case "Heavy-craters": - case "Hills-craters": - case "Light-craters": + case "ColdMountain": + case "Glacier": + case "HotMountainsDry": + case "HotMountainsWet": + case "Mountain": // dark odds = new int[]{50,20,10,10,10}; break; From 23df016b81914e43881566e8002278e0e5624340 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 2 Mar 2024 09:55:42 -0500 Subject: [PATCH 33/38] used enums. show changed tempature --- MekHQ/src/mekhq/AtBGameThread.java | 8 +- MekHQ/src/mekhq/GameThread.java | 12 +- MekHQ/src/mekhq/adapter/PressureAdapter.java | 15 +- .../mission/AtBDynamicScenarioFactory.java | 3 +- .../mekhq/campaign/mission/AtBScenario.java | 108 +++++++-------- .../src/mekhq/campaign/mission/Scenario.java | 128 +++++++++--------- .../atb/scenario/AceDuelBuiltInScenario.java | 12 +- .../scenario/OfficerDuelBuiltInScenario.java | 12 +- MekHQ/src/mekhq/campaign/universe/Planet.java | 4 +- .../mekhq/gui/view/AtBScenarioViewPanel.java | 34 ++--- .../src/mekhq/gui/view/ScenarioViewPanel.java | 23 ++-- 11 files changed, 184 insertions(+), 175 deletions(-) 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()) { From ccce40493c29e696387c89c9a7f0ff7f4725f0cd Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 3 Mar 2024 15:39:10 -0500 Subject: [PATCH 34/38] use config file to map terrain to weather odds --- .../TerrainConditionsOddsManifest.xml | 780 ++++++++++++++++++ MekHQ/src/mekhq/MHQConstants.java | 1 + .../mekhq/campaign/mission/AtBScenario.java | 361 +------- .../mission/TerrainConditionsOdds.java | 33 + .../TerrainConditionsOddsManifest.java | 559 +++++++++++++ 5 files changed, 1403 insertions(+), 331 deletions(-) create mode 100644 MekHQ/data/terrainconditionsodds/TerrainConditionsOddsManifest.xml create mode 100644 MekHQ/src/mekhq/campaign/mission/TerrainConditionsOdds.java create mode 100644 MekHQ/src/mekhq/campaign/mission/TerrainConditionsOddsManifest.java diff --git a/MekHQ/data/terrainconditionsodds/TerrainConditionsOddsManifest.xml b/MekHQ/data/terrainconditionsodds/TerrainConditionsOddsManifest.xml new file mode 100644 index 0000000000..8be0b7a571 --- /dev/null +++ b/MekHQ/data/terrainconditionsodds/TerrainConditionsOddsManifest.xml @@ -0,0 +1,780 @@ + + + + + + Light + standard + + ArcticDesert + Badlands + ColdFacility + ColdForest + ColdHills + ColdSea + ColdUrban + Desert + Forest + FrozenFacility + FrozenSea + Hills + HotFacility + HotForest + HotHillsDry + HotHillsWet + HotSea + HotUrban + Jungle + Plains + Savannah + Sea + SnowField + Steppe + Swamp + TemperateFacility + Tundra + Urban + + + + LIGHT_MOONLESS + 99 + + + LIGHT_DAY + 600 + + + LIGHT_FULL_MOON + 100 + + + LIGHT_DUSK + 200 + + + LIGHT_PITCH_BLACK + 1 + + + + + Light + dark + + ColdMountain + Glacier + HotMountainsDry + HotMountainsWet + Mountain + + + + LIGHT_MOONLESS + 10 + + + LIGHT_DAY + 50 + + + LIGHT_FULL_MOON + 10 + + + LIGHT_DUSK + 20 + + + LIGHT_PITCH_BLACK + 10 + + + + + Wind + standard + + ColdFacility + ColdForest + ColdHills + ColdMountain + ColdUrban + Forest + FrozenFacility + Hills + HotFacility + HotForest + HotHillsWet + HotMountainsWet + HotUrban + Jungle + Mountain + Swamp + TemperateFacility + Urban + + + + WIND_CALM + 70 + + + WIND_LIGHT_GALE + 10 + + + WIND_TORNADO_F1_TO_F3 + 2 + + + WIND_MOD_GALE + 10 + + + WIND_STORM + 3 + + + WIND_STRONG_GALE + 4 + + + WIND_TORNADO_F4 + 1 + + + + + Wind + high + + ArcticDesert + Badlands + ColdSea + Desert + FrozenSea + Glacier + HotHillsDry + HotMountainsDry + HotSea + Plains + Savannah + Sea + SnowField + Steppe + Tundra + + + + WIND_CALM + 50 + + + WIND_LIGHT_GALE + 15 + + + WIND_TORNADO_F1_TO_F3 + 4 + + + WIND_MOD_GALE + 14 + + + WIND_STORM + 5 + + + WIND_STRONG_GALE + 10 + + + WIND_TORNADO_F4 + 2 + + + + + Weather + standard + + Forest + Hills + HotFacility + HotForest + HotUrban + Mountain + Plains + Savannah + Steppe + TemperateFacility + Urban + + + + WEATHER_LIGHTNING_STORM + 0 + + + WEATHER_DOWNPOUR + 2 + + + WEATHER_SLEET + 3 + + + WEATHER_LIGHT_HAIL + 0 + + + WEATHER_MOD_RAIN + 4 + + + WEATHER_HEAVY_HAIL + 0 + + + WEATHER_HEAVY_RAIN + 4 + + + WEATHER_LIGHT_SNOW + 6 + + + WEATHER_GUSTING_RAIN + 2 + + + WEATHER_CLEAR + 67 + + + WEATHER_ICE_STORM + 1 + + + WEATHER_LIGHT_RAIN + 7 + + + WEATHER_MOD_SNOW + 2 + + + WEATHER_HEAVY_SNOW + 2 + + + + + Weather + hot wet + + HotHillsWet + HotMountainsWet + HotSea + Jungle + + + + WEATHER_LIGHTNING_STORM + 0 + + + WEATHER_DOWNPOUR + 5 + + + WEATHER_SLEET + 1 + + + WEATHER_LIGHT_HAIL + 0 + + + WEATHER_MOD_RAIN + 12 + + + WEATHER_HEAVY_HAIL + 0 + + + WEATHER_HEAVY_RAIN + 10 + + + WEATHER_LIGHT_SNOW + 1 + + + WEATHER_GUSTING_RAIN + 8 + + + WEATHER_CLEAR + 47 + + + WEATHER_ICE_STORM + 0 + + + WEATHER_LIGHT_RAIN + 16 + + + WEATHER_MOD_SNOW + 0 + + + WEATHER_HEAVY_SNOW + 0 + + + + + Weather + wet + + Sea + Swamp + + + + WEATHER_LIGHTNING_STORM + 0 + + + WEATHER_DOWNPOUR + 6 + + + WEATHER_SLEET + 2 + + + WEATHER_LIGHT_HAIL + 0 + + + WEATHER_MOD_RAIN + 10 + + + WEATHER_HEAVY_HAIL + 0 + + + WEATHER_HEAVY_RAIN + 8 + + + WEATHER_LIGHT_SNOW + 6 + + + WEATHER_GUSTING_RAIN + 6 + + + WEATHER_CLEAR + 46 + + + WEATHER_ICE_STORM + 1 + + + WEATHER_LIGHT_RAIN + 12 + + + WEATHER_MOD_SNOW + 2 + + + WEATHER_HEAVY_SNOW + 1 + + + + + Weather + snowy + + ColdFacility + ColdForest + ColdHills + ColdMountain + ColdSea + ColdUrban + FrozenFacility + FrozenSea + Glacier + SnowField + Tundra + + + + WEATHER_LIGHTNING_STORM + 0 + + + WEATHER_DOWNPOUR + 1 + + + WEATHER_SLEET + 8 + + + WEATHER_LIGHT_HAIL + 0 + + + WEATHER_MOD_RAIN + 3 + + + WEATHER_HEAVY_HAIL + 0 + + + WEATHER_HEAVY_RAIN + 3 + + + WEATHER_LIGHT_SNOW + 12 + + + WEATHER_GUSTING_RAIN + 1 + + + WEATHER_CLEAR + 46 + + + WEATHER_ICE_STORM + 4 + + + WEATHER_LIGHT_RAIN + 6 + + + WEATHER_MOD_SNOW + 10 + + + WEATHER_HEAVY_SNOW + 6 + + + + + Weather + dry + + ArcticDesert + Badlands + Desert + HotHillsDry + HotMountainsDry + + + + WEATHER_LIGHTNING_STORM + 0 + + + WEATHER_DOWNPOUR + 0 + + + WEATHER_SLEET + 1 + + + WEATHER_LIGHT_HAIL + 0 + + + WEATHER_MOD_RAIN + 1 + + + WEATHER_HEAVY_HAIL + 0 + + + WEATHER_HEAVY_RAIN + 0 + + + WEATHER_LIGHT_SNOW + 1 + + + WEATHER_GUSTING_RAIN + 0 + + + WEATHER_CLEAR + 95 + + + WEATHER_ICE_STORM + 0 + + + WEATHER_LIGHT_RAIN + 2 + + + WEATHER_MOD_SNOW + 0 + + + WEATHER_HEAVY_SNOW + 0 + + + + + Fog + standard + + ArcticDesert + Forest + Hills + Jungle + Plains + Savannah + Steppe + TemperateFacility + Urban + + + + FOG_LIGHT + 5 + + + FOG_HEAVY + 5 + + + FOG_NONE + 90 + + + + + Fog + heavy + + ColdFacility + ColdForest + ColdHills + ColdMountain + ColdSea + ColdUrban + FrozenFacility + FrozenSea + Glacier + Mountain + Sea + SnowField + Swamp + Tundra + + + + FOG_LIGHT + 20 + + + FOG_HEAVY + 20 + + + FOG_NONE + 60 + + + + + Fog + none + + Badlands + Desert + HotFacility + HotForest + HotHillsDry + HotHillsWet + HotMountainsDry + HotMountainsWet + HotSea + HotUrban + + + + FOG_LIGHT + 20 + + + FOG_HEAVY + 20 + + + FOG_NONE + 60 + + + + + BlowingSand + standard + + ColdFacility + ColdForest + ColdHills + ColdMountain + ColdSea + ColdUrban + Forest + FrozenFacility + FrozenSea + Hills + HotFacility + HotForest + HotHillsWet + HotMountainsWet + HotSea + HotUrban + Jungle + Mountain + Plains + Savannah + Sea + SnowField + Steppe + Swamp + TemperateFacility + Urban + + + + BLOWING_SAND_NONE + 90 + + + BLOWING_SAND + 10 + + + + + BlowingSand + heavy + + ArcticDesert + Badlands + Desert + Glacier + HotHillsDry + HotMountainsDry + Tundra + + + + BLOWING_SAND_NONE + 40 + + + BLOWING_SAND + 60 + + + + + EMI + standard + + ColdFacility + ColdForest + ColdHills + ColdMountain + ColdSea + ColdUrban + Forest + FrozenFacility + FrozenSea + Glacier + Hills + HotFacility + HotForest + HotHillsWet + HotMountainsWet + HotSea + HotUrban + Jungle + Mountain + Plains + Savannah + Sea + SnowField + Steppe + Swamp + TemperateFacility + Urban + + + + EMI_NONE + 999 + + + EMI + 1 + + + + + EMI + high + + ArcticDesert + Badlands + Desert + HotHillsDry + HotMountainsDry + Tundra + + + + EMI_NONE + 90 + + + EMI + 10 + + + + diff --git a/MekHQ/src/mekhq/MHQConstants.java b/MekHQ/src/mekhq/MHQConstants.java index 80f89b2da6..9ab4e4bdf9 100644 --- a/MekHQ/src/mekhq/MHQConstants.java +++ b/MekHQ/src/mekhq/MHQConstants.java @@ -245,6 +245,7 @@ public final class MHQConstants extends SuiteConstants { public static final String STRATCON_CONTRACT_PATH = "./data/stratconcontractdefinitions/"; public static final String STRATCON_BIOME_MANIFEST_PATH = "./data/stratconbiomedefinitions/StratconBiomeManifest.xml"; + public static final String TERRAIN_CONDITIONS_ODDS_MANIFEST_PATH = "./data/terrainconditionsodds/TerrainConditionsOddsManifest.xml"; public static final String HOSTILE_FACILITY_SCENARIO = "Hostile Facility.xml"; public static final String ALLIED_FACILITY_SCENARIO = "Allied Facility.xml"; public static final String SCENARIO_MODIFIER_ALLIED_GROUND_UNITS = "PrimaryAlliesGround.xml"; diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 200a6cd082..dc8a98eba4 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -57,7 +57,6 @@ import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.IntStream; /** * @author Neoancient @@ -180,6 +179,10 @@ public abstract class AtBScenario extends Scenario implements IAtBScenario { protected final transient ResourceBundle defaultResourceBundle = ResourceBundle.getBundle("mekhq.resources.AtBScenarioBuiltIn", MekHQ.getMHQOptions().getLocale()); + + + private static TerrainConditionsOddsManifest TCO; + private static StratconBiomeManifest SB; //endregion Variable Declarations public AtBScenario () { @@ -197,6 +200,8 @@ public AtBScenario () { deploymentDelay = 0; lanceCount = 0; rerollsRemaining = 0; + TCO = TerrainConditionsOddsManifest.getInstance(); + SB = StratconBiomeManifest.getInstance(); } public void initialize(Campaign c, Lance lance, boolean attacker, LocalDate date) { @@ -301,353 +306,47 @@ private void initBattle(Campaign campaign) { } public void setTerrain() { - Map mapTypes = StratconBiomeManifest.getInstance().getBiomeMapTypes(); + Map mapTypes = SB.getBiomeMapTypes(); List keys = mapTypes.keySet().stream().sorted().collect(Collectors.toList()); setTerrainType(keys.get(Compute.randomInt(keys.size()))); } - private int rollCondition(int[] odds) { - int condition = 0; - int sum = IntStream.of(odds).sum(); - int rollingSum = 0; - int roll = Compute.randomInt(sum); - - for (int i = 0; i < odds.length; i++) { - if (odds[i] > 0) { - rollingSum += odds[i]; - if (roll < rollingSum) { - condition = i; - break; - } - } - } + public void setLightConditions() { + setLight(TCO.rollLightCondition(getTerrainType())); + } - return condition; - } - - private Light rollLightCondition() { - int[] odds; - String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); - - switch (terrainType) { - case "ArcticDesert": - case "Badlands": - case "ColdFacility": - case "ColdForest": - case "ColdHills": - case "ColdSea": - case "ColdUrban": - case "Desert": - case "Forest": - case "FrozenFacility": - case "FrozenSea": - case "Hills": - case "HotFacility": - case "HotForest": - case "HotHillsDry": - case "HotHillsWet": - case "HotSea": - case "HotUrban": - case "Jungle": - case "Plains": - case "Savannah": - case "Sea": - case "SnowField": - case "Steppe": - case "Swamp": - case "TemperateFacility": - case "Tundra": - case "Urban": - // standard - odds = new int[]{600,200,100,99,1}; - break; - case "ColdMountain": - case "Glacier": - case "HotMountainsDry": - case "HotMountainsWet": - case "Mountain": - // dark - odds = new int[]{50,20,10,10,10}; - break; - default: - return Light.DAY; - } - - Light light = Light.getLight(rollCondition(odds)); - - return light; - } - - private Wind rollWindCondition() { - int[] odds; - String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); - - switch (terrainType) { - case "ColdFacility": - case "ColdForest": - case "ColdHills": - case "ColdMountain": - case "ColdUrban": - case "Forest": - case "FrozenFacility": - case "Hills": - case "HotFacility": - case "HotForest": - case "HotHillsDry": - case "HotHillsWet": - case "HotMountainsDry": - case "HotMountainsWet": - case "HotUrban": - case "Jungle": - case "Mountain": - case "Steppe": - case "Swamp": - case "TemperateFacility": - case "Urban": - // standard - odds = new int[]{70,10,10,4,3,2,1}; - break; - case "ArcticDesert": - case "Badlands": - case "ColdSea": - case "Desert": - case "FrozenSea": - case "Glacier": - case "HotSea": - case "Plains": - case "Savannah": - case "Sea": - case "SnowField": - case "Tundra": - // high - odds = new int[]{50,15,15,9,5,4,2}; - break; - default: - return Wind.CALM; + public void setWeather() { + // weather is irrelevant in these situations. + if (getBoardType() == AtBScenario.T_SPACE || + getBoardType() == AtBScenario.T_ATMOSPHERE) { + return; } - Wind wind = Wind.getWind(rollCondition(odds)); + Wind wind = TCO.rollWindCondition(getTerrainType()); - if (!WeatherRestriction.IsWindRestricted(wind.ordinal(), getAtmosphere().ordinal(), getTemperature())) { - return wind; - } else { - return Wind.CALM; - } - } - - private Weather rollWeatherCondition() { - int[] odds; - String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); - - switch (terrainType) { - case "Forest": - case "Hills": - case "HotFacility": - case "HotForest": - case "HotUrban": - case "Mountain": - case "Plains": - case "Savannah": - case "Steppe": - case "TemperateFacility": - case "Urban": - // standard - odds = new int[]{69,7,4,4,2,1,6,2,1,1,2,1}; - break; - case "HotHillsWet": - 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 - odds = new int[]{47,12,10,8,6,4,6,2,1,1,2,1}; - break; - case "ColdFacility": - case "ColdForest": - case "ColdHills": - case "ColdMountain": - case "ColdSea": - case "ColdUrban": - case "FrozenFacility": - case "FrozenSea": - case "SnowField": - case "Tundra": - // snowy - odds = new int[]{41,6,3,3,1,1,12,10,8,6,6,3}; - break; - case "ArcticDesert": - case "Badlands": - case "Desert": - case "HotHillsDry": - case "HotMountainsDry": - // dry - odds = new int[]{87,2,1,1,1,1,2,1,1,1,1,1}; - break; - default: - return Weather.CLEAR; + if (WeatherRestriction.IsWindRestricted(wind.ordinal(), getAtmosphere().ordinal(), getTemperature())) { + wind = Wind.CALM; } - Weather weather = Weather.getWeather(rollCondition(odds)); + Weather weather = TCO.rollWeatherCondition(getTerrainType()); - if (!WeatherRestriction.IsWeatherRestricted(weather.ordinal(), getAtmosphere().ordinal(), getTemperature())) { - return weather; - } else { - return Weather.CLEAR; - } - } - - private Fog rollFogCondition() { - int[] odds; - String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); - - switch (terrainType) { - case "Forest": - case "Glacier": - case "Hills": - case "HotFacility": - case "HotForest": - case "HotUrban": - case "Mountain": - case "Plains": - case "Savannah": - case "Steppe": - case "TemperateFacility": - case "Urban": - // standard - odds = new int[]{90,5,5}; - break; - case "ColdFacility": - case "ColdForest": - case "ColdHills": - case "ColdMountain": - case "ColdSea": - case "ColdUrban": - case "FrozenFacility": - case "FrozenSea": - case "HotHillsWet": - case "HotMountainsWet": - case "HotSea": - case "Jungle": - case "Sea": - case "SnowField": - case "Swamp": - case "Tundra": - // heavy - odds = new int[]{60,20,20}; - break; - default: - return Fog.FOG_NONE; + if (WeatherRestriction.IsWeatherRestricted(weather.ordinal(), getAtmosphere().ordinal(), getTemperature())) { + weather = Weather.CLEAR; } - Fog fog = Fog.getFog(rollCondition(odds)); - - if (!WeatherRestriction.IsFogRestricted(fog.ordinal(), getAtmosphere().ordinal(), getTemperature())) { - return fog; - } else { - return Fog.FOG_NONE; - } - } - - private BlowingSand rollBlowingSandCondition() { - int[] odds; - String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); - - switch (terrainType) { - case "ColdFacility": - case "ColdForest": - case "ColdHills": - case "ColdMountain": - case "ColdUrban": - case "Forest": - case "FrozenFacility": - case "Hills": - case "HotFacility": - case "HotForest": - case "HotHillsWet": - case "HotMountainsWet": - case "HotUrban": - case "Jungle": - case "Mountain": - case "Steppe": - case "Swamp": - case "TemperateFacility": - case "Urban": - // standard - odds = new int[]{90,10}; - break; - case "ArcticDesert": - case "Badlands": - case "Desert": - case "HotHillsDry": - case "HotMountainsDry": - // heavy - odds = new int[]{40,60}; - break; - default: - return BlowingSand.BLOWING_SAND_NONE; - } - - return rollCondition(odds) == 1 ? BlowingSand.BLOWING_SAND : BlowingSand.BLOWING_SAND_NONE; - } - - private EMI rollEMICondition() { - int[] odds; - String terrainType = getTerrainType() == null ? "Hills" : getTerrainType(); - - switch (terrainType) { - case "Forest": - case "Hills": - case "HotFacility": - case "HotForest": - case "HotUrban": - case "Mountain": - case "Plains": - case "Savannah": - case "Steppe": - case "TemperateFacility": - case "Urban": - // standard - odds = new int[]{999,1}; - break; - case "ArcticDesert": - case "Badlands": - case "Desert": - case "HotHillsDry": - case "HotMountainsDry": - // high - odds = new int[]{90,10}; - break; - default: - return EMI.EMI_NONE; - } + Fog fog = TCO.rollFogCondition(getTerrainType()); - if (getAtmosphere().isDenserThan(Atmosphere.THIN)) { - return rollCondition(odds) == 1 ? EMI.EMI : EMI.EMI_NONE; - } else { - return EMI.EMI_NONE; + if (WeatherRestriction.IsFogRestricted(fog.ordinal(), getAtmosphere().ordinal(), getTemperature())) { + fog = Fog.FOG_NONE; } - } - public void setLightConditions() { - setLight(rollLightCondition()); - } + BlowingSand blowingSand = TCO.rollBlowingSandCondition(getTerrainType()); - public void setWeather() { - // weather is irrelevant in these situations. - if (getBoardType() == AtBScenario.T_SPACE || - getBoardType() == AtBScenario.T_ATMOSPHERE) { - return; + if (getAtmosphere().isLighterThan(Atmosphere.TRACE)) { + blowingSand = BlowingSand.BLOWING_SAND_NONE; } - Wind wind = rollWindCondition(); - Weather weather = rollWeatherCondition(); - Fog fog = rollFogCondition(); - BlowingSand blowingSand = rollBlowingSandCondition(); - EMI emi = rollEMICondition(); + EMI emi = TCO.rollEMICondition(getTerrainType()); int temp = getTemperature(); temp = PlanetaryConditions.setTempFromWeather(weather, temp); @@ -721,8 +420,8 @@ public int getBaseMapY() { } public void setMapFile(String terrainType) { - Map biomeMapTypes = StratconBiomeManifest.getInstance().getBiomeMapTypes(); - StratconBiomeManifest.MapTypeList value = biomeMapTypes.get(terrainType); + Map mapTypes = SB.getBiomeMapTypes(); + StratconBiomeManifest.MapTypeList value = mapTypes.get(terrainType); if (value != null) { List mapTypeList = value.mapTypes; setMap(mapTypeList.get(Compute.randomInt(mapTypeList.size()))); diff --git a/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOdds.java b/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOdds.java new file mode 100644 index 0000000000..789d72f1d2 --- /dev/null +++ b/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOdds.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 - The MegaMek Team. All Rights Reserved. + * + * This file is part of MegaMek. + * + * MegaMek is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MegaMek is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MegaMek. If not, see . + */ +package mekhq.campaign.mission; + + +import jakarta.xml.bind.annotation.XmlElementWrapper; + +import java.util.List; +import java.util.Map; + +public class TerrainConditionsOdds { + public String type; + public String name; + @XmlElementWrapper(name = "terrains") + public List terrain; + public Map odds; +} diff --git a/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOddsManifest.java b/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOddsManifest.java new file mode 100644 index 0000000000..e888506266 --- /dev/null +++ b/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOddsManifest.java @@ -0,0 +1,559 @@ +/* + * Copyright (c) 2024 - The MegaMek Team. All Rights Reserved. + * + * This file is part of MegaMek. + * + * MegaMek is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MegaMek is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MegaMek. If not, see . + */ +package mekhq.campaign.mission; + + +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBElement; +import jakarta.xml.bind.Marshaller; +import jakarta.xml.bind.Unmarshaller; +import jakarta.xml.bind.annotation.*; +import megamek.common.Compute; +import megamek.common.enums.*; +import mekhq.MHQConstants; +import mekhq.campaign.stratcon.StratconBiomeManifest; +import mekhq.utilities.MHQXMLUtility; +import org.apache.logging.log4j.LogManager; + +import javax.xml.namespace.QName; +import javax.xml.transform.Source; +import java.io.*; +import java.util.*; +import java.util.stream.Collectors; + +@XmlRootElement(name = "TerrainConditionsOddsManifest") +@XmlAccessorType(XmlAccessType.NONE) +public class TerrainConditionsOddsManifest { + @XmlElement(name="TerrainConditionsOdds") + private static List TCO = new ArrayList<>(); + + private static TerrainConditionsOddsManifest instance; + + public static TerrainConditionsOddsManifest getInstance() { + if (instance == null) { + instance = load(); + validations(); + } + + return instance; + } + + private static TerrainConditionsOddsManifest load() { + TerrainConditionsOddsManifest result = new TerrainConditionsOddsManifest(); + + File inputFile = new File(MHQConstants.TERRAIN_CONDITIONS_ODDS_MANIFEST_PATH); + if (!inputFile.exists()) { + result.TCO.addAll(initLight()); + result.TCO.addAll(initWind()); + result.TCO.addAll(initWeather()); + result.TCO.addAll(initFog()); + result.TCO.addAll(initBlowingSand()); + result.TCO.addAll(initEMI()); + + try { + JAXBContext context = JAXBContext.newInstance(TerrainConditionsOddsManifest.class); + JAXBElement element = new JAXBElement<>(new QName("TerrainConditionsOddsManifest"), + TerrainConditionsOddsManifest.class, result); + StringWriter writer = new StringWriter(); + + Marshaller m = context.createMarshaller(); + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + String comment = "\n\n"; + m.setProperty("org.glassfish.jaxb.xmlHeaders", comment); + m.marshal(element, writer); + FileWriter fw = new FileWriter(inputFile); + fw.append(writer.toString()); + fw.close(); + } catch (Exception ex) { + LogManager.getLogger().error("Error Serializing TerrainConditionsOddsManifest", ex); + } + } else { + try { + JAXBContext context = JAXBContext.newInstance(TerrainConditionsOddsManifest.class); + Unmarshaller um = context.createUnmarshaller(); + try (FileInputStream fileStream = new FileInputStream(inputFile)) { + Source inputSource = MHQXMLUtility.createSafeXmlSource(fileStream); + JAXBElement element = um.unmarshal(inputSource, TerrainConditionsOddsManifest.class); + result = element.getValue(); + } + } catch (Exception ex) { + LogManager.getLogger().error("Error Deserializing TerrainConditionsOddsManifest", ex); + } + } + + return result; + } + + private static void validations() { + Set mapTypes = StratconBiomeManifest.getInstance().getBiomeMapTypes().keySet(); + List types = List.of(Light.class.getSimpleName(), Wind.class.getSimpleName(), + Weather.class.getSimpleName(), Fog.class.getSimpleName(), + BlowingSand.class.getSimpleName(), EMI.class.getSimpleName()); + List enumTypes = new ArrayList<>(); + enumTypes.addAll(Arrays.stream(Light.values()).map(e -> e.getExternalId()).collect(Collectors.toList())); + enumTypes.addAll(Arrays.stream(Wind.values()).map(e -> e.getExternalId()).collect(Collectors.toList())); + enumTypes.addAll(Arrays.stream(Weather.values()).map(e -> e.getExternalId()).collect(Collectors.toList())); + enumTypes.addAll(Arrays.stream(Fog.values()).map(e -> e.getExternalId()).collect(Collectors.toList())); + enumTypes.addAll(Arrays.stream(BlowingSand.values()).map(e -> e.getExternalId()).collect(Collectors.toList())); + enumTypes.addAll(Arrays.stream(EMI.values()).map(e -> e.getExternalId()).collect(Collectors.toList())); + + Map dupTerrain = new HashMap<>(); + List unknownTerrain = new ArrayList<>(); + List unknownTypes = new ArrayList<>(); + List unknownEnums = new ArrayList<>(); + Map> conditionTerrain = new HashMap<>(); + Set terrainSet; + + for (TerrainConditionsOdds tco : instance.TCO) { + String msg = tco.type + " " + tco.name + " odds sum: " + tco.odds.values().stream().mapToInt(i -> i).sum(); + LogManager.getLogger().info(msg); + + for (String terrain : tco.terrain) { + String key = tco.type + " " + terrain; + dupTerrain.put(key, dupTerrain.getOrDefault(key, 0) + 1); + terrainSet = conditionTerrain.getOrDefault(tco.type, new HashSet<>()); + terrainSet.add(terrain); + conditionTerrain.put(tco.type, terrainSet); + if (!mapTypes.contains(terrain)) { + unknownTerrain.add(tco.type + " " + tco.name + " " + terrain); + } + if (!types.contains(tco.type) && !unknownTypes.contains(tco.type)) { + unknownTypes.add(tco.type); + } + } + for (Map.Entry entry: tco.odds.entrySet()) { + if (!enumTypes.contains(entry.getKey()) && !unknownEnums.contains(entry.getKey())) { + unknownEnums.add(entry.getKey()); + } + } + } + + if (!unknownTerrain.isEmpty()) { + LogManager.getLogger().info("unknown terrain: " + unknownTerrain.stream().map(Object::toString).collect(Collectors.joining(", "))); + } + if (!unknownTypes.isEmpty()) { + LogManager.getLogger().info("unknown type: " + unknownTypes.stream().map(Object::toString).collect(Collectors.joining(", "))); + } + if (!unknownEnums.isEmpty()) { + LogManager.getLogger().info("unknown odds key: " + unknownEnums.stream().map(Object::toString).collect(Collectors.joining(", "))); + } + for (Map.Entry entry : dupTerrain.entrySet()) { + if (entry.getValue() > 1) { + LogManager.getLogger().info("duplicate terrain: " + entry.getKey() + " " + entry.getValue()); + } + } + for (Map.Entry> entry : conditionTerrain.entrySet()) { + Set missing = new HashSet<>(); + missing.addAll(mapTypes); + missing.removeAll(entry.getValue()); + if (!missing.isEmpty()) { + LogManager.getLogger().info("missing terrain " + entry.getKey() + ": " + missing.stream().map(Object::toString).collect(Collectors.joining(", "))); + } + } + } + + private static List initLight() { + List terrain; + Map odds; + List result = new ArrayList<>(); + TerrainConditionsOdds t; + + odds = Map.of(Light.DAY.getExternalId(), 600, + Light.DUSK.getExternalId(),200, + Light.FULL_MOON.getExternalId(),100, + Light.MOONLESS.getExternalId(),99, + Light.PITCH_BLACK.getExternalId(),1); + terrain = List.of("ArcticDesert", "Badlands", "ColdFacility", "ColdForest", "ColdHills", + "ColdSea", "ColdUrban", "Desert", "Forest", "FrozenFacility", "FrozenSea", + "Hills", "HotFacility", "HotForest", "HotHillsDry", "HotHillsWet", "HotSea", + "HotUrban", "Jungle", "Plains", "Savannah", "Sea", "SnowField", "Steppe", + "Swamp", "TemperateFacility", "Tundra", "Urban"); + t = new TerrainConditionsOdds(); + t.type = Light.class.getSimpleName(); + t.name = "standard"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + odds = Map.of(Light.DAY.getExternalId(), 50, + Light.DUSK.getExternalId(),20, + Light.FULL_MOON.getExternalId(),10, + Light.MOONLESS.getExternalId(),10, + Light.PITCH_BLACK.getExternalId(),10); + terrain = List.of("ColdMountain", "Glacier", "HotMountainsDry", "HotMountainsWet", "Mountain"); + t = new TerrainConditionsOdds(); + t.type = Light.class.getSimpleName(); + t.name = "dark"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + return result; + } + + private static List initWind() { + List terrain; + Map odds; + List result = new ArrayList<>(); + TerrainConditionsOdds t; + + odds = Map.of(Wind.CALM.getExternalId(), 70, + Wind.LIGHT_GALE.getExternalId(),10, + Wind.MOD_GALE.getExternalId(),10, + Wind.STRONG_GALE.getExternalId(),4, + Wind.STORM.getExternalId(),3, + Wind.TORNADO_F1_TO_F3.getExternalId(),2, + Wind.TORNADO_F4.getExternalId(),1); + terrain = List.of("ColdFacility", "ColdForest", "ColdHills", "ColdMountain", "ColdUrban", + "Forest", "FrozenFacility", "Hills", "HotFacility", "HotForest", "HotHillsWet", "HotMountainsWet", + "HotUrban", "Jungle", "Mountain", "Swamp", "TemperateFacility", "Urban"); + t = new TerrainConditionsOdds(); + t.type = Wind.class.getSimpleName(); + t.name = "standard"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + odds = Map.of(Wind.CALM.getExternalId(), 50, + Wind.LIGHT_GALE.getExternalId(),15, + Wind.MOD_GALE.getExternalId(),14, + Wind.STRONG_GALE.getExternalId(),10, + Wind.STORM.getExternalId(),5, + Wind.TORNADO_F1_TO_F3.getExternalId(),4, + Wind.TORNADO_F4.getExternalId(),2); + terrain = List.of("ArcticDesert", "Badlands", "ColdSea", "Desert", "FrozenSea", + "Glacier", "HotHillsDry", "HotMountainsDry", "HotSea", "Plains", "Savannah", "Sea", + "SnowField", "Steppe", "Tundra"); + t = new TerrainConditionsOdds(); + t.type = Wind.class.getSimpleName(); + t.name = "high"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + return result; + } + + private static List initWeather() { + List terrain; + Map odds = new HashMap<>(); + List result = new ArrayList<>(); + TerrainConditionsOdds t; + + odds.put(Weather.CLEAR.getExternalId(), 67); + odds.put(Weather.LIGHT_RAIN.getExternalId(), 7); + odds.put(Weather.MOD_RAIN.getExternalId(), 4); + odds.put(Weather.HEAVY_RAIN.getExternalId(), 4); + odds.put(Weather.GUSTING_RAIN.getExternalId(), 2); + odds.put(Weather.DOWNPOUR.getExternalId(), 2); + odds.put(Weather.LIGHT_SNOW.getExternalId(), 6); + odds.put(Weather.MOD_SNOW.getExternalId(), 2); + odds.put(Weather.HEAVY_SNOW.getExternalId(), 2); + odds.put(Weather.SLEET.getExternalId(), 3); + odds.put(Weather.ICE_STORM.getExternalId(), 1); + odds.put(Weather.LIGHT_HAIL.getExternalId(), 0); + odds.put(Weather.HEAVY_HAIL.getExternalId(), 0); + odds.put(Weather.LIGHTNING_STORM.getExternalId(), 0); + terrain = List.of("Forest", "Hills", "HotFacility", "HotForest", "HotUrban", "Mountain", + "Plains", "Savannah", "Steppe", "TemperateFacility", "Urban"); + t = new TerrainConditionsOdds(); + t.type = Weather.class.getSimpleName(); + t.name = "standard"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + odds = new HashMap<>(); + odds.put(Weather.CLEAR.getExternalId(), 47); + odds.put(Weather.LIGHT_RAIN.getExternalId(), 16); + odds.put(Weather.MOD_RAIN.getExternalId(), 12); + odds.put(Weather.HEAVY_RAIN.getExternalId(), 10); + odds.put(Weather.GUSTING_RAIN.getExternalId(), 8); + odds.put(Weather.DOWNPOUR.getExternalId(), 5); + odds.put(Weather.LIGHT_SNOW.getExternalId(), 1); + odds.put(Weather.MOD_SNOW.getExternalId(), 0); + odds.put(Weather.HEAVY_SNOW.getExternalId(), 0); + odds.put(Weather.SLEET.getExternalId(), 1); + odds.put(Weather.ICE_STORM.getExternalId(), 0); + odds.put(Weather.LIGHT_HAIL.getExternalId(), 0); + odds.put(Weather.HEAVY_HAIL.getExternalId(), 0); + odds.put(Weather.LIGHTNING_STORM.getExternalId(), 0); + terrain = List.of("HotHillsWet", "HotMountainsWet", "HotSea", "Jungle"); + t = new TerrainConditionsOdds(); + t.type = Weather.class.getSimpleName(); + t.name = "hot wet"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + odds = new HashMap<>(); + odds.put(Weather.CLEAR.getExternalId(), 46); + odds.put(Weather.LIGHT_RAIN.getExternalId(), 12); + odds.put(Weather.MOD_RAIN.getExternalId(), 10); + odds.put(Weather.HEAVY_RAIN.getExternalId(), 8); + odds.put(Weather.GUSTING_RAIN.getExternalId(), 6); + odds.put(Weather.DOWNPOUR.getExternalId(), 6); + odds.put(Weather.LIGHT_SNOW.getExternalId(), 6); + odds.put(Weather.MOD_SNOW.getExternalId(), 2); + odds.put(Weather.HEAVY_SNOW.getExternalId(), 1); + odds.put(Weather.SLEET.getExternalId(), 2); + odds.put(Weather.ICE_STORM.getExternalId(), 1); + odds.put(Weather.LIGHT_HAIL.getExternalId(), 0); + odds.put(Weather.HEAVY_HAIL.getExternalId(), 0); + odds.put(Weather.LIGHTNING_STORM.getExternalId(), 0); + terrain = List.of("Sea", "Swamp"); + t = new TerrainConditionsOdds(); + t.type = Weather.class.getSimpleName(); + t.name = "wet"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + odds = new HashMap<>(); + odds.put(Weather.CLEAR.getExternalId(), 46); + odds.put(Weather.LIGHT_RAIN.getExternalId(), 6); + odds.put(Weather.MOD_RAIN.getExternalId(), 3); + odds.put(Weather.HEAVY_RAIN.getExternalId(), 3); + odds.put(Weather.GUSTING_RAIN.getExternalId(), 1); + odds.put(Weather.DOWNPOUR.getExternalId(), 1); + odds.put(Weather.LIGHT_SNOW.getExternalId(), 12); + odds.put(Weather.MOD_SNOW.getExternalId(), 10); + odds.put(Weather.HEAVY_SNOW.getExternalId(), 6); + odds.put(Weather.SLEET.getExternalId(), 8); + odds.put(Weather.ICE_STORM.getExternalId(), 4); + odds.put(Weather.LIGHT_HAIL.getExternalId(), 0); + odds.put(Weather.HEAVY_HAIL.getExternalId(), 0); + odds.put(Weather.LIGHTNING_STORM.getExternalId(), 0);; + terrain = List.of("ColdFacility", "ColdForest", "ColdHills", "ColdMountain", "ColdSea", "ColdUrban", + "FrozenFacility", "FrozenSea", "Glacier" , "SnowField", "Tundra"); + t = new TerrainConditionsOdds(); + t.type = Weather.class.getSimpleName(); + t.name = "snowy"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + odds = new HashMap<>(); + odds.put(Weather.CLEAR.getExternalId(), 95); + odds.put(Weather.LIGHT_RAIN.getExternalId(), 2); + odds.put(Weather.MOD_RAIN.getExternalId(), 1); + odds.put(Weather.HEAVY_RAIN.getExternalId(), 0); + odds.put(Weather.GUSTING_RAIN.getExternalId(), 0); + odds.put(Weather.DOWNPOUR.getExternalId(), 0); + odds.put(Weather.LIGHT_SNOW.getExternalId(), 1); + odds.put(Weather.MOD_SNOW.getExternalId(), 0); + odds.put(Weather.HEAVY_SNOW.getExternalId(), 0); + odds.put(Weather.SLEET.getExternalId(), 1); + odds.put(Weather.ICE_STORM.getExternalId(), 0); + odds.put(Weather.LIGHT_HAIL.getExternalId(), 0); + odds.put(Weather.HEAVY_HAIL.getExternalId(), 0); + odds.put(Weather.LIGHTNING_STORM.getExternalId(), 0); + terrain = List.of("ArcticDesert", "Badlands", "Desert", "HotHillsDry", "HotMountainsDry"); + t = new TerrainConditionsOdds(); + t.type = Weather.class.getSimpleName(); + t.name = "dry"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + return result; + } + + private static List initFog() { + List terrain; + Map odds; + List result = new ArrayList<>(); + TerrainConditionsOdds t; + + odds = Map.of(Fog.FOG_NONE.getExternalId(), 90, + Fog.FOG_LIGHT.getExternalId(),5, + Fog.FOG_HEAVY.getExternalId(),5); + terrain = List.of("ArcticDesert", "Forest", "Hills", "Jungle", "Plains", "Savannah", "Steppe", "TemperateFacility", "Urban"); + t = new TerrainConditionsOdds(); + t.type = Fog.class.getSimpleName(); + t.name = "standard"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + odds = Map.of(Fog.FOG_NONE.getExternalId(), 60, + Fog.FOG_LIGHT.getExternalId(),20, + Fog.FOG_HEAVY.getExternalId(),20); + terrain = List.of("ColdFacility", "ColdForest", "ColdHills", "ColdMountain", "ColdSea", + "ColdUrban", "FrozenFacility", "FrozenSea", "Glacier", "Mountain", "Sea", + "SnowField", "Swamp", "Tundra"); + t = new TerrainConditionsOdds(); + t.type = Fog.class.getSimpleName(); + t.name = "heavy"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + odds = Map.of(Fog.FOG_NONE.getExternalId(), 60, + Fog.FOG_LIGHT.getExternalId(),20, + Fog.FOG_HEAVY.getExternalId(),20); + terrain = List.of("Badlands", "Desert", "HotFacility", "HotForest", "HotHillsDry", "HotHillsWet", + "HotMountainsDry", "HotMountainsWet", "HotSea", "HotUrban"); + t = new TerrainConditionsOdds(); + t.type = Fog.class.getSimpleName(); + t.name = "none"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + return result; + } + + private static List initBlowingSand() { + List terrain; + Map odds; + List result = new ArrayList<>(); + TerrainConditionsOdds t; + + odds = Map.of(BlowingSand.BLOWING_SAND_NONE.getExternalId(), 90, + BlowingSand.BLOWING_SAND.getExternalId(),10); + terrain = List.of("ColdFacility", "ColdForest", "ColdHills", "ColdMountain", "ColdSea", "ColdUrban", + "Forest", "FrozenFacility", "FrozenSea", "Hills", "HotFacility", "HotForest", + "HotHillsWet", "HotMountainsWet", "HotSea", "HotUrban", "Jungle", "Mountain", "Plains", "Savannah", + "Sea", "SnowField", "Steppe", "Swamp", "TemperateFacility", "Urban"); + t = new TerrainConditionsOdds(); + t.type = BlowingSand.class.getSimpleName(); + t.name = "standard"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + odds = Map.of(BlowingSand.BLOWING_SAND_NONE.getExternalId(), 40, + BlowingSand.BLOWING_SAND.getExternalId(),60); + terrain = List.of("ArcticDesert", "Badlands", "Desert", "Glacier", "HotHillsDry", "HotMountainsDry", "Tundra"); + t = new TerrainConditionsOdds(); + t.type = BlowingSand.class.getSimpleName(); + t.name = "heavy"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + return result; + } + + private static List initEMI() { + List terrain; + Map odds; + List result = new ArrayList<>(); + TerrainConditionsOdds t; + + odds = Map.of(EMI.EMI_NONE.getExternalId(), 999, + EMI.EMI.getExternalId(),1); + terrain = List.of("ColdFacility", "ColdForest", "ColdHills", "ColdMountain", "ColdSea", "ColdUrban", + "Forest", "FrozenFacility", "FrozenSea", "Glacier", "Hills", "HotFacility", "HotForest", + "HotHillsWet", "HotMountainsWet", "HotSea", "HotUrban", "Jungle", "Mountain", + "Plains", "Savannah", "Sea", "SnowField", "Steppe", "Swamp", "TemperateFacility", "Urban"); + t = new TerrainConditionsOdds(); + t.type = EMI.class.getSimpleName(); + t.name = "standard"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + odds = Map.of(EMI.EMI_NONE.getExternalId(), 90, + EMI.EMI.getExternalId(),10); + terrain = List.of("ArcticDesert", "Badlands", "Desert", "HotHillsDry", "HotMountainsDry", "Tundra"); + t = new TerrainConditionsOdds(); + t.type = EMI.class.getSimpleName(); + t.name = "high"; + t.terrain = terrain; + t.odds = odds; + result.add(t); + + return result; + } + + private Map oddsForTerrain(String type, String terrainType) { + terrainType = terrainType.isEmpty() ? "Hills" : terrainType; + + for (TerrainConditionsOdds entry : TCO) { + if (entry.type.equals(type) && entry.terrain.contains(terrainType)) { + return entry.odds; + } + } + + return null; + } + + private String rollCondition(Map odds) { + String condition = ""; + int sum = odds.values().stream().mapToInt(i -> i).sum(); + int rollingSum = 0; + int roll = Compute.randomInt(sum); + TreeMap sorted = new TreeMap<>(odds); + + for (Map.Entry chance : sorted.entrySet()) { + if (chance.getValue() > 0) { + rollingSum += chance.getValue(); + if (roll < rollingSum) { + condition = chance.getKey(); + break; + } + } + } + + return condition; + } + + public Light rollLightCondition(String terrainType) { + Map odds = oddsForTerrain(Light.class.getSimpleName(), terrainType); + + return odds != null ? Light.getLight(rollCondition(odds)) : Light.DAY; + } + + public Wind rollWindCondition(String terrainType) { + Map odds = oddsForTerrain(Wind.class.getSimpleName(), terrainType); + + return odds != null ? Wind.getWind(rollCondition(odds)) : Wind.CALM; + } + + public Weather rollWeatherCondition(String terrainType) { + Map odds = oddsForTerrain(Weather.class.getSimpleName(), terrainType); + + return odds != null ? Weather.getWeather(rollCondition(odds)) : Weather.CLEAR; + } + + public Fog rollFogCondition(String terrainType) { + Map odds = oddsForTerrain(Fog.class.getSimpleName(), terrainType); + + return odds != null ? Fog.getFog(rollCondition(odds)) : Fog.FOG_NONE; + } + + public BlowingSand rollBlowingSandCondition(String terrainType) { + Map odds = oddsForTerrain(BlowingSand.class.getSimpleName(), terrainType); + + return odds != null ? BlowingSand.getBlowingSand(rollCondition(odds)) : BlowingSand.BLOWING_SAND_NONE; + } + + public EMI rollEMICondition(String terrainType) { + Map odds = oddsForTerrain(EMI.class.getSimpleName(), terrainType); + + return odds != null ? EMI.getEMI(rollCondition(odds)) : EMI.EMI_NONE; + } +} From c96d59fce7cfc3ca0d291a90adc1a5ae6c05c370 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 3 Mar 2024 17:06:11 -0500 Subject: [PATCH 35/38] code cleanup --- .../mekhq/campaign/mission/AtBDynamicScenarioFactory.java | 2 +- MekHQ/src/mekhq/campaign/mission/AtBScenario.java | 1 - MekHQ/src/mekhq/campaign/mission/Scenario.java | 6 +++--- MekHQ/src/mekhq/campaign/mission/ScenarioMapParameters.java | 2 +- MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index 321b779ac4..c66762d1f9 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -750,7 +750,7 @@ public static void setTerrain(AtBDynamicScenario scenario) { scenario.setTerrain(); scenario.setMapFile(); } else { - StratconBiomeManifest biomeManifest = StratconBiomeManifest.getInstance(); + StratconBiomeManifest biomeManifest = StratconBiomeManifest.getInstance(); int kelvinTemp = scenario.getTemperature() + StratconContractInitializer.ZERO_CELSIUS_IN_KELVIN; List allowedFacility = biomeManifest.getTempMap(StratconBiomeManifest.TERRAN_FACILITY_BIOME) .floorEntry(kelvinTemp).getValue().allowedTerrainTypes; diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index dc8a98eba4..26acc5369d 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -180,7 +180,6 @@ public abstract class AtBScenario extends Scenario implements IAtBScenario { protected final transient ResourceBundle defaultResourceBundle = ResourceBundle.getBundle("mekhq.resources.AtBScenarioBuiltIn", MekHQ.getMHQOptions().getLocale()); - private static TerrainConditionsOddsManifest TCO; private static StratconBiomeManifest SB; //endregion Variable Declarations diff --git a/MekHQ/src/mekhq/campaign/mission/Scenario.java b/MekHQ/src/mekhq/campaign/mission/Scenario.java index 951859d0c4..cfcf126f7a 100644 --- a/MekHQ/src/mekhq/campaign/mission/Scenario.java +++ b/MekHQ/src/mekhq/campaign/mission/Scenario.java @@ -939,7 +939,7 @@ public static Scenario generateInstanceFromXML(Node wn, Campaign c, Version vers retVal.addBotForce(bf, c); } } else if (wn2.getNodeName().equalsIgnoreCase("scenarioDeploymentLimit")) { - retVal.deploymentLimit = ScenarioDeploymentLimit.generateInstanceFromXML(wn2, c, version); + retVal.deploymentLimit = ScenarioDeploymentLimit.generateInstanceFromXML(wn2, c, version); } else if (wn2.getNodeName().equalsIgnoreCase("usingFixedMap")) { retVal.setUsingFixedMap(Boolean.parseBoolean(wn2.getTextContent().trim())); } else if (wn2.getNodeName().equalsIgnoreCase("boardType")) { @@ -971,10 +971,10 @@ public static Scenario generateInstanceFromXML(Node wn, Campaign c, Version vers } else if (wn2.getNodeName().equalsIgnoreCase("gravity")) { retVal.gravity = Float.parseFloat(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("emi")) { - EMI emi = Boolean.parseBoolean(wn2.getTextContent()) ? EMI.EMI : EMI.EMI_NONE; + EMI emi = Boolean.parseBoolean(wn2.getTextContent()) ? EMI.EMI : EMI.EMI_NONE; retVal.emi = emi; } else if (wn2.getNodeName().equalsIgnoreCase("blowingSand")) { - BlowingSand blowingSand = Boolean.parseBoolean(wn2.getTextContent()) ? BlowingSand.BLOWING_SAND : BlowingSand.BLOWING_SAND_NONE; + 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()); diff --git a/MekHQ/src/mekhq/campaign/mission/ScenarioMapParameters.java b/MekHQ/src/mekhq/campaign/mission/ScenarioMapParameters.java index fb090d9db5..c6791de5b6 100644 --- a/MekHQ/src/mekhq/campaign/mission/ScenarioMapParameters.java +++ b/MekHQ/src/mekhq/campaign/mission/ScenarioMapParameters.java @@ -72,7 +72,7 @@ public ScenarioMapParameters clone() { @XmlElement(name="allowedTerrainType") public List allowedTerrainTypes = new ArrayList<>(); - public List getAllowedTerrainType() { + public List getAllowedTerrainType() { return allowedTerrainTypes; } diff --git a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java index 256c47ac9b..3444dae530 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java +++ b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java @@ -186,7 +186,7 @@ public static void generateScenariosForTrack(Campaign campaign, AtBContract cont public static void setScenarioParametersFromBiome(StratconTrackState track, StratconScenario scenario) { StratconCoords coords = scenario.getCoords(); AtBDynamicScenario backingScenario = scenario.getBackingScenario(); - StratconBiomeManifest biomeManifest = StratconBiomeManifest.getInstance(); + StratconBiomeManifest biomeManifest = StratconBiomeManifest.getInstance(); // for non-surface scenarios, we will skip the temperature update if (backingScenario.getBoardType() != Scenario.T_SPACE && From 0bf09d6a5fcccd0977bd768fd7d4ca31377a8899 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 3 Mar 2024 18:50:39 -0500 Subject: [PATCH 36/38] fix error --- .../campaign/mission/AtBDynamicScenarioFactory.java | 12 ++++++------ .../mission/TerrainConditionsOddsManifest.java | 2 +- .../campaign/stratcon/StratconRulesManager.java | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index c66762d1f9..bc8c390524 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -119,23 +119,23 @@ public static AtBDynamicScenario initializeScenarioFromTemplate(ScenarioTemplate boolean planetsideScenario = template.isPlanetSurface(); + setTerrain(scenario); + + if (campaign.getCampaignOptions().isUsePlanetaryConditions() && planetsideScenario) { + setPlanetaryConditions(scenario, contract, campaign); + } + // set lighting conditions if the user wants to play with them and is on a ground map // theoretically some lighting conditions apply to space maps as well, but requires additional work to implement properly if (campaign.getCampaignOptions().isUseLightConditions() && planetsideScenario) { setLightConditions(scenario); } - if (campaign.getCampaignOptions().isUsePlanetaryConditions() && planetsideScenario) { - setPlanetaryConditions(scenario, contract, campaign); - } - // set weather conditions if the user wants to play with them and is on a ground map if (campaign.getCampaignOptions().isUseWeatherConditions() && planetsideScenario) { setWeather(scenario); } - setTerrain(scenario); - // apply a default "reinforcements" force template if a scenario-specific one does not already exist if (!template.getScenarioForces().containsKey(ScenarioForceTemplate.REINFORCEMENT_TEMPLATE_ID)) { ScenarioForceTemplate defaultReinforcements = ScenarioForceTemplate.getDefaultReinforcementsTemplate(); diff --git a/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOddsManifest.java b/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOddsManifest.java index e888506266..f6d4aecac7 100644 --- a/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOddsManifest.java +++ b/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOddsManifest.java @@ -490,7 +490,7 @@ private static List initEMI() { } private Map oddsForTerrain(String type, String terrainType) { - terrainType = terrainType.isEmpty() ? "Hills" : terrainType; + terrainType = terrainType == null ? "Hills" : terrainType; for (TerrainConditionsOdds entry : TCO) { if (entry.type.equals(type) && entry.terrain.contains(terrainType)) { diff --git a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java index 3444dae530..8882c872b6 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java +++ b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java @@ -231,6 +231,7 @@ public static void setScenarioParametersFromBiome(StratconTrackState track, Stra if (!backingScenario.isUsingFixedMap()) { backingScenario.setMap(mapTypeList.get(Compute.randomInt(mapTypeList.size()))); } + backingScenario.setLightConditions(); backingScenario.setWeather(); } } From 63c5fe34aa54b09b2e1d52fb3cab00a4d1e5a555 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 3 Mar 2024 19:07:54 -0500 Subject: [PATCH 37/38] fix error --- .../src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index bc8c390524..93457572e4 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -119,12 +119,12 @@ public static AtBDynamicScenario initializeScenarioFromTemplate(ScenarioTemplate boolean planetsideScenario = template.isPlanetSurface(); - setTerrain(scenario); - if (campaign.getCampaignOptions().isUsePlanetaryConditions() && planetsideScenario) { setPlanetaryConditions(scenario, contract, campaign); } + setTerrain(scenario); + // set lighting conditions if the user wants to play with them and is on a ground map // theoretically some lighting conditions apply to space maps as well, but requires additional work to implement properly if (campaign.getCampaignOptions().isUseLightConditions() && planetsideScenario) { From 03ed42a10a9b0c827789e8b967b49ed0000e85a5 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Wed, 20 Mar 2024 19:23:45 -0400 Subject: [PATCH 38/38] fix imports --- MekHQ/src/mekhq/AtBGameThread.java | 1 + MekHQ/src/mekhq/GameThread.java | 1 + MekHQ/src/mekhq/adapter/PressureAdapter.java | 3 +-- .../campaign/mission/AtBDynamicScenarioFactory.java | 2 +- MekHQ/src/mekhq/campaign/mission/AtBScenario.java | 3 ++- MekHQ/src/mekhq/campaign/mission/Scenario.java | 3 +-- .../mission/TerrainConditionsOddsManifest.java | 2 +- .../mission/atb/scenario/AceDuelBuiltInScenario.java | 9 ++++----- .../atb/scenario/OfficerDuelBuiltInScenario.java | 10 ++++------ MekHQ/src/mekhq/campaign/universe/Planet.java | 3 +-- MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java | 4 ++-- MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java | 4 ++-- 12 files changed, 21 insertions(+), 24 deletions(-) diff --git a/MekHQ/src/mekhq/AtBGameThread.java b/MekHQ/src/mekhq/AtBGameThread.java index f68fccffe5..8133ef3492 100644 --- a/MekHQ/src/mekhq/AtBGameThread.java +++ b/MekHQ/src/mekhq/AtBGameThread.java @@ -23,6 +23,7 @@ import megamek.client.bot.princess.Princess; import megamek.client.ui.swing.ClientGUI; import megamek.common.*; +import megamek.common.planetaryconditions.PlanetaryConditions; import mekhq.campaign.force.Force; import mekhq.campaign.mission.AtBDynamicScenario; import mekhq.campaign.mission.AtBScenario; diff --git a/MekHQ/src/mekhq/GameThread.java b/MekHQ/src/mekhq/GameThread.java index 63596cf135..1af716d36a 100644 --- a/MekHQ/src/mekhq/GameThread.java +++ b/MekHQ/src/mekhq/GameThread.java @@ -25,6 +25,7 @@ import megamek.client.ui.swing.ClientGUI; import megamek.client.ui.swing.util.MegaMekController; import megamek.common.*; +import megamek.common.planetaryconditions.PlanetaryConditions; import megamek.common.preference.PreferenceManager; import mekhq.campaign.Campaign; import mekhq.campaign.force.Force; diff --git a/MekHQ/src/mekhq/adapter/PressureAdapter.java b/MekHQ/src/mekhq/adapter/PressureAdapter.java index 9fc8f04d4a..fd9c3ccda5 100644 --- a/MekHQ/src/mekhq/adapter/PressureAdapter.java +++ b/MekHQ/src/mekhq/adapter/PressureAdapter.java @@ -19,8 +19,7 @@ package mekhq.adapter; import jakarta.xml.bind.annotation.adapters.XmlAdapter; -import megamek.common.PlanetaryConditions; -import megamek.common.enums.Atmosphere; +import megamek.common.planetaryconditions.Atmosphere; public class PressureAdapter extends XmlAdapter { diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index 93457572e4..da2e407000 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -30,7 +30,7 @@ import megamek.codeUtilities.StringUtility; import megamek.common.*; import megamek.common.annotations.Nullable; -import megamek.common.enums.Atmosphere; +import megamek.common.planetaryconditions.Atmosphere; import megamek.common.enums.Gender; import megamek.common.enums.SkillLevel; import megamek.common.icons.Camouflage; diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 26acc5369d..37cff3ea21 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -27,9 +27,10 @@ import megamek.common.annotations.Nullable; import megamek.common.EntityWeightClass; import megamek.common.enums.*; -import megamek.common.enums.Atmosphere; +import megamek.common.planetaryconditions.*; import megamek.common.icons.Camouflage; import megamek.common.options.OptionsConstants; +import megamek.common.planetaryconditions.Atmosphere; import mekhq.MHQConstants; import mekhq.MekHQ; import mekhq.campaign.Campaign; diff --git a/MekHQ/src/mekhq/campaign/mission/Scenario.java b/MekHQ/src/mekhq/campaign/mission/Scenario.java index cfcf126f7a..baea6bb476 100644 --- a/MekHQ/src/mekhq/campaign/mission/Scenario.java +++ b/MekHQ/src/mekhq/campaign/mission/Scenario.java @@ -26,9 +26,8 @@ import megamek.common.Entity; import megamek.common.IStartingPositions; import megamek.common.MapSettings; -import megamek.common.PlanetaryConditions; import megamek.common.annotations.Nullable; -import megamek.common.enums.*; +import megamek.common.planetaryconditions.*; import mekhq.MekHQ; import mekhq.utilities.MHQXMLUtility; import mekhq.campaign.Campaign; diff --git a/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOddsManifest.java b/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOddsManifest.java index f6d4aecac7..4757e0ea4b 100644 --- a/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOddsManifest.java +++ b/MekHQ/src/mekhq/campaign/mission/TerrainConditionsOddsManifest.java @@ -25,7 +25,7 @@ import jakarta.xml.bind.Unmarshaller; import jakarta.xml.bind.annotation.*; import megamek.common.Compute; -import megamek.common.enums.*; +import megamek.common.planetaryconditions.*; import mekhq.MHQConstants; import mekhq.campaign.stratcon.StratconBiomeManifest; import mekhq.utilities.MHQXMLUtility; diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/AceDuelBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/AceDuelBuiltInScenario.java index c9e5f54bea..a93599390f 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/AceDuelBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/AceDuelBuiltInScenario.java @@ -23,12 +23,11 @@ import megamek.common.Compute; import megamek.common.Entity; 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 megamek.common.planetaryconditions.Fog; +import megamek.common.planetaryconditions.Light; +import megamek.common.planetaryconditions.Weather; +import megamek.common.planetaryconditions.Wind; import mekhq.campaign.Campaign; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.mission.AtBScenario; diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/OfficerDuelBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/OfficerDuelBuiltInScenario.java index 93fba7cd3b..a98738f056 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/OfficerDuelBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/OfficerDuelBuiltInScenario.java @@ -23,12 +23,11 @@ import megamek.common.Compute; import megamek.common.Entity; 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 megamek.common.planetaryconditions.Fog; +import megamek.common.planetaryconditions.Light; +import megamek.common.planetaryconditions.Weather; +import megamek.common.planetaryconditions.Wind; import mekhq.campaign.Campaign; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.mission.AtBScenario; @@ -36,7 +35,6 @@ import mekhq.campaign.mission.ScenarioObjective; import mekhq.campaign.mission.atb.AtBScenarioEnabled; import mekhq.campaign.unit.Unit; -import org.apache.logging.log4j.LogManager; @AtBScenarioEnabled public class OfficerDuelBuiltInScenario extends AtBScenario { diff --git a/MekHQ/src/mekhq/campaign/universe/Planet.java b/MekHQ/src/mekhq/campaign/universe/Planet.java index 4fb52cdc71..05201be9f5 100644 --- a/MekHQ/src/mekhq/campaign/universe/Planet.java +++ b/MekHQ/src/mekhq/campaign/universe/Planet.java @@ -26,7 +26,6 @@ import megamek.codeUtilities.ObjectUtility; import megamek.common.EquipmentType; import megamek.common.ITechnology; -import megamek.common.PlanetaryConditions; import megamek.common.TargetRoll; import mekhq.Utilities; import mekhq.adapter.*; @@ -649,7 +648,7 @@ public Integer getPressure(LocalDate when) { } public String getPressureName(LocalDate when) { - megamek.common.enums.Atmosphere currentPressure = megamek.common.enums.Atmosphere.getAtmosphere(getPressure(when)); + megamek.common.planetaryconditions.Atmosphere currentPressure = megamek.common.planetaryconditions.Atmosphere.getAtmosphere(getPressure(when)); return null != currentPressure ? currentPressure.toString() : "unknown"; } diff --git a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java index 2f8954baec..fc0498b440 100644 --- a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java @@ -24,9 +24,9 @@ import megamek.client.ui.dialogs.BotConfigDialog; import megamek.client.ui.swing.UnitEditorDialog; import megamek.common.IStartingPositions; -import megamek.common.PlanetaryConditions; import megamek.common.annotations.Nullable; -import megamek.common.enums.Atmosphere; +import megamek.common.planetaryconditions.Atmosphere; +import megamek.common.planetaryconditions.PlanetaryConditions; import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.force.ForceStub; diff --git a/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java index 1b9e2e004a..ed00252f36 100644 --- a/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/ScenarioViewPanel.java @@ -20,9 +20,9 @@ */ package mekhq.gui.view; -import megamek.common.PlanetaryConditions; import megamek.common.annotations.Nullable; -import megamek.common.enums.Atmosphere; +import megamek.common.planetaryconditions.Atmosphere; +import megamek.common.planetaryconditions.PlanetaryConditions; import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.force.ForceStub;