Skip to content

Commit

Permalink
Issue 6303: RFE - Hazardous Liquid Pools - Changes requested by @rjha…
Browse files Browse the repository at this point in the history
  • Loading branch information
psikomonkie committed Feb 1, 2025
1 parent d5ec24d commit 24ebd71
Show file tree
Hide file tree
Showing 4 changed files with 347 additions and 161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ private double calcHazardousLiquidHazard(Hex hex, boolean endHex, Entity movingU

// After all that math let's make sure we do at least 1 damage
// (.6 repeating when normalized for the HLP doing no damage 1/3 of the time)
dmg = Math.max(dmg, 0.666);
dmg = Math.max(dmg, 2.0/3.0);

if (step.isProne() || (hex.containsTerrain(Terrains.WATER) && hex.terrainLevel(Terrains.WATER) > 1)) {
exposedArmor = movingUnit.getTotalArmor();
Expand Down
17 changes: 6 additions & 11 deletions megamek/src/megamek/common/Terrains.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.HashSet;
import java.util.Hashtable;

import megamek.common.enums.HazardousLiquidPoolType;
import megamek.server.SmokeCloud;

public class Terrains implements Serializable {
Expand Down Expand Up @@ -153,13 +154,6 @@ public class Terrains implements Serializable {
public static final int DEPLOYMENT_ZONE = 57;

public static final int HAZARDOUS_LIQUID = 58;
// Wind blown hazardous is for MapPack Alien Worlds' Wind Blown Hazardous Liquid rules
// Wind blown (MP: Alien Rules) isn't implemented
// Water flow (TO:AR 47 for Hazardous Pools rules) isn't implemented
public static final int HAZARDOUS_LIQUID_LVL_NORMAL = 0;
public static final int HAZARDOUS_LIQUID_LVL_WIND_BLOWN = 1;
public static final int HAZARDOUS_LIQUID_LVL_FLOWS = 2;
public static final int HAZARDOUS_LIQUID_LVL_FLOWS_AND_WIND_BLOWN = 3;

/**
* Keeps track of the different type of terrains that can have exits.
Expand Down Expand Up @@ -406,12 +400,13 @@ public static String getDisplayName(int type, int level) {
case DEPLOYMENT_ZONE:
return "Deployment Zone";
case HAZARDOUS_LIQUID:
switch (level) {
case HAZARDOUS_LIQUID_LVL_WIND_BLOWN:
HazardousLiquidPoolType hazardousLiquidPoolType = HazardousLiquidPoolType.getType(level);
switch (hazardousLiquidPoolType) {
case WIND_BLOWN:
return "Hazardous Liquid (Wind Blown)";
case HAZARDOUS_LIQUID_LVL_FLOWS:
case FLOWS:
return "Hazardous Liquid (Flows)";
case HAZARDOUS_LIQUID_LVL_FLOWS_AND_WIND_BLOWN:
case FLOWS_AND_WIND_BLOWN:
return "Hazardous Liquid (Flows and Wind Blown)";
default:
return "Hazardous Liquid";
Expand Down
49 changes: 49 additions & 0 deletions megamek/src/megamek/common/enums/HazardousLiquidPoolType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2025 - 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 <http://www.gnu.org/licenses/>.
*/

package megamek.common.enums;

import java.util.Arrays;

/**
* A hazardous liquid pool can be wind-blown, pushed by water flow, both, or neither.
*/
public enum HazardousLiquidPoolType {
// Wind blown hazardous is for MapPack Alien Worlds' Wind Blown Hazardous Liquid rules
// Wind blown (MP: Alien Rules) isn't implemented
// Water flow (TO:AR 47 for Hazardous Pools rules) isn't implemented
NORMAL(0),
WIND_BLOWN(1),
FLOWS(2),
FLOWS_AND_WIND_BLOWN(3);

private final Integer terrainLevel;

HazardousLiquidPoolType(final Integer terrainLevel) {
this.terrainLevel = terrainLevel;
}

public int getTerrainLevel() {
return this.terrainLevel;
}

public static HazardousLiquidPoolType getType(final int ordinal) {
return Arrays.stream(HazardousLiquidPoolType.values()).filter(type -> type.ordinal() == ordinal).findFirst().orElse(NORMAL);
}
}
Loading

0 comments on commit 24ebd71

Please sign in to comment.