Class Scenario

java.lang.Object
mekhq.campaign.mission.scenarios.Scenario
All Implemented Interfaces:
IPlayerSettings
Direct Known Subclasses:
AtBScenario

public class Scenario extends Object implements IPlayerSettings
  • Field Details

    • S_DEFAULT_ID

      public static final int S_DEFAULT_ID
      See Also:
    • T_GROUND

      public static final int T_GROUND
      See Also:
    • T_ATMOSPHERE

      public static final int T_ATMOSPHERE
      See Also:
    • T_SPACE

      public static final int T_SPACE
      See Also:
    • botForces

      protected List<BotForce> botForces
      Lists of enemy forces
    • botForcesStubs

      protected List<BotForceStub> botForcesStubs
    • light

      protected megamek.common.planetaryConditions.Light light
      planetary conditions parameters
    • weather

      protected megamek.common.planetaryConditions.Weather weather
    • wind

      protected megamek.common.planetaryConditions.Wind wind
    • fog

      protected megamek.common.planetaryConditions.Fog fog
    • atmosphere

      protected megamek.common.planetaryConditions.Atmosphere atmosphere
    • atmosphericTaint

      protected megamek.common.planetaryConditions.AtmosphericTaint atmosphericTaint
    • gravity

      protected float gravity
  • Constructor Details

    • Scenario

      public Scenario()
    • Scenario

      public Scenario(String name)
  • Method Details

    • getName

      public String getName()
    • getHyperlinkedName

      public String getHyperlinkedName()
      Returns the name of this object as an HTML hyperlink.

      The hyperlink is formatted with a "SCENARIO:" protocol prefix followed by the object's ID. This allows UI components that support HTML to render the name as a clickable link, which can be used to navigate to or focus on this specific object when clicked.

      Returns:
      An HTML formatted string containing the object's name as a hyperlink with its ID
      Since:
      0.50.05
    • setName

      public void setName(String n)
    • getStratConScenarioType

      public ScenarioType getStratConScenarioType()
    • setStratConScenarioType

      public void setStratConScenarioType(ScenarioType type)
    • getDescription

      public String getDescription()
    • setDesc

      public void setDesc(String d)
    • getReport

      public String getReport()
    • setReport

      public void setReport(String r)
    • getStatus

      public ScenarioStatus getStatus()
    • setStatus

      public void setStatus(ScenarioStatus status)
    • isCrisis

      public boolean isCrisis()
    • setIsCrisis

      public void setIsCrisis(boolean isCrisis)
    • getDate

      @Nullable public LocalDate getDate()
    • setDate

      public void setDate(@Nullable LocalDate date)
    • getLinkedScenario

      public int getLinkedScenario()
    • setLinkedScenarioID

      public void setLinkedScenarioID(int ScenarioID)
    • hasObjectives

      public boolean hasObjectives()
    • getScenarioObjectives

      public List<ScenarioObjective> getScenarioObjectives()
    • setScenarioObjectives

      public void setScenarioObjectives(List<ScenarioObjective> scenarioObjectives)
    • isCloaked

      public boolean isCloaked()
      This indicates that the scenario should not be displayed in the briefing tab.
    • setCloaked

      public void setCloaked(boolean cloaked)
    • getStartingPos

      public int getStartingPos()
      Specified by:
      getStartingPos in interface IPlayerSettings
    • setStartingPos

      public void setStartingPos(int start)
      Specified by:
      setStartingPos in interface IPlayerSettings
    • getStartOffset

      public int getStartOffset()
      Specified by:
      getStartOffset in interface IPlayerSettings
    • setStartOffset

      public void setStartOffset(int startOffset)
      Specified by:
      setStartOffset in interface IPlayerSettings
    • getStartWidth

      public int getStartWidth()
      Specified by:
      getStartWidth in interface IPlayerSettings
    • setStartWidth

      public void setStartWidth(int startWidth)
      Specified by:
      setStartWidth in interface IPlayerSettings
    • getStartingAnyNWx

      public int getStartingAnyNWx()
      Specified by:
      getStartingAnyNWx in interface IPlayerSettings
    • setStartingAnyNWx

      public void setStartingAnyNWx(int startingAnyNWx)
      Specified by:
      setStartingAnyNWx in interface IPlayerSettings
    • getStartingAnyNWy

      public int getStartingAnyNWy()
      Specified by:
      getStartingAnyNWy in interface IPlayerSettings
    • setStartingAnyNWy

      public void setStartingAnyNWy(int startingAnyNWy)
      Specified by:
      setStartingAnyNWy in interface IPlayerSettings
    • getStartingAnySEx

      public int getStartingAnySEx()
      Specified by:
      getStartingAnySEx in interface IPlayerSettings
    • setStartingAnySEx

      public void setStartingAnySEx(int startingAnySEx)
      Specified by:
      setStartingAnySEx in interface IPlayerSettings
    • getStartingAnySEy

      public int getStartingAnySEy()
      Specified by:
      getStartingAnySEy in interface IPlayerSettings
    • setStartingAnySEy

      public void setStartingAnySEy(int startingAnySEy)
      Specified by:
      setStartingAnySEy in interface IPlayerSettings
    • setBoardType

      public void setBoardType(int boardType)
    • getBoardType

      public int getBoardType()
    • getMapSizeX

      public int getMapSizeX()
    • setMapSizeX

      public void setMapSizeX(int mapSizeX)
    • getMapSizeY

      public int getMapSizeY()
    • setMapSizeY

      public void setMapSizeY(int mapSizeY)
    • getMap

      public String getMap()
    • setMap

      public void setMap(String map)
    • getMapForDisplay

      public String getMapForDisplay()
    • isUsingFixedMap

      public boolean isUsingFixedMap()
    • setUsingFixedMap

      public void setUsingFixedMap(boolean usingFixedMap)
    • getLight

      public megamek.common.planetaryConditions.Light getLight()
    • setLight

      public void setLight(megamek.common.planetaryConditions.Light light)
    • getWeather

      public megamek.common.planetaryConditions.Weather getWeather()
    • setWeather

      public void setWeather(megamek.common.planetaryConditions.Weather weather)
    • getWind

      public megamek.common.planetaryConditions.Wind getWind()
    • setWind

      public void setWind(megamek.common.planetaryConditions.Wind wind)
    • getFog

      public megamek.common.planetaryConditions.Fog getFog()
    • setFog

      public void setFog(megamek.common.planetaryConditions.Fog fog)
    • getAtmosphere

      public megamek.common.planetaryConditions.Atmosphere getAtmosphere()
    • setAtmosphere

      public void setAtmosphere(megamek.common.planetaryConditions.Atmosphere atmosphere)
    • getAtmosphericTaint

      public megamek.common.planetaryConditions.AtmosphericTaint getAtmosphericTaint()
      Returns:
      how safe the air is to breathe where this scenario is fought, never null
    • setAtmosphericTaint

      public void setAtmosphericTaint(@Nullable megamek.common.planetaryConditions.AtmosphericTaint atmosphericTaint)
      Parameters:
      atmosphericTaint - the air to fight this scenario in, or null for breathable air. A scenario always has some air recorded, because writeToXML(java.io.PrintWriter, int) asks it for the name to save.
    • getTemperature

      public int getTemperature()
    • setTemperature

      public void setTemperature(int temperature)
    • getGravity

      public float getGravity()
    • setGravity

      public void setGravity(float gravity)
    • setEMI

      public void setEMI(megamek.common.planetaryConditions.EMI emi)
    • getEMI

      public megamek.common.planetaryConditions.EMI getEMI()
    • setBlowingSand

      public void setBlowingSand(megamek.common.planetaryConditions.BlowingSand blow)
    • getBlowingSand

      public megamek.common.planetaryConditions.BlowingSand getBlowingSand()
    • canWindShiftDirection

      public boolean canWindShiftDirection()
    • setShiftWindDirection

      public void setShiftWindDirection(boolean b)
    • canWindShiftStrength

      public boolean canWindShiftStrength()
    • setShiftWindStrength

      public void setShiftWindStrength(boolean b)
    • getMaxWindStrength

      public megamek.common.planetaryConditions.Wind getMaxWindStrength()
    • setMaxWindStrength

      public void setMaxWindStrength(megamek.common.planetaryConditions.Wind strength)
    • getMinWindStrength

      public megamek.common.planetaryConditions.Wind getMinWindStrength()
    • setMinWindStrength

      public void setMinWindStrength(megamek.common.planetaryConditions.Wind strength)
    • createPlanetaryConditions

      public megamek.common.planetaryConditions.PlanetaryConditions createPlanetaryConditions()
      Create a PlanetaryConditions object from variables
      Returns:
      PlanetaryConditions object
    • readPlanetaryConditions

      public void readPlanetaryConditions(megamek.common.planetaryConditions.PlanetaryConditions planetaryConditions)
      Read the values from a PlanetaryConditions object into the Scenario variables for planetary conditions. This is necessary because MekHQ has XML and MegaMek doesn't.
      Parameters:
      planetaryConditions - A PlanetaryConditions object
    • getDeploymentLimit

      public ScenarioDeploymentLimit getDeploymentLimit()
    • setDeploymentLimit

      public void setDeploymentLimit(ScenarioDeploymentLimit limit)
    • getPlayerTransportLinkages

      public Map<UUID,List<UUID>> getPlayerTransportLinkages()
    • addPlayerTransportRelationship

      public void addPlayerTransportRelationship(UUID transportId, UUID cargoId)
      Adds a transport-cargo pair to the internal transport relationship store.
      Parameters:
      transportId - the UUID of the transport object
      cargoId - the UUID of the cargo being transported
    • getId

      public int getId()
    • setId

      public void setId(int i)
    • getMissionId

      @Nullable public UUID getMissionId()
    • setMissionId

      public void setMissionId(@Nullable UUID i)
    • getForceIDs

      public List<Integer> getForceIDs()
    • getForces

      public Formation getForces(Campaign campaign)
    • getSalvageFormations

      public List<Integer> getSalvageFormations()
    • removeSalvageFormation

      public void removeSalvageFormation(List<Integer> forceIds)
    • addSalvageFormation

      public void addSalvageFormation(int forceId)
    • clearSalvageFormations

      public void clearSalvageFormations()
    • getSalvageTechs

      public List<UUID> getSalvageTechs()
    • addSalvageTech

      public void addSalvageTech(UUID personId)
    • removeSalvageTechs

      public void removeSalvageTechs(List<UUID> personIds)
    • clearSalvageTechs

      public void clearSalvageTechs()
    • getIndividualUnitIDs

      public List<UUID> getIndividualUnitIDs()
      Gets the IDs of units deployed to this scenario individually.
    • addForces

      public void addForces(int fid)
    • addUnit

      public void addUnit(UUID uid)
    • containsPlayerUnit

      public boolean containsPlayerUnit(UUID uid)
    • removeUnit

      public void removeUnit(UUID uid)
    • removeFormation

      public void removeFormation(int fid)
    • clearAllFormationsAndPersonnel

      public void clearAllFormationsAndPersonnel(Campaign campaign)
    • convertToStub

      public void convertToStub(Campaign campaign, ScenarioStatus status)
      Converts this scenario to a stub
    • generateStub

      public void generateStub(Campaign c)
    • getForceStub

      public FormationStub getForceStub()
    • isAssigned

      public boolean isAssigned(Unit unit, Campaign campaign)
    • getBotForces

      public List<BotForce> getBotForces()
    • setBotForces

      public void setBotForces(List<BotForce> bf)
    • addBotForce

      public void addBotForce(BotForce botForce, Campaign c)
    • getBotForce

      public BotForce getBotForce(int i)
    • removeBotForce

      public void removeBotForce(int i)
    • getNumBots

      public int getNumBots()
    • getBotForcesStubs

      public List<BotForceStub> getBotForcesStubs()
    • getTraitorUnits

      public List<Unit> getTraitorUnits(Campaign c)
      Get a List of all traitor Units in this scenario. This function just combines the results from BotForce#getTraitorUnits across all BotForces.
      Parameters:
      c - - A Campaign pointer
      Returns:
      a List of traitor Units
    • isTraitor

      public boolean isTraitor(megamek.common.units.Entity en, Campaign c)
      Tests whether a given entity is a traitor in this Scenario by checking external id values. This should also be usable against entities that are ejected pilots from the original traitor entity.
      Parameters:
      en - a MegaMek Entity
      c - a Campaign pointer
      Returns:
      a boolean indicating whether this entity is a traitor in this Scenario.
    • isTraitor

      public boolean isTraitor(UUID personId)
      Given a Person's id, is that person a traitor in this Scenario
      Parameters:
      personId - - a UUID giving a person's id in the campaign
      Returns:
      a boolean indicating if this person is a traitor in the Scenario
    • getExternalIDLookup

      public Map<String,megamek.common.units.Entity> getExternalIDLookup()
    • setExternalIDLookup

      @Deprecated(since="0.51.0", forRemoval=true) public void setExternalIDLookup(HashMap<String,megamek.common.units.Entity> externalIDLookup)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • canDeploy

      public boolean canDeploy(Unit unit, Campaign campaign)
      Determines whether a unit is eligible to deploy to the scenario. If a ScenarioDeploymentLimit is present the unit type will be checked to make sure it is valid. The function also checks to see if the unit is a traitor unit which will disallow deployment.
      Parameters:
      unit - - The Unit to be deployed
      campaign - - a pointer to the Campaign
      Returns:
      true if the unit is eligible, otherwise false
    • canDeployUnits

      public boolean canDeployUnits(Vector<Unit> units, Campaign campaign)
      Determines whether a list of units is eligible to deploy to the scenario.
      Parameters:
      units - - a Vector made up of Units to be deployed
      campaign - - a pointer to the Campaign
      Returns:
      true if all units in the list are eligible, otherwise false
    • canDeployForces

      public boolean canDeployForces(Vector<Formation> formations, Campaign c)
      Determines whether a list of forces is eligible to deploy to the scenario.
      Parameters:
      formations - list of forces
      c - the campaign that the forces are part of
      Returns:
      true if all units in all forces in the list are eligible, otherwise false
    • includesRequiredPersonnel

      public boolean includesRequiredPersonnel(Campaign c)
    • includesRequiredUnits

      public boolean includesRequiredUnits(Campaign c)
    • canStartScenario

      public boolean canStartScenario(Campaign c)
      Determines whether this scenario can be started now. The base implementation applies only the readiness checks in canPrepareScenario(Campaign); subclasses may override it to impose additional restrictions, such as requiring the current date to match the scenario's scheduled date (see AtBScenario).
      Parameters:
      c - the campaign this scenario belongs to
      Returns:
      true if the scenario can be started
    • canPrepareScenario

      public boolean canPrepareScenario(Campaign c)
      Determines whether this scenario is ready for deployment preparation: it is current, has a deployed force, and meets its required personnel and unit constraints.

      This readiness check intentionally excludes any date-based restriction. In the base Scenario implementation canStartScenario(Campaign) simply delegates to this method, but subclasses such as AtBScenario may override canStartScenario to additionally require that the scenario be launched on its scheduled date. Because canPrepareScenario never applies such a restriction, it is suitable for gating preparation actions (adjusting the deployment, exporting or printing the assigned force) that players should be able to perform ahead of the scenario's date.

      Parameters:
      c - the campaign this scenario belongs to
      Returns:
      true if the scenario is current and its deployment requirements are met
    • writeToXML

      public void writeToXML(PrintWriter pw, int indent)
    • writeToXMLBegin

      protected int writeToXMLBegin(PrintWriter pw, int indent)
    • writeToXMLEnd

      protected void writeToXMLEnd(PrintWriter pw, int indent)
    • loadFieldsFromXmlNode

      protected void loadFieldsFromXmlNode(Node wn, megamek.Version version, Campaign campaign) throws ParseException
      Throws:
      ParseException
    • generateInstanceFromXML

      public static Scenario generateInstanceFromXML(Node wn, Campaign c, megamek.Version version)
    • getEntityStub

      protected static List<String> getEntityStub(Node wn)
    • getLoot

      public List<Loot> getLoot()
    • addLoot

      public void addLoot(Loot l)
    • resetLoot

      public void resetLoot()
    • isFriendlyUnit

      public boolean isFriendlyUnit(megamek.common.units.Entity entity, Campaign campaign)
    • getHasTrack

      public boolean getHasTrack()
    • setHasTrack

      public void setHasTrack(boolean b)
    • getStratConRoadEntryEdges

      public List<Integer> getStratConRoadEntryEdges()
      Returns:
      the hex directions (0-5) in which a StratCon sector road leaves this scenario's hex; empty when the scenario is not on a road
    • setStratConRoadEntryEdges

      public void setStratConRoadEntryEdges(List<Integer> stratConRoadEntryEdges)
    • isStratConWaterAdjacent

      public boolean isStratConWaterAdjacent()
      Returns:
      true if this StratCon scenario's hex borders open water (coast, lakeshore, or riverbank)
    • setStratConWaterAdjacent

      public void setStratConWaterAdjacent(boolean stratConWaterAdjacent)
    • isStratConUrban

      public boolean isStratConUrban()
      Returns:
      true if this StratCon scenario's hex holds a city (which overlays any base terrain)
    • setStratConUrban

      public void setStratConUrban(boolean stratConUrban)
    • getStratConUrbanization

      public double getStratConUrbanization()
      Returns:
      how built-up this StratCon scenario's city is, 0.0 (hamlet) to 1.0 (dense metropolis); only meaningful when isStratConUrban() is true
    • setStratConUrbanization

      public void setStratConUrbanization(double stratConUrbanization)
    • getBoardTypeName

      public static String getBoardTypeName(int i)