Class TemporaryECMField

java.lang.Object
megamek.common.TemporaryECMField
All Implemented Interfaces:
Serializable

public class TemporaryECMField extends Object implements Serializable
Represents a temporary ECM field that expires after a set duration.

EMP mines create temporary ECM bubbles that last until the End Phase of the following turn per Tactical Operations: Advanced Rules (Experimental).

See Also:
  • Constructor Details

    • TemporaryECMField

      public TemporaryECMField(Coords position, int range, int creationRound, int expirationRound, GamePhase expirationPhase, int playerId, String source)
      Creates a new temporary ECM field.
      Parameters:
      position - The center hex of the ECM field
      range - The range in hexes (0 = single hex)
      creationRound - The game round when this field was created
      expirationRound - The game round when this field expires
      expirationPhase - The phase during which this field expires
      playerId - The player who created this field (or Player.PLAYER_NONE)
      source - Description of the source (e.g., "EMP Mine")
  • Method Details

    • fromEMPMine

      public static TemporaryECMField fromEMPMine(Coords position, int currentRound, int playerId)
      Creates a temporary ECM field from an EMP mine detonation.

      Per TO:AR, the ECM bubble lasts until the End Phase of the following turn.

      Parameters:
      position - The hex where the EMP mine detonated
      currentRound - The current game round
      playerId - The player who deployed the mine
      Returns:
      A new TemporaryECMField configured for EMP mine effects
    • getPosition

      public Coords getPosition()
      Returns:
      The center position of this ECM field
    • getRange

      public int getRange()
      Returns:
      The range of this ECM field in hexes (0 = single hex only)
    • getCreationRound

      public int getCreationRound()
      Returns:
      The round this field was created
    • getExpirationRound

      public int getExpirationRound()
      Returns:
      The round this field expires
    • getExpirationPhase

      public GamePhase getExpirationPhase()
      Returns:
      The phase during which this field expires
    • getPlayerId

      public int getPlayerId()
      Returns:
      The player ID associated with this field
    • getSource

      public String getSource()
      Returns:
      Description of what created this ECM field
    • isExpired

      public boolean isExpired(int currentRound, GamePhase currentPhase)
      Checks if this ECM field has expired.
      Parameters:
      currentRound - The current game round
      currentPhase - The current game phase
      Returns:
      true if this field has expired
    • affectsHex

      public boolean affectsHex(Coords coords)
      Checks if this ECM field affects the given coordinates.
      Parameters:
      coords - The coordinates to check
      Returns:
      true if this ECM field covers the given hex
    • toECMInfo

      public ECMInfo toECMInfo()
      Converts this temporary field to an ECMInfo object for use in ECM calculations.

      EMP mine ECM is hostile to everyone (including the player who placed the mine), similar to Chaff. This is achieved by passing null as the owner.

      Returns:
      An ECMInfo representing this temporary field, hostile to all players
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object